iden3 / snarkjs

zkSNARK implementation in JavaScript & WASM
GNU General Public License v3.0
1.77k stars 421 forks source link

snarkjs zkey export json, PLONK, Error: Invalid section size reading #401

Closed doutv closed 1 month ago

doutv commented 1 year ago

I want to export readable json for PLONK

Steps to reproduce the bug:

// demo.circom
pragma circom 2.1.4;

template Example () {
    signal input a;
    signal input b;
    signal input c;

    c === a * b;
}

component main { public [ c ] } = Example();

/* INPUT = {
    "a": "2",
    "b": "3",
    "c": "6"
} */
circom demo.circom --r1cs --wasm --sym
snarkjs plonk setup demo.r1cs ./ptau/pot13_final.ptau demo_final.zkey
snarkjs zkey export json demo_final.zkey demo_final.zkey.json

The last command will produce error:

[ERROR] snarkJS: Error: Invalid section size reading
    at Object.endReadSection (/home/jason/.nvm/versions/node/v16.20.1/lib/node_modules/snarkjs/node_modules/@iden3/binfileutils/build/main.cjs:107:74)
    at readZKey (/home/jason/.nvm/versions/node/v16.20.1/lib/node_modules/snarkjs/build/cli.cjs:3970:35)
    at async zkeyExportJson$1 (/home/jason/.nvm/versions/node/v16.20.1/lib/node_modules/snarkjs/build/cli.cjs:5190:18)
    at async Object.zkeyExportJson [as action] (/home/jason/.nvm/versions/node/v16.20.1/lib/node_modules/snarkjs/build/cli.cjs:13047:22)
    at async clProcessor (/home/jason/.nvm/versions/node/v16.20.1/lib/node_modules/snarkjs/build/cli.cjs:481:27)
doutv commented 1 year ago

I change another Circom program, it produces the same error.

Maybe the problem is inside zkeyExportJson.