Skip to content

Instantly share code, notes, and snippets.

@ahaym
Created December 23, 2021 19:09
Show Gist options
  • Save ahaym/de775a7681c21ef756f2f8685c52e7f1 to your computer and use it in GitHub Desktop.
Save ahaym/de775a7681c21ef756f2f8685c52e7f1 to your computer and use it in GitHub Desktop.
include"../node_modules/circomlib/circuits/mimcsponge.circom";
template Main() {
signal private input leaf ;
signal input root ;
signal private input pathElements[2] ;
signal private input pathIndices[2] ;
signal output out ;
signal sig__temp0 ;
signal sig__temp1 ;
sig__temp0 <-- (((pathElements[0])-(leaf))*(pathIndices[0]))+(leaf);
sig__temp0 === (((pathElements[0])-(leaf))*(pathIndices[0]))+(leaf);
sig__temp1 <-- (((leaf)-(pathElements[0]))*(pathIndices[0]))+(pathElements[0]);
sig__temp1 === (((leaf)-(pathElements[0]))*(pathIndices[0]))+(pathElements[0]);
component hasher__temp2 = MiMCSponge ( 2, 220, 1 ) ;
hasher__temp2.ins[0] <-- sig__temp0;
hasher__temp2.ins[0] === sig__temp0;
hasher__temp2.ins[1] <-- sig__temp1;
hasher__temp2.ins[1] === sig__temp1;
hasher__temp2.k <-- 0;
hasher__temp2.k === 0;
signal sig__temp3 ;
signal sig__temp4 ;
sig__temp3 <-- (((pathElements[1])-(hasher__temp2.outs[0]))*(pathIndices[1]))+(hasher__temp2.outs[0]);
sig__temp3 === (((pathElements[1])-(hasher__temp2.outs[0]))*(pathIndices[1]))+(hasher__temp2.outs[0]);
sig__temp4 <-- (((hasher__temp2.outs[0])-(pathElements[1]))*(pathIndices[1]))+(pathElements[1]);
sig__temp4 === (((hasher__temp2.outs[0])-(pathElements[1]))*(pathIndices[1]))+(pathElements[1]);
component hasher__temp5 = MiMCSponge ( 2, 220, 1 ) ;
hasher__temp5.ins[0] <-- sig__temp3;
hasher__temp5.ins[0] === sig__temp3;
hasher__temp5.ins[1] <-- sig__temp4;
hasher__temp5.ins[1] === sig__temp4;
hasher__temp5.k <-- 0;
hasher__temp5.k === 0;
root === hasher__temp5.outs[0];
}
component main = Main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment