Skip to content

Commit f3f3688

Browse files
authored
test(circuits): add test using the identity library (#785)
There is a new test using the Semaphore Identity package to test compatibility between the Identity library and the circuit. re #484
1 parent 0fa785b commit f3f3688

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/circuits/tests/semaphore.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Group } from "@semaphore-protocol/core"
1+
import { Group, Identity } from "@semaphore-protocol/core"
22
import { Base8, mulPointEscalar } from "@zk-kit/baby-jubjub"
33
import { WitnessTester } from "circomkit"
44
import { poseidon2 } from "poseidon-lite"
@@ -94,4 +94,28 @@ describe("semaphore", () => {
9494

9595
await circuit.expectFail(INPUT)
9696
})
97+
98+
it("Should calculate the root and the nullifier correctly using the Semaphore Identity library", async () => {
99+
const { commitment, secretScalar: secret } = new Identity()
100+
101+
const group = new Group([commitment, 2n, 3n])
102+
103+
const { merkleProofSiblings, merkleProofIndices } = generateMerkleProof(group, 0, MAX_DEPTH)
104+
105+
const INPUT = {
106+
secret,
107+
merkleProofLength: group.depth,
108+
merkleProofIndices,
109+
merkleProofSiblings,
110+
scope,
111+
message
112+
}
113+
114+
const OUTPUT = {
115+
nullifier: poseidon2([scope, secret]),
116+
merkleRoot: group.root
117+
}
118+
119+
await circuit.expectPass(INPUT, OUTPUT)
120+
})
97121
})

0 commit comments

Comments
 (0)