# ZKSMPS Prover Js

## About

ZKSMPS Prover Js is a Javascript / Typescript implementation of the prover of the ZKSMPS.

## Installation

``` 
yarn add @sismo-core/zksmps-prover-js
``` 

## Usage

### Generate a proof 

``` 
const prover = new ZKSMPSProver(
    worldMerkleTree,
    commitmentMapperPubKey
); 

const proof = await prover.generateSnarkProof(
    source.address,
    source.secret,
    source.commitmentReceipt,
    destination.address,
    destination.secret,
    destination.commitmentReceipt,
    selectedValue,
    hostId,
    accountMerkleTree,
    externalNullifier
);

const { privateInputs, publicInputs } = await prover.generateInputs(
    source.address,
    source.secret,
    source.commitmentReceipt,
    destination.address,
    destination.secret,
    destination.commitmentReceipt,
    selectedValue,
    hostId,
    accountMerkleTreeInfo,
    externalNullifier
);
``` 

For the commitment mapper in tests you can use : [@sismo-core/zksmps-commitment-mapper-tester-js](../../commitment-mapper-tester-js)

|  Params  | Type      | Description |
| ---------- | -------------- | ------------- |
| worldMerkleTree | MerkleTree | World Merkle tree that contain the Account Merkle tree |
| commitmentMapperPubKey | EddsaPublicKey | Pub key get from the CommitmentMapper |
| (source|destination).address | string | Ethereum address |
| (source|destination).secret | BigNumber | Secret send in the commit to the CommitmentMapper |
| (source|destination).commitmentReceipt | EddsaSignature | Receipt return by the CommitmentMapper after the commit |
| selectedValue | BigNumber | Value of the attestation |
| hostId | number | Id of the destination host |
| accountMerkleTree | MerkleTree | Merkle tree of the attestation |
| externalNullifier | BigNumber | Combine with sourceIdNullifier to create nullifierHash |
