From 1374af3c3565e13eee15b93b1d1a9107c87325a8 Mon Sep 17 00:00:00 2001 From: bdim1 Date: Tue, 22 Feb 2022 18:47:05 +0100 Subject: [PATCH 1/2] fix: tests Former-commit-id: fa083e6a6fcfd9eab7d9b0ccb5b3cad948eafadb [formerly 2a8e52ecbcb13208b972bdd607b1268ae429eb4e] [formerly e1978b8b5641c1805af97b55b918764a5c555d1f [formerly dcca7e586c1e0b1695434b7af60938d600d69066]] [formerly 06668f41dde43e5d6103737576488988b6d91849 [formerly 297cb89efd6324a00b7e777aab7b47f31d40432b] [formerly 7c924e342dad9a01e3f824226d500ded73183f6b [formerly ea7fbd9fbf5881965ac93318ef138b6943018975]]] Former-commit-id: 70c61292ade983375bfa0ee19c1938dbb53e16a0 [formerly 4a90d9c8fb6f86d3a90e3d8b1b46169b365e6739] [formerly 6b05ff88bde052827f72d8641b6ec5f0ef9204f4 [formerly 61761542c6fd08f3d4e583bf7e21059438e3a081]] Former-commit-id: f34aa061c99b1c5b0d9dc28be320c35a286fb004 [formerly b5a480ef022142ddd2cc4beff6c9dbd0007fef6e] Former-commit-id: e38f5e5148156af408d5635ae9cd66a22686942e --- packages/protocols/tests/rln.test.ts | 16 ++-------------- packages/protocols/tests/semaphore.test.ts | 15 +++------------ 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/packages/protocols/tests/rln.test.ts b/packages/protocols/tests/rln.test.ts index e96ec1d..590dfea 100644 --- a/packages/protocols/tests/rln.test.ts +++ b/packages/protocols/tests/rln.test.ts @@ -4,7 +4,6 @@ import * as fs from "fs" import * as path from "path" import { RLN } from "../src" import { generateMerkleProof, genExternalNullifier, genSignalHash } from "../src/utils" -import { RLNPublicSignals } from "../src/types" describe("RLN", () => { const zkeyFiles = "./packages/protocols/zkeyFiles" @@ -79,7 +78,7 @@ describe("RLN", () => { }) // eslint-disable-next-line jest/no-disabled-tests - it.skip("Should generate rln proof and verify it", async () => { + it("Should generate rln proof and verify it", async () => { const identity = new ZkIdentity() const secretHash = identity.getSecretHash() const identityCommitment = identity.genIdentityCommitment() @@ -88,23 +87,12 @@ describe("RLN", () => { leaves.push(identityCommitment) const signal = "hey hey" - const signalHash = genSignalHash(signal) const epoch = genExternalNullifier("test-epoch") const rlnIdentifier = RLN.genIdentifier() 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) - - const publicSignals: RLNPublicSignals = { - yShare: y, - merkleRoot: merkleProof.root, - internalNullifier: nullifier, - signalHash, - epoch, - rlnIdentifier - } const vkeyPath = path.join(zkeyFiles, "rln", "verification_key.json") const vKey = JSON.parse(fs.readFileSync(vkeyPath, "utf-8")) @@ -113,7 +101,7 @@ describe("RLN", () => { const finalZkeyPath = path.join(zkeyFiles, "rln", "rln_final.zkey") const fullProof = await RLN.genProof(witness, wasmFilePath, finalZkeyPath) - const response = await RLN.verifyProof(vKey, { proof: fullProof.proof, publicSignals }) + const response = await RLN.verifyProof(vKey, fullProof ) expect(response).toBe(true) }, 30000) diff --git a/packages/protocols/tests/semaphore.test.ts b/packages/protocols/tests/semaphore.test.ts index 2b9f93e..af3e36b 100644 --- a/packages/protocols/tests/semaphore.test.ts +++ b/packages/protocols/tests/semaphore.test.ts @@ -3,8 +3,7 @@ import { getCurveFromName } from "ffjavascript" import fs from "fs" import path from "path" import { Semaphore } from "../src" -import { SemaphorePublicSignals } from "../src/types" -import { generateMerkleProof, genExternalNullifier, genSignalHash } from "../src/utils" +import { generateMerkleProof, genExternalNullifier } from "../src/utils" describe("Semaphore", () => { const zkeyFiles = "./packages/protocols/zkeyFiles" @@ -41,7 +40,7 @@ describe("Semaphore", () => { }) // eslint-disable-next-line jest/no-disabled-tests - it.skip("Should generate Semaphore full proof", async () => { + it("Should generate Semaphore full proof", async () => { const identity = new ZkIdentity() const identityCommitment = identity.genIdentityCommitment() const externalNullifier = genExternalNullifier("voting_1") @@ -64,16 +63,8 @@ describe("Semaphore", () => { const vkeyPath = path.join("./packages/protocols/zkeyFiles", "semaphore", "verification_key.json") const vKey = JSON.parse(fs.readFileSync(vkeyPath, "utf-8")) - const nullifierHash = Semaphore.genNullifierHash(externalNullifier, identity.getNullifier()) - const publicSignals: SemaphorePublicSignals = { - merkleRoot: merkleProof.root.toString(), - nullifierHash, - signalHash: genSignalHash(signal), - externalNullifier - } - - const response = await Semaphore.verifyProof(vKey, { proof: fullProof.proof, publicSignals }) + const response = await Semaphore.verifyProof(vKey, fullProof) expect(response).toBe(true) }, 30000) From 41418a42eedf316eb7e1deaabbfcd47b265fd285 Mon Sep 17 00:00:00 2001 From: bdim1 Date: Tue, 22 Feb 2022 18:49:05 +0100 Subject: [PATCH 2/2] fix: skip Former-commit-id: 8c0eff82bb1d543bfbc661a1c7555354cb8d5be5 [formerly 017ac827194d5d01f9af959739aa63ae3c559692] [formerly 68f6c7906ec269b74d8a5528e7b19fac6cd06e68 [formerly 5dde3b7944abee0ac5455cf281049f6179ac5145]] [formerly 100d2033b7ceb87a6566890127f7869bc75cbd59 [formerly 7e757c2cbf1cd58a5fd670d7a7c61531e0c797cd] [formerly f8d7e0ab82af16a4dae692288f7b9979face2bf8 [formerly 925dc525ae57fe430329f2787d64ff38b645a314]]] Former-commit-id: dcf54d96430f94ee7b5810422d2e734cce1e027d [formerly 4d3d273caa6a620291659e47c4b9530d86d62b9d] [formerly f58753d33ed9f2a85ca9c5a7b2f92adcee4453bb [formerly 105d7d03ffdd11ee65e74196bd473fa938676b0b]] Former-commit-id: 9cffd34724c31063d2acfb4a27cde92df8b7ea07 [formerly c8e8637e621d9daf71c508af0655a5c3dea63f49] Former-commit-id: e541add3f75f0a6ad382e7c0e4a7b17aafcf5361 --- packages/protocols/tests/rln.test.ts | 2 +- packages/protocols/tests/semaphore.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocols/tests/rln.test.ts b/packages/protocols/tests/rln.test.ts index 590dfea..bbc393d 100644 --- a/packages/protocols/tests/rln.test.ts +++ b/packages/protocols/tests/rln.test.ts @@ -78,7 +78,7 @@ describe("RLN", () => { }) // eslint-disable-next-line jest/no-disabled-tests - it("Should generate rln proof and verify it", async () => { + it.skip("Should generate and verify RLN proof", async () => { const identity = new ZkIdentity() const secretHash = identity.getSecretHash() const identityCommitment = identity.genIdentityCommitment() diff --git a/packages/protocols/tests/semaphore.test.ts b/packages/protocols/tests/semaphore.test.ts index af3e36b..a7b20ce 100644 --- a/packages/protocols/tests/semaphore.test.ts +++ b/packages/protocols/tests/semaphore.test.ts @@ -40,7 +40,7 @@ describe("Semaphore", () => { }) // eslint-disable-next-line jest/no-disabled-tests - it("Should generate Semaphore full proof", async () => { + it.skip("Should generate and verify Semaphore proof", async () => { const identity = new ZkIdentity() const identityCommitment = identity.genIdentityCommitment() const externalNullifier = genExternalNullifier("voting_1")