From 9d2c1c53cf3c8fb2416aa305492a941204e2edc3 Mon Sep 17 00:00:00 2001 From: Saleel Date: Wed, 4 Oct 2023 20:15:47 +0530 Subject: [PATCH] chore: update gen zkey script --- README.md | 33 +++++- .../scripts/3_gen_chunk_zkey.sh | 4 + yarn.lock | 109 +++++++++++++++++- 3 files changed, 139 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 924f2f1..f16f781 100644 --- a/README.md +++ b/README.md @@ -129,11 +129,8 @@ wget https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_21.ptau -#### Zkey Creation -Put the email into `emls` folder. Use the below command to generate the input.json for twitter - -`ts-node packages/twitter-verifier-app/scripts/generate_input.ts --email_file=./emls/zktestemail_twitter.eml` +#### Building circuit and generating Zkeys You can also edit the constant filename at the top of generate_input.ts to import that file instead of the args. You can then use the output of running that file as the input file (you may need to rename it) for both zkey and verifier generation. @@ -150,7 +147,33 @@ cp entropy.env.example entropy.env Fill out the env via random characters into the values for entropy1 and entropy2, and hexadecimal characters into the beacon. These scripts will compile and test your zkey for you, and generate a normal zkey with for an on chain verifier or server side prover, with the same entropy as the chunked one. If you only want the chunked one, use ./3_gen_chunk_zkey.sh in place of the generation. ```bash -./1_compile.sh && ./2_gen_wtns.sh && ./3_gen_both_zkeys.sh && ./4_gen_vkey.sh && ./5_gen_proof.sh +./1_compile.sh && ./3_gen_both_zkeys.sh && ./4_gen_vkey.sh +``` + +#### Generating input and witness + +Put the email into `emls` folder. Use the below command to generate the input.json for twitter + +`ts-node --project=tsconfig.json packages/twitter-verifier-app/scripts/generate_input.ts --email_file=./emls/zktestemail_twitter.eml` + +`input.json` will be written to `/packages/twitter-verifier-circuits/inputs/input.json` which can be used for witness generation and proving. + +You can generate witness by running + +```bash +./2_gen_wtns.sh +``` + +and create generate proof using +```bash +./5_gen_proof.sh +``` + +#### Generating solidity verifier + +Run +```bash +./7_gen_solidity_verifier.sh ``` #### Server-side Prover: Rapidsnark Setup (Optional) diff --git a/packages/twitter-verifier-circuits/scripts/3_gen_chunk_zkey.sh b/packages/twitter-verifier-circuits/scripts/3_gen_chunk_zkey.sh index 987f887..9bc5c2d 100755 --- a/packages/twitter-verifier-circuits/scripts/3_gen_chunk_zkey.sh +++ b/packages/twitter-verifier-circuits/scripts/3_gen_chunk_zkey.sh @@ -12,6 +12,10 @@ if [ ! -d "$BUILD_DIR"/partial_zkeys ]; then mkdir -p "$BUILD_DIR"/partial_zkeys fi +yarn remove snarkjs +yarn add snarkjs@git+https://github.com/vb7401/snarkjs.git#24981febe8826b6ab76ae4d76cf7f9142919d2b8 +yarn + echo "****GENERATING ZKEY NONCHUNKED 0****" start=$(date +%s) set -x diff --git a/yarn.lock b/yarn.lock index 87dc8d9..c7b8c25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2219,6 +2219,16 @@ __metadata: languageName: node linkType: hard +"@iden3/binfileutils@npm:0.0.10": + version: 0.0.10 + resolution: "@iden3/binfileutils@npm:0.0.10" + dependencies: + fastfile: 0.0.19 + ffjavascript: ^0.2.48 + checksum: cdeb8ac01e12f485d9fb236654c00d5d5016fc89eae24f7822885dd42f09935cbef601dbdd8a0c96dfb00ded9f4f623e0eec0b568aa86d16522cf77ce6f9498b + languageName: node + linkType: hard + "@iden3/binfileutils@npm:0.0.11": version: 0.0.11 resolution: "@iden3/binfileutils@npm:0.0.11" @@ -3370,7 +3380,7 @@ __metadata: ffjavascript: ^0.2.59 jest: ^29.5.0 mocha: ^10.2.0 - snarkjs: "https://github.com/sampritipanda/snarkjs.git#fef81fc51d17a734637555c6edbd585ecda02d9e" + snarkjs: "git+https://github.com/vb7401/snarkjs.git#24981febe8826b6ab76ae4d76cf7f9142919d2b8" languageName: unknown linkType: soft @@ -5245,7 +5255,7 @@ __metadata: languageName: node linkType: hard -"big-integer@npm:^1.6.51": +"big-integer@npm:^1.6.42, big-integer@npm:^1.6.48, big-integer@npm:^1.6.51": version: 1.6.51 resolution: "big-integer@npm:1.6.51" checksum: 3d444173d1b2e20747e2c175568bedeebd8315b0637ea95d75fd27830d3b8e8ba36c6af40374f36bdaea7b5de376dcada1b07587cb2a79a928fccdb6e6e3c518 @@ -5337,6 +5347,13 @@ __metadata: languageName: node linkType: hard +"blakejs@npm:^1.1.0": + version: 1.2.1 + resolution: "blakejs@npm:1.2.1" + checksum: d699ba116cfa21d0b01d12014a03e484dd76d483133e6dc9eb415aa70a119f08beb3bcefb8c71840106a00b542cba77383f8be60cd1f0d4589cb8afb922eefbe + languageName: node + linkType: hard + "bluebird@npm:^3.5.5": version: 3.7.2 resolution: "bluebird@npm:3.7.2" @@ -5991,6 +6008,17 @@ __metadata: languageName: node linkType: hard +"circom_runtime@npm:0.1.17": + version: 0.1.17 + resolution: "circom_runtime@npm:0.1.17" + dependencies: + ffjavascript: 0.2.48 + bin: + calcwit: calcwit.js + checksum: 595fc0cc3a62ba5daf8d849feae41c48805c0df43965f85dde4dc434efb607e455fa7801d41c1feacfe0c3c71952a45cd3985abf26fde40c54138392891afd8c + languageName: node + linkType: hard + "circom_runtime@npm:0.1.21": version: 0.1.21 resolution: "circom_runtime@npm:0.1.21" @@ -8024,6 +8052,13 @@ __metadata: languageName: node linkType: hard +"fastfile@npm:0.0.19, fastfile@npm:^0.0.19": + version: 0.0.19 + resolution: "fastfile@npm:0.0.19" + checksum: 6179bdd7c21be9882294dae66103795c099594098b51958bcf08a4545c91387321b43511730d0542a5a9ed8c5ec9069c065e065fd67255453ac900a23895dac1 + languageName: node + linkType: hard + "fastfile@npm:0.0.20": version: 0.0.20 resolution: "fastfile@npm:0.0.20" @@ -8065,6 +8100,18 @@ __metadata: languageName: node linkType: hard +"ffjavascript@npm:0.2.48": + version: 0.2.48 + resolution: "ffjavascript@npm:0.2.48" + dependencies: + big-integer: ^1.6.48 + wasmbuilder: ^0.0.12 + wasmcurves: 0.1.0 + web-worker: ^1.2.0 + checksum: 68beae9a4f642c06656685353b84fd7655020ca0e628ea046e94452ab779587953cc45cde106d74b68be7177b49c8f19b105d6552c4a1d715e784ae9e7c9ed34 + languageName: node + linkType: hard + "ffjavascript@npm:0.2.56": version: 0.2.56 resolution: "ffjavascript@npm:0.2.56" @@ -12855,6 +12902,18 @@ __metadata: languageName: node linkType: hard +"r1csfile@npm:0.0.35": + version: 0.0.35 + resolution: "r1csfile@npm:0.0.35" + dependencies: + "@iden3/bigarray": 0.0.2 + "@iden3/binfileutils": 0.0.10 + fastfile: 0.0.19 + ffjavascript: 0.2.48 + checksum: 84f7b4eab5bcdd6a3f6d699998c9479a5eff8d670383d4f0c5afc08431f45353abab9a8b07eeabaef89807e24b0ba50611d4d6280eb6c3a7483e1487a91f0ac6 + languageName: node + linkType: hard + "r1csfile@npm:0.0.41, r1csfile@npm:^0.0.41": version: 0.0.41 resolution: "r1csfile@npm:0.0.41" @@ -13128,6 +13187,13 @@ __metadata: languageName: node linkType: hard +"readline@npm:^1.3.0": + version: 1.3.0 + resolution: "readline@npm:1.3.0" + checksum: dfaf8e6ac20408ea00d650e95f7bb47f77c4c62dd12ed7fb51731ee84532a2f3675fcdc4cab4923dc1eef227520a2e082a093215190907758bea9f585b19438e + languageName: node + linkType: hard + "real-require@npm:^0.1.0": version: 0.1.0 resolution: "real-require@npm:0.1.0" @@ -13902,6 +13968,26 @@ __metadata: languageName: node linkType: hard +"snarkjs@git+https://github.com/vb7401/snarkjs.git#24981febe8826b6ab76ae4d76cf7f9142919d2b8": + version: 0.4.12 + resolution: "snarkjs@https://github.com/vb7401/snarkjs.git#commit=24981febe8826b6ab76ae4d76cf7f9142919d2b8" + dependencies: + "@iden3/binfileutils": 0.0.10 + blake2b-wasm: ^2.4.0 + circom_runtime: 0.1.17 + ejs: ^3.1.6 + fastfile: ^0.0.19 + ffjavascript: 0.2.48 + js-sha3: ^0.8.0 + logplease: ^1.2.15 + r1csfile: 0.0.35 + readline: ^1.3.0 + bin: + snarkjs: build/cli.cjs + checksum: 9011df4b58475a0b4ae988f8b459a9a4d2bb5d2b60221d0ec370a10f2492c88909768215f3b22e514b2cf24dca79818790447005a33ed6aee177b9fda6948a75 + languageName: node + linkType: hard + "snarkjs@https://github.com/sampritipanda/snarkjs.git#fef81fc51d17a734637555c6edbd585ecda02d9e": version: 0.5.0 resolution: "snarkjs@https://github.com/sampritipanda/snarkjs.git#commit=fef81fc51d17a734637555c6edbd585ecda02d9e" @@ -15498,6 +15584,25 @@ __metadata: languageName: node linkType: hard +"wasmbuilder@npm:^0.0.12": + version: 0.0.12 + resolution: "wasmbuilder@npm:0.0.12" + dependencies: + big-integer: ^1.6.48 + checksum: 327b3c50b0e1e5e3aac9e218e0f96fdc638b7952ab86acc2ad53960371996826dbb0a8095edce482cf1d9c245d96884449701909bc962920aa7ec8241db01214 + languageName: node + linkType: hard + +"wasmcurves@npm:0.1.0": + version: 0.1.0 + resolution: "wasmcurves@npm:0.1.0" + dependencies: + big-integer: ^1.6.42 + blakejs: ^1.1.0 + checksum: 6bf6719e659a88904af0b98d152316e3b22435ca6a2cfc8bbf4530576806f17b2776b2c7d91d1a678fe0d51485a0d1748efcd080808c181c7977bee50b26efa9 + languageName: node + linkType: hard + "wasmcurves@npm:0.2.0": version: 0.2.0 resolution: "wasmcurves@npm:0.2.0"