iden3 / circom

zkSnark circuit compiler
GNU General Public License v3.0
1.28k stars 244 forks source link

modified inputs #29

Closed thomaslavaur closed 2 years ago

thomaslavaur commented 2 years ago

Hello !

I'm trying to verify a commitment of a rescue function. The problem is when I write the commit in the inputs, it's directly modified by the circuit without reasons (the value is less than bn128's elliptic curve group order). Here is my simple circuit :

pragma circom 2.0.0;

include "./rescue.circom";

template test(){ signal input in; signal input commit; signal output out;

component hash = rescue(1);

hash.entree[0] <== in;

out <== hash.sortie;

}

component main {public [commit]} = test();

This is what the public file and the input files looks like : input : 15522569492626651840248353495983403506074603540762064124302882378518279710261 (commit) public : 15522569492626651840248353495983403506074603540762064124302882378518279710261 (hash result) and 15522569492626650996385962682425768945933593965259583670031600469260676104192 (wrong copy of my input)

Can someone tell me if it's an error from me or not?

Thomas

thomaslavaur commented 2 years ago

I think the problem is when I give a big integer as input (even if it's less than the curve group order).

thomaslavaur commented 2 years ago

Ok, I solve the problem. The problem come from the JSON parser used in generate witness. I edited the generate_witness.js file in circom/code_producer/srs/wasm_element/ in order to add a line that enable big integer for parser.

alrubio commented 2 years ago

The solution, without changing anything is using string format for large integers "...". { "in1" : "21888242871839275222246405745257275088548364400416034343698204186575808495616", ... } Handling large numbers without "" is a problem of JS.

alrubio commented 2 years ago

If there are no further comments, I'll proceed to close the issue.