This commit is contained in:
yslcrypto 2020-07-13 18:33:50 +02:00
parent 1d0691cb5d
commit 736db053b8

View File

@ -2,35 +2,50 @@
This is a JavaScript and Pure Web Assembly implementation of zkSNARK schemes. It uses the Groth16 Protocol (3 point only and 3 pairings)
This library includes all the tools for the Trusted setup multiparty ceremony.
This includes the universal ceremony "powers of tau".
And the per circuit phase 2 ceremony.
This library includes all the tools required to perform trusted setup multi-party ceremonies: including the universal "powers of tau" ceremony, and the second phase circuit specific ceremonies.
The formats used in this library for the multipary computation are compatible with the ones used in other (implementations in rust)[].
The formats used in this library for the multi-party computation are compatible with the ones used in [Semaphore's Perpetual Powers of Tau](https://github.com/weijiekoh/perpetualpowersoftau) and [other implementations](https://github.com/kobigurk/phase2-bn254).
This library uses the compiled circuits generated by the circom compiler.
This library uses the compiled circuits generated by the [circom](https://github.com/iden3/circom) compiler.
The library works in nodejs and browser.
The library works in `node.js` as well as directly in the browser.
It's a ESM module, so it can be directly imported from bigger projects using rollup or webpack.
It's an [ES module](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/), so it can be directly imported into bigger projects using [Rollup](https://rollupjs.org/guide/en/) or [Webpack](https://webpack.js.org/).
The low level criptography is done directly in wasm. And it uses working threads to parallelize the computations. The result is a high performance library with benchmarks comparable with implementations running in the host.
The low-level cryptography is performed directly in wasm, and uses worker threads to parallelize the computations. The result is a high performance library with benchmarks comparable to host implementations.
## Usage / Tutorial.
## Preliminaries
### Install node v14
First off, make sure you have a recent version of `Node.js` installed. While any version after `v12` should work fine, we recommend you install `v14` or later.
If youre not sure which version of Node you have installed, you can run:
```sh
node -v
```
To download the latest version of Node, see [here](https://nodejs.org/en/download/).
### Install snarkjs and circom
To install `circom` and `snarkjs`, run:
```sh
npm install -g circom@latest
npm install -g snarkjs@latest
```
### Help
If you're seeing an error, try prefixing both commands with `sudo`.
### Understand the Help command
To see a list of all `snarkjs` commands, as well as descriptions about their inputs and outputs, run:
```sh
snarkjs --help
```
In commands that takes long time, you can add the -v or --verbose option to see the progress.
The help for specific command:
@ -39,41 +54,53 @@ Example
snarkjs groth16 prove --help
```
Most of the commands have a shor alias.
Most of the commands have a short alias.
For example, the previos command can also be invoked as:
For example, the previous command can also be invoked as:
```sh
snarkjs g16p --help
```
For this tutorial, create a new direcory and change the path
### Debugging tip
If you a feel a command is taking longer than it should, re-run it with a `-v` or `--verbose` option to see more details about how it's progressing and where it's getting blocked. For example:
```sh
snarkjs g16p -v
```
## Tutorial
### 0. Create a new directory
```sh
mkdir snarkjs_example
cd snarkjs_example
```
### Start a new ceremony.
### 1. Start a new ceremony.
```sh
snarkjs powersoftau new bn128 12 pot12_0000.ptau
```
You can also use bls12-381 as the curve.
The first parameter after `new` refers to the type of curve you wish to use. At the moment, we support both `bn128` and `bls12-381`.
The secons parameter is the power of two of the maximum number of contraints that can accept this ceremony.
The second parameter, in this case `12`, is the power of two of the maximum number of contraints that the ceremony can accept.
In this case 12 means that the maximum constraints will be 2**12 = 4096
In this case, the maximum number of constraints is `2^12 = 4096`.
### Contribute in the ceremony
### 2. Contribute to the ceremony
```sh
snarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name="Example Name" -v
```
The name is a random name and it's include for reference. It's printed in the verification.
### Do a second contribution
### 3. Provide a second contribution
```sh
snarkjs powersoftau contribute pot12_0001.ptau pot12_0002.ptau --name="Second contribution Name" -v -e="some random text"
```
@ -81,7 +108,7 @@ snarkjs powersoftau contribute pot12_0001.ptau pot12_0002.ptau --name="Second co
the -e parameter allows the comman to be non interactive and use this text as an extra source of entropy for the random generation.
### Verify the file
### 4. Verify the file
```sh
snarkjs powersoftau verify pot12_0002.ptau
```
@ -89,7 +116,7 @@ snarkjs powersoftau verify pot12_0002.ptau
This command checks all the contributions of the Multiparty Computation (MPC) and list the hashes of the
intermediary results.
### Contribute using ther party software.
### Contribute using third party software
```sh
snarkjs powersoftau export challange pot12_0002.ptau challange_0003