Skip to content

Commit 9a921f8

Browse files
author
tilo-14
committed
fix(circuits): Fix CI compilation errors and address PR feedback
zk-nullifier: - Split nullifier.circom into template + nullifier_main.circom - Fixes multiple main components error when batchnullifier includes nullifier zk-merkle-proof & zk-id: - Replace Num2Bits_strict(levels) with Num2Bits(levels) - Remove redundant LessThan range check (Num2Bits already constrains) - Remove unused comparators.circom import
1 parent 042c0d8 commit 9a921f8

5 files changed

Lines changed: 8 additions & 19 deletions

File tree

zk/zk-id/circuits/merkle_proof.circom

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma circom 2.0.0;
33
include "../node_modules/circomlib/circuits/poseidon.circom";
44
include "../node_modules/circomlib/circuits/bitify.circom";
55
include "../node_modules/circomlib/circuits/switcher.circom";
6-
include "../node_modules/circomlib/circuits/comparators.circom";
76

87
// Merkle Proof Verification Template
98
// Verifies that a leaf is in a Merkle tree with a given root
@@ -13,16 +12,9 @@ template MerkleProof(levels) {
1312
signal input leafIndex;
1413
signal output root;
1514

16-
// Range check: leafIndex < 2^levels
17-
component indexRange = LessThan(levels + 1);
18-
indexRange.in[0] <== leafIndex;
19-
indexRange.in[1] <== 1 << levels;
20-
indexRange.out === 1;
21-
2215
component switcher[levels];
2316
component hasher[levels];
24-
25-
component indexBits = Num2Bits_strict(levels);
17+
component indexBits = Num2Bits(levels);
2618
indexBits.in <== leafIndex;
2719

2820
for (var i = 0; i < levels; i++) {

zk/zk-merkle-proof/circuits/merkle_proof.circom

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@ pragma circom 2.0.0;
33
include "../node_modules/circomlib/circuits/poseidon.circom";
44
include "../node_modules/circomlib/circuits/bitify.circom";
55
include "../node_modules/circomlib/circuits/switcher.circom";
6-
include "../node_modules/circomlib/circuits/comparators.circom";
76

87
template MerkleProof(levels) {
98
signal input leaf;
109
signal input pathElements[levels];
1110
signal input leafIndex;
1211
signal output root;
1312

14-
// Range check: leafIndex < 2^levels
15-
component indexRange = LessThan(levels + 1);
16-
indexRange.in[0] <== leafIndex;
17-
indexRange.in[1] <== 1 << levels;
18-
indexRange.out === 1;
19-
2013
component switcher[levels];
2114
component hasher[levels];
22-
component indexBits = Num2Bits_strict(levels);
15+
component indexBits = Num2Bits(levels);
2316
indexBits.in <== leafIndex;
2417

2518
for (var i = 0; i < levels; i++) {

zk/zk-nullifier/circuits/nullifier.circom

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ template Nullifier() {
1414
nullifier === hasher.out;
1515
}
1616

17-
component main { public [verification_id, nullifier] } = Nullifier();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pragma circom 2.0.0;
2+
3+
include "./nullifier.circom";
4+
5+
component main { public [verification_id, nullifier] } = Nullifier();

zk/zk-nullifier/scripts/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ echo ""
6060

6161
# Single nullifier circuit
6262
echo -e "${BLUE}[5/9]${NC} Compiling nullifier.circom..."
63-
circom circuits/nullifier.circom \
63+
circom circuits/nullifier_main.circom \
6464
--r1cs --wasm --sym -o build
6565
echo -e "${GREEN}${NC} Single circuit compiled"
6666
echo ""

0 commit comments

Comments
 (0)