Open this in zkREPL →
This file can be included into other zkREPLs with include "gist:9c8d24ea5fd8507b90c3695c21a1c67e";
Open this in zkREPL →
This file can be included into other zkREPLs with include "gist:9c8d24ea5fd8507b90c3695c21a1c67e";
Open this in zkREPL →
This file can be included into other zkREPLs with include "gist:9c8d24ea5fd8507b90c3695c21a1c67e";
pragma circom 2.1.6; | |
include "circomlib/pedersen.circom"; | |
include "circomlib/comparators.circom"; | |
template rpPedersen(N) { | |
signal input x; // N bits | |
signal input r; // 128 bits | |
signal output c0; | |
signal output c1; | |
signal input ul; | |
component bitifyX = Num2Bits(N); | |
bitifyX.in <== x; | |
component bitifyR = Num2Bits(128); | |
bitifyR.in <== r; | |
component CPed = Pedersen(N + 128); | |
for (var i = 0; i < N; i++) { | |
CPed.in[i] <== bitifyX.out[i]; | |
} | |
for (var i = 0; i < 128; i++) { | |
CPed.in[N + i] <== bitifyR.out[i]; | |
} | |
CPed.out[0] ==> c0; | |
CPed.out[1] ==> c1; | |
component CLess = LessThan(N); | |
CLess.in[0] <== x; | |
CLess.in[1] <== ul; | |
CLess.out === 1; | |
log(CLess.out); | |
} | |
component main{public [ul]} = rpPedersen(32); | |
/* INPUT = { | |
"x": "5", | |
"r": "77", | |
"ul": "6" | |
} */ |
pragma circom 2.1.6; | |
include "circomlib/poseidon.circom"; | |
include "circomlib/comparators.circom"; | |
template rpPoseidon(N) { | |
signal input x; | |
signal input r; | |
signal output c; | |
signal input ul; | |
component CPos = Poseidon(2); | |
CPos.inputs[0] <== x; | |
CPos.inputs[1] <== r; | |
CPos.out ==> c; | |
component rangeCheck = Num2Bits(N); | |
rangeCheck.in <== x; | |
component CLess = LessThan(N); | |
CLess.in[0] <== x; | |
CLess.in[1] <== ul; | |
CLess.out === 1; | |
log(CLess.out); | |
} | |
component main{public [ul]} = rpPoseidon(32); | |
/* INPUT = { | |
"x": "5", | |
"r": "77", | |
"ul": "7" | |
} */ |