Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot bundle snarkjs correctly. #1002

Open
abcfy2 opened this issue Nov 13, 2022 · 1 comment
Open

Cannot bundle snarkjs correctly. #1002

abcfy2 opened this issue Nov 13, 2022 · 1 comment

Comments

@abcfy2
Copy link

abcfy2 commented Nov 13, 2022

Hi there. I have snarkjs in my source code, but building using ncc seems not working.

Here is my sample project:

tmp.tar.gz

You can use:

npm ci
npm start

to reproduce my issue.

async function plonkVerify() {
  const {proof: _proof, publicSignals: _publicSignals} =
    await wrappedSnark.plonk.fullProve(
      {c: 18, a: 3, b: 15},
      path.join(circuitsRoot, 'adder.wasm'),
      path.join(circuitsRoot, 'adder.zkey')
    );
  console.log('finish code');
}

plonkVerify();

Bundle snarkjs by ncc will never execute code console.log('finish code');. Output:

❯ npm start

> start
> ncc run src/index.ts -e snark.js

ncc: Version 0.34.0
ncc: Compiling file index.js into CJS
ncc: Using typescript@4.7.4 (local user-provided)
   0kB  file.js
   0kB  src/index.d.ts
   0kB  src/constant.d.ts
   0kB  circuits/adder.r1cs
   1kB  worker-pipeline.js
   1kB  worker.js
   1kB  circuits/adder.vkey.json
   5kB  worker1.js
   8kB  src/wrappedSnark.d.ts
  13kB  circuits/adder.zkey
  32kB  circuits/adder.wasm
  40kB  sourcemap-register.js
1144kB  index.js
1342kB  index.js.map
1342kB  index.js.map
2587kB  [2825ms] - ncc 0.34.0
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
enter function fullProve-plonkFullProve
{"level":20,"time":1668348784117,"pid":43678,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Reading Wtns"}















But when I set "start": "ncc run src/index.ts -e snarkjs", and run again. It works very well. Output:

❯ npm start

> start
> ncc run src/index.ts -e snarkjs

ncc: Version 0.34.0
ncc: Compiling file index.js into CJS
ncc: Using typescript@4.7.4 (local user-provided)
  0kB  file.js
  0kB  src/index.d.ts
  0kB  src/constant.d.ts
  0kB  circuits/adder.r1cs
  1kB  worker-pipeline.js
  1kB  worker.js
  1kB  circuits/adder.vkey.json
  5kB  worker1.js
  8kB  src/wrappedSnark.d.ts
 13kB  circuits/adder.zkey
 32kB  circuits/adder.wasm
 40kB  sourcemap-register.js
129kB  index.js
137kB  index.js.map
137kB  index.js.map
367kB  [2704ms] - ncc 0.34.0
enter function fullProve-plonkFullProve
{"level":20,"time":1668348803701,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Reading Wtns"}
{"level":20,"time":1668348803719,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp A: 0/10"}
{"level":20,"time":1668348803733,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp A: 0/10"}
{"level":20,"time":1668348803733,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp B: 0/10"}
{"level":20,"time":1668348803745,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp B: 0/10"}
{"level":20,"time":1668348803745,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp C: 0/10"}
{"level":20,"time":1668348803772,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp C: 0/10"}
{"level":20,"time":1668348803775,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"beta: 3914016556244735536442942518527731075222789228986771161045440701369077186095"}
{"level":20,"time":1668348803776,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"gamma: 7856253856522505844452734569058930871634924687889629597554617885459283856043"}
{"level":20,"time":1668348803786,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp Z: 0/11"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp Z: 0/11"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"phse3: Reading QM4"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"phse3: Reading QL4"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"phse3: Reading QR4"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"phse3: Reading QO4"}
{"level":20,"time":1668348803804,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"phse3: Reading QC4"}
{"level":20,"time":1668348803805,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"alpha: 16404293505290775731228329520062642566128567176692094378342201750484144634877"}
{"level":20,"time":1668348803805,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"calculating t 0/32"}
{"level":20,"time":1668348803813,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"ifft T"}
{"level":20,"time":1668348803815,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"dividing T/Z"}
{"level":20,"time":1668348803815,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"ifft Tz"}
{"level":20,"time":1668348803816,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp T1: 0/9"}
{"level":20,"time":1668348803826,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp T1: 0/9"}
{"level":20,"time":1668348803826,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp T2: 0/9"}
{"level":20,"time":1668348803833,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp T2: 0/9"}
{"level":20,"time":1668348803834,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp T3: 0/14"}
{"level":20,"time":1668348803840,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp T3: 0/14"}
{"level":20,"time":1668348803841,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"xi: 19787884518267292174739713704138290892587349835573736049127058104660608851168"}
{"level":20,"time":1668348803843,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"v: 2154894666340351786464605485682592359425771740947888135511902540165983037010"}
{"level":20,"time":1668348803843,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp Wxi: 0/14"}
{"level":20,"time":1668348803851,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp Wxi: 0/14"}
{"level":20,"time":1668348803851,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp start: multiexp Wxiw: 0/11"}
{"level":20,"time":1668348803873,"pid":43781,"hostname":"fengyu-laptop-mj","from":"snarkjs","msg":"Multiexp end: multiexp Wxiw: 0/11"}
finish code

Please help. Thanks.

@abcfy2
Copy link
Author

abcfy2 commented Dec 23, 2022

Any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant