mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-04-28 03:00:41 -04:00
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
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Group } from "@semaphore-protocol/core"
|
||||
import { Group, Identity } from "@semaphore-protocol/core"
|
||||
import { Base8, mulPointEscalar } from "@zk-kit/baby-jubjub"
|
||||
import { WitnessTester } from "circomkit"
|
||||
import { poseidon2 } from "poseidon-lite"
|
||||
@@ -94,4 +94,28 @@ describe("semaphore", () => {
|
||||
|
||||
await circuit.expectFail(INPUT)
|
||||
})
|
||||
|
||||
it("Should calculate the root and the nullifier correctly using the Semaphore Identity library", async () => {
|
||||
const { commitment, secretScalar: secret } = new Identity()
|
||||
|
||||
const group = new Group([commitment, 2n, 3n])
|
||||
|
||||
const { merkleProofSiblings, merkleProofIndices } = generateMerkleProof(group, 0, MAX_DEPTH)
|
||||
|
||||
const INPUT = {
|
||||
secret,
|
||||
merkleProofLength: group.depth,
|
||||
merkleProofIndices,
|
||||
merkleProofSiblings,
|
||||
scope,
|
||||
message
|
||||
}
|
||||
|
||||
const OUTPUT = {
|
||||
nullifier: poseidon2([scope, secret]),
|
||||
merkleRoot: group.root
|
||||
}
|
||||
|
||||
await circuit.expectPass(INPUT, OUTPUT)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user