Skip to content

Commit

Permalink
feat(circom): Add tests to IsEqaulArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-nikolov96 committed Jun 26, 2023
1 parent 044dd90 commit a8ffce9
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions beacon-light-client/circom/circuits/utils/arrays.circom
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ template Selector(N) {
out <== sums[N];
}

<<<<<<< HEAD
=======
template RangeCheck(n) {
signal input in[3];
signal output out;

signal first <== LessThanBitsCheck(64)([in[0], in[1]]);
signal second <== LessThanBitsCheck(64)([in[1], in[2]]);

out <== first * second;
}

>>>>>>> d2c78b2f19ec512a921c39fedcba5413061c5a30
template IsEqualArrays(N) {
signal input in[2][N];
signal output out;
Expand Down
6 changes: 6 additions & 0 deletions beacon-light-client/circom/circuits/utils/numerical.circom
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template LessThanOrEqualBitsCheck(n) {
out <== LessEqThan(n)(in);
}

<<<<<<< HEAD
template RangeCheck(n) {
signal input in[3];
signal output out;
Expand All @@ -36,13 +37,18 @@ template RangeCheck(n) {
out <== first * second;
}

=======
>>>>>>> d2c78b2f19ec512a921c39fedcba5413061c5a30
template DivisionVerification() {
signal input dividend;
signal input divisor;
signal input quotient;
signal input remainder;

<<<<<<< HEAD
//TODO: Needs additional constraint
=======
>>>>>>> d2c78b2f19ec512a921c39fedcba5413061c5a30
dividend === divisor * quotient + remainder;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma circom 2.1.5;

include "../../circuits/utils/arrays.circom";

component main = IsEqualArrays(3) // N must be equal to length in both arrays in input["in"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"in": [["1","2","2"],["1","2","2"]]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"out": "1"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"in": [["100","2","2"],["1","2","101"]]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"out": "0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"in": [["10","8","7"],["7","8","10"]]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"out": "0"}

0 comments on commit a8ffce9

Please sign in to comment.