Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snarkjs

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snarkjs - npm Package Compare versions

Comparing version 0.4.7 to 0.4.9

9

.vscode/launch.json

@@ -7,2 +7,11 @@ {

"configurations": [
{
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{

@@ -9,0 +18,0 @@ "type": "pwa-node",

4

package.json
{
"name": "snarkjs",
"type": "module",
"version": "0.4.7",
"version": "0.4.9",
"description": "zkSNARKs implementation in JavaScript",

@@ -46,3 +46,3 @@ "main": "./build/main.cjs",

"fastfile": "0.0.19",
"ffjavascript": "0.2.37",
"ffjavascript": "0.2.39",
"js-sha3": "^0.8.0",

@@ -49,0 +49,0 @@ "logplease": "^1.2.15",

@@ -35,8 +35,7 @@

### Install snarkjs and circom
### Install snarkjs
To install `circom` and `snarkjs`, run:
To install `snarkjs` run:
```sh
npm install -g circom@latest
npm install -g snarkjs@latest

@@ -74,2 +73,6 @@ ```

### Install circom
To install `circom`, follow the instructions at [installing circom](https://docs.circom.io/getting-started/installation).
## Guide

@@ -226,5 +229,7 @@

cat <<EOT > circuit.circom
pragma circom 2.0.0;
template Multiplier(n) {
signal private input a;
signal private input b;
signal input a;
signal input b;
signal output c;

@@ -252,3 +257,3 @@

```sh
circom circuit.circom --r1cs --wasm --sym -v
circom circuit.circom --r1cs --wasm --sym
```

@@ -307,7 +312,23 @@

### 14. Setup
### 14. Calculate the witness
First, we create a file with the inputs for our circuit:
```sh
cat <<EOT > input.json
{"a": 3, "b": 11}
EOT
```
Now, we use the Javascript/WASM program created by `circom` in the directory *circuit_js* to create the witness (values of all the wires) for our inputs:
```sh
circuit_js$ node generate_witness.js circuit.wasm ../input.json ../witness.wtns
```
### 15. Setup
Currently, snarkjs supports 2 proving systems: groth16 and PLONK.
Groth16 requires a trusted ceremony for each circuit. PLONK does not require it, it's enought with the powers of tau ceremony which is universal.
Groth16 requires a trusted ceremony for each circuit. PLONK does not require it, it's enough with the powers of tau ceremony which is universal.

@@ -340,3 +361,3 @@ #### Plonk

### 15. Contribute to the phase 2 ceremony
### 16. Contribute to the phase 2 ceremony
```sh

@@ -351,3 +372,3 @@ snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="1st Contributor Name" -v

### 16. Provide a second contribution
### 17. Provide a second contribution
```sh

@@ -359,3 +380,3 @@ snarkjs zkey contribute circuit_0001.zkey circuit_0002.zkey --name="Second contribution Name" -v -e="Another random entropy"

### 17. Provide a third contribution using third party software
### 18. Provide a third contribution using third party software

@@ -370,3 +391,3 @@ ```sh

### 18. Verify the latest `zkey`
### 19. Verify the latest `zkey`
```sh

@@ -388,3 +409,3 @@ snarkjs zkey verify circuit.r1cs pot12_final.ptau circuit_0003.zkey

### 19. Apply a random beacon
### 20. Apply a random beacon
```sh

@@ -398,3 +419,3 @@ snarkjs zkey beacon circuit_0003.zkey circuit_final.zkey 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon phase2"

### 20. Verify the final `zkey`
### 21. Verify the final `zkey`
```sh

@@ -406,3 +427,3 @@ snarkjs zkey verify circuit.r1cs pot12_final.ptau circuit_final.zkey

### 21. Export the verification key
### 22. Export the verification key
```sh

@@ -413,26 +434,5 @@ snarkjs zkey export verificationkey circuit_final.zkey verification_key.json

### 22. Calculate the witness
```sh
cat <<EOT > input.json
{"a": 3, "b": 11}
EOT
snarkjs wtns calculate circuit.wasm input.json witness.wtns
```
Calculate the witness (given the inputs `a = 3` and `b = 11`).
### 23. Create the proof
### 23. Debug the final witness calculation
```sh
snarkjs wtns debug circuit.wasm input.json witness.wtns circuit.sym --trigger --get --set
```
And check for any errors in the witness calculation process (best practice).
The `wtns debug` command logs every time a new component starts/ends (`--trigger`), when a signal is set (`--set`) and when it's read (`--get`).
### 24. Create the proof
#### PLONK

@@ -458,3 +458,3 @@

### 25. Verify the proof
### 24. Verify the proof

@@ -476,3 +476,3 @@ #### PLONK

### 26. Turn the verifier into a smart contract
### 25. Turn the verifier into a smart contract
```sh

@@ -484,3 +484,3 @@ snarkjs zkey export solidityverifier circuit_final.zkey verifier.sol

### 27. Simulate a verification call
### 26. Simulate a verification call
```sh

@@ -487,0 +487,0 @@ snarkjs zkey export soliditycalldata public.json proof.json

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc