Cannot bundle snarkjs correctly.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 9.8k
- Forks
- 326
- PR merge metrics
- No merged PRs in 30d
Description
Hi there. I have snarkjs in my source code, but building using ncc seems not working.
Here is my sample project:
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Download the linked tmp.tar.gz sample, run npm ci, and reproduce with npm start using src/index.ts and the ncc -e option. Compare the failing snark.js exclusion with the working snarkjs exclusion, then verify that the bundled program reaches console.log('finish code') and completes the PLONK proof.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100