Skip to content

Commit

Permalink
fix(cli): 🐛 use IsEqual template to correctly compare the addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralOutDotEu committed Nov 1, 2023
1 parent 291fade commit 94f382a
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions templates/circuit.circom
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
pragma circom 2.1.6;

template Whitelist() {
template IsZero() {
signal input in;
signal output out;

signal inv;

inv <-- in!=0 ? 1/in : 0;

out <== -in*inv +1;
in*out === 0;
}


template IsEqual() {
signal input in[2];
signal output out;

component isz = IsZero();

in[1] - in[0] ==> isz.in;

isz.out ==> out;
}

template Whitelist () {

signal input addressInDecimal;
signal input sameAddressButPublic;
signal output c;

component ise = IsEqual();

ise.in[0] <== addressInDecimal;
ise.in[1] <== sameAddressButPublic;
assert(ise.out==1);
c <== ise.out;

assert(addressInDecimal==sameAddressButPublic);
}

component main {public [sameAddressButPublic]} = Whitelist();
component main { public [ sameAddressButPublic ] } = Whitelist();

0 comments on commit 94f382a

Please sign in to comment.