arnaucube
arnaucube/circomlibPublic Self-hosted repository
circomlib/circuits/smt/smtverifierlevel.circom
circuits/smt/smtverifierlevel.circomRaw
 1/******
 2
 3SMTVerifierLevel
 4
 5This circuit has 1 hash
 6
 7Outputs according to the state.
 8
 9State        root
10=====        =======
11top          H'(child, sibling)
12i0           0
13iold         old1leaf
14inew         new1leaf
15na           0
16
17H' is the Hash function with the inputs shifted acordingly.
18
19*****/
20
21
22template SMTVerifierLevel() {
23    signal input st_top;
24    signal input st_i0;
25    signal input st_iold;
26    signal input st_inew;
27    signal input st_na;
28
29    signal output root;
30    signal input sibling;
31    signal input old1leaf;
32    signal input new1leaf;
33    signal input lrbit;
34    signal input child;
35
36    signal aux[2];
37
38    component proofHash = SMTHash2();
39    component switcher = Switcher();
40
41    switcher.L <== child;
42    switcher.R <== sibling;
43
44    switcher.sel <== lrbit;
45    proofHash.L <== switcher.outL;
46    proofHash.R <== switcher.outR;
47
48    aux[0] <== proofHash.out * st_top;
49    aux[1] <== old1leaf*st_iold;
50
51    root <== aux[0] + aux[1] + new1leaf*st_inew;
52}