mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
revert: set leaf parameter
Former-commit-id: 4d5c394f6c817a6a5a5688603ef214317c8285f6 [formerly 83cf49fbe5f15933b59ea2996a434136269f2ca7] [formerly e912d23c465248ef949d080ad1ec86b72928b182 [formerly 41feaf80ffcc9225fe0a3c3deedd56808d2afc34]] [formerly 007fe5f7131793f8b35ba617aaf3ea844c2bec77 [formerly a73eb1abe3b7d32551b9c16956000b863814917f] [formerly ce8b591636b0d4ea258ad4263728445ce072e984 [formerly 26dd0f9da9]]]
Former-commit-id: 615e7ed2c7797bf8a54a836e4a666c2cdc03dcb1 [formerly 3bccd256910dde5158b311d487ac4470dbe6bd74] [formerly 00f9e6bc56646da2ee0b73b3cfc8a418a6910021 [formerly 9b00fabafa29d530d2f31fded2de9ab573e7ca9c]]
Former-commit-id: 1f7c6c7a621559d0f005d42db603e515cd7e04bf [formerly 05fe3e2781eb683de453f90773734a0dd53c9b40]
Former-commit-id: 5755b6177bd7c058ab090429c4ae036d63df0410
This commit is contained in:
@@ -62,9 +62,15 @@ export function generateMerkleProof(
|
||||
zeroValue: StrBigInt,
|
||||
arity: number,
|
||||
leaves: StrBigInt[],
|
||||
leafIndex: number
|
||||
leaf: StrBigInt
|
||||
): MerkleProof {
|
||||
const tree = generateMerkleTree(depth, zeroValue, arity, leaves)
|
||||
|
||||
const leafIndex = leaves.indexOf(BigInt(leaf))
|
||||
|
||||
if (leafIndex === -1) {
|
||||
throw new Error("The leaf does not exists")
|
||||
}
|
||||
|
||||
return tree.createProof(leafIndex)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ describe("RLN", () => {
|
||||
const epoch: string = genExternalNullifier("test-epoch")
|
||||
const rlnIdentifier = RLN.genIdentifier()
|
||||
|
||||
const merkleProof = generateMerkleProof(15, BigInt(0), 2, leaves, leaves.length - 1)
|
||||
const merkleProof = generateMerkleProof(15, BigInt(0), 2, leaves, identityCommitment)
|
||||
const witness = RLN.genWitness(secretHash, merkleProof, epoch, signal, rlnIdentifier)
|
||||
|
||||
expect(typeof witness).toBe("object")
|
||||
@@ -61,7 +61,7 @@ describe("RLN", () => {
|
||||
const epoch = genExternalNullifier("test-epoch")
|
||||
const rlnIdentifier = RLN.genIdentifier()
|
||||
|
||||
const merkleProof = generateMerkleProof(15, BigInt(0), 2, leaves, leaves.length - 1)
|
||||
const merkleProof = generateMerkleProof(15, BigInt(0), 2, leaves, identityCommitment)
|
||||
const witness = RLN.genWitness(secretHash, merkleProof, epoch, signal, rlnIdentifier)
|
||||
|
||||
const [y, nullifier] = RLN.calculateOutput(secretHash, BigInt(epoch), rlnIdentifier, signalHash)
|
||||
|
||||
@@ -26,7 +26,7 @@ describe("Semaphore", () => {
|
||||
const leaves = [BigInt(3), BigInt(2), identityCommitment, BigInt(4)]
|
||||
const signal = "0x111"
|
||||
|
||||
const merkleProof = generateMerkleProof(20, BigInt(0), 5, leaves, 2)
|
||||
const merkleProof = generateMerkleProof(20, BigInt(0), 5, leaves, identityCommitment)
|
||||
|
||||
const witness = Semaphore.genWitness(
|
||||
identity.getTrapdoor(),
|
||||
@@ -47,7 +47,7 @@ describe("Semaphore", () => {
|
||||
const leaves = [BigInt(3), BigInt(2), identityCommitment, BigInt(4)]
|
||||
const signal = "0x111"
|
||||
|
||||
const merkleProof = generateMerkleProof(20, BigInt(0), 5, leaves, 2)
|
||||
const merkleProof = generateMerkleProof(20, BigInt(0), 5, leaves, identityCommitment)
|
||||
|
||||
const witness = Semaphore.genWitness(
|
||||
identity.getTrapdoor(),
|
||||
|
||||
Reference in New Issue
Block a user