iden3 / circom_old

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

compile error when using mimc hash #58

Closed KimiWu123 closed 4 years ago

KimiWu123 commented 4 years ago

Version: circom@0.5.7

It shows this error when I use v0.5.7 to compile, but it works well at v0.0.34. (I got the same error at v0.0.35.)

...circomlib/circuits/mimcsponge.circom:42,4-263,5   Sizes in assignment must be the same
{
 "type": "OP",
 "op": "=",
 "values": [
  {
   "type": "DECLARE",
   "declareType": "VARIABLE",
   "name": {
    "type": "VARIABLE",
    "name": "c",
    "selectors": [],
    "first_line": 42,
    "first_column": 8,
    "last_line": 42,
    "last_column": 9
   },
   "first_line": 42,
   "first_column": 4,
   "last_line": 42,
   "last_column": 9,
   "refId": 6
.
.
.
 ],
 "first_line": 42,
 "first_column": 4,
 "last_line": 263,
 "last_column": 5
}

here is my code snippet

template example_MiMC() {
    var numInput = 2; 
    var rounds = 220; 
    var numOutput = 1;

    signal private input ins[numInput]; 
    signal output outs[numOutput];

    component mimc = MiMCSponge(numInput, rounds, numOutput);
    for(var i=0; i<numInput; i++) {
        mimc.ins[i] <== ins[i];
    }
    mimc.k <== 0;

    for(var i=0; i<numOutput; i++) {
        outs[i] <==  mimc.outs[i];
    }

}

I got the same error when calling MultiMiMC7. No idea what happened, any suggestions?

jbaylina commented 4 years ago

You need to apecify the aizes on the definition..

Example:

var a = [1,2]

Now is wrong

you need to do

var a[2] =[1,2]

Sent from my iPhone

On 18 Apr 2020, at 10:06, Kimi Wu notifications@github.com wrote:

 Version: circom@0.5.7

It shows this error when I use v0.5.7 to compile, but it works well at v0.0.34. (I got the same error at v0.0.35.)

...circomlib/circuits/mimcsponge.circom:42,4-263,5 Sizes in assignment must be the same { "type": "OP", "op": "=", "values": [ { "type": "DECLARE", "declareType": "VARIABLE", "name": { "type": "VARIABLE", "name": "c", "selectors": [], "first_line": 42, "first_column": 8, "last_line": 42, "last_column": 9 }, "first_line": 42, "first_column": 4, "last_line": 42, "last_column": 9, "refId": 6 .. . .. ], "first_line": 42, "first_column": 4, "last_line": 263, "last_column": 5 } here is my code snippet

template example_MiMC() { var numInput = 2; var rounds = 220; var numOutput = 1;

signal private input ins[numInput]; 
signal output outs[numOutput];

component mimc = MiMCSponge(numInput, rounds, numOutput);
for(var i=0; i<numInput; i++) {
    mimc.ins[i] <== ins[i];
}
mimc.k <== 0;

for(var i=0; i<numOutput; i++) {
    outs[i] <==  mimc.outs[i];
}

} I got the same error when calling MultiMiMC7. No idea what happened, any suggestions?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

KimiWu123 commented 4 years ago

sorry for the late reply, but in my example, the size of all the arrays are declared. Did I miss anyone?

     signal private input ins[numInput];
     signal output outs[numOutput];

     component mimc = MiMCSponge(numInput, rounds, numOutput);
     for(var i=0; i<numInput; i++) {
         mimc.ins[i] <== ins[i];
     }
hugo-dc commented 4 years ago

@KimiWu123 The issue seems to be in circomlib, possibly you're using an older version of circomlib where arrays doesn't have an implicit size declared.

This is an example of the latest version of mimcsponge.circom: https://github.com/iden3/circomlib/blob/master/circuits/mimcsponge.circom#L45