iden3 / snarkjs

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

Bug: 'snarkjs r1cs print' produces an error with circom 2.0 #106

Closed zk-tarts closed 3 years ago

zk-tarts commented 3 years ago

Description

I'm going through the guide in readme.md.
My error happens at Step 9: Create the circuit.
I'm using the newest version of circom (2.0).
I had to edit the example in order for it to compile (changing signal private to signal). see below

pragma circom 2.0.0; // added this line

template Multiplier(n) {
    signal input a;  // removed "private"
    signal input b; // removed "private"
    signal output c;

    signal int[n];

    int[0] <== a*a +b;
    for (var i=1; i<n; i++){
        int[i]<==int[i-1]*int[i-1] + b;
    }

    c <== int[n-1];
}

component main = Multiplier(1000);

Error Log

$ snarkjs rp circuit.r1cs circuit.sym
[ERROR] snarkJS: RangeError: Offset is outside the bounds of the DataView
    at DataView.getUint32 (<anonymous>)
    at readULE64 (/home/me/.config/yarn/global/node_modules/r1csfile/build/main.cjs:102:32)
    at readMap (/home/me/.config/yarn/global/node_modules/r1csfile/build/main.cjs:92:21)
    at async Object.readR1cs (/home/me/.config/yarn/global/node_modules/r1csfile/build/main.cjs:123:19)
    at async Object.r1csPrint$1 [as action] (/home/me/.config/yarn/global/node_modules/snarkjs/build/cli.cjs:8159:17)
    at async clProcessor (/home/me/.config/yarn/global/node_modules/snarkjs/build/cli.cjs:282:21)

This error is only present when running snarkjs rp on files output from the new compiler.

zk-tarts commented 3 years ago

seems fixed now