iden3 / circom_old

Circuit compiler for zkSNARKs
GNU General Public License v3.0
472 stars 82 forks source link

input value is changed #48

Closed KimiWu123 closed 4 years ago

KimiWu123 commented 4 years ago

I tried to verify signature by EdDSAVerifier but it's always failed. So I split the verification of S part into another sample as following,

template test() {

    signal input S;
    signal output out[2];

    component SBits = Num2Bits(256)
    SBits.in <== S;

    var BASE8 = [
        5299619240641551281634865583518297030282874472190772894086521144482721001553,
        16950150798460657717958625567821834550301663161624707787222815936182638968203
    ];
    component mulFix = EscalarMulFix(256, BASE8);
    for (var i=0; i<256; i++) {
        mulFix.e[i] <== SBits.out[i];
    }

    mulFix.out[0] ==> out[0];
    mulFix.out[1] ==> out[1];
}

component main = test();

and my input.json is

{"S": 2129243915978267980511515511350111723623685317644064470882297086073041379651}

The value in public.json after I invoke snarkjs proof would be

[
 "21077223667197299398911811132080519749183972580603377412513269668177406276917",
 "7405681274430135500839781818487463621807111870717884804708224059611060758039",
 "2129243915978268095655899854089454063261110467163115800685838184083248644096"
]

The last one 2129243915978268095655899854089454063261110467163115800685838184083248644096 should be my input S, but the value has been changed. That causes the output value is not what I expected. What happened? Is there any limitation of input values?

KimiWu123 commented 4 years ago

I found the root cause, the value should be embedded in double quotes ".

{"S": "2129243915978267980511515511350111723623685317644064470882297086073041379651"}