From 957f2aec768ac9bd22139fa86330c6c8afdf9e5e Mon Sep 17 00:00:00 2001 From: josh crites Date: Fri, 10 May 2024 13:34:39 -0400 Subject: [PATCH] update --- foundry-voting/.gitignore | 5 ++++- foundry-voting/README.md | 22 +++++++++++----------- foundry-voting/test/zkVote.t.sol | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/foundry-voting/.gitignore b/foundry-voting/.gitignore index e7f2f2b..b6b2f4c 100644 --- a/foundry-voting/.gitignore +++ b/foundry-voting/.gitignore @@ -14,4 +14,7 @@ docs/ .env node_modules -crs \ No newline at end of file +crs + +circuits/contract +circuits/proofs diff --git a/foundry-voting/README.md b/foundry-voting/README.md index e519702..ac406dd 100644 --- a/foundry-voting/README.md +++ b/foundry-voting/README.md @@ -4,10 +4,10 @@ This example project shows how to create a simple zk voting circuit in Noir with a corresponding Solidity contract to track eligible voters, proposals and votes. -This example was last tested with Noir version 0.22.0. You can install it with [noirup](https://noir-lang.org/docs/getting_started/installation/#installing-noirup) using +This example was last tested with Noir version 0.28.0. You can install it with [noirup](https://noir-lang.org/docs/getting_started/installation/#installing-noirup) using ```bash -noirup -v 0.22.0 +noirup -v 0.28.0 ``` ## Overview @@ -16,14 +16,14 @@ This is the model used for creating the [circuit](circuits/src/main.nr) and the 1. Create a set of voters. A merkle root is stored in the zkVote Solidity contract that voters will use to verify membership against. In this example, there are 4 accounts in the set of voters. The private keys are 0, 1, 2, 3 and the secret value to create the commitment is 9. -| Secret | Commitment = pedersen(secret) | -| ------ | ------------------------------------------------------------------ | -| 1 | 0x09489945604c9686e698cb69d7bd6fc0cdb02e9faae3e1a433f1c342c1a5ecc4 | -| 2 | 0x2d961d9814298c04a4639a56c5c95030d704340ab6d13c135a326da5e515559d | -| 3 | 0x0a1d1f62bdd17dbdd447feccd23471821e7e43f1ce9165f636513b83a9933474 | -| 4 | 0x273e0772e851cd0d83d77f05f334d156bc53194e42e8680c6d9469b3aa887eb1 | +| Private Key | Commitment = pedersen(private key, secret) | +| ----------- | ------------------------------------------------------------------ | +| 1 | 0x03542cb720369f19a74fd05b4edfbedb27a78514ad3283f1b3270a1656cced8e | +| 2 | 0x1efa9d6bb4dfdf86063cc77efdec90eb9262079230f1898049efad264835b6c8 | +| 3 | 0x24013340c052ebf847e0d7081f84e6a8e92f54e2e1726a1e559ac46a8f242007 | +| 4 | 0x04fd3da9756f25c72ca8990437b7f7b58e7ca48bfc21e65e7978320db8b1e5c5 | -This gives intermediate hashes of `0x083ed6aeca136c6159a761749f6db0c192bacf04294e22ed968ae1a845f97285` (`pedersen(commitment0, commitment1)`) and `0x1501e80783ee5c988327f46f5fcdce388cb97aa7e959ad345c1e2cbaa0b42b83` (`pedersen(commitment2, commitment3)`) and a root hash of `0x29fd5ee89e33f559a7b32ac39f57400aa5a6c77492e28c088f9eb511b0c73e78`. +This gives intermediate hashes of `0x046394ae1ebbf494f2cd2c2d37171099510d099489c9accef59f90512d5f0477` (`pedersen(commitment0, commitment1)`) and `0x2a653551d87767c545a2a11b29f0581a392b4e177a87c8e3eb425c51a26a8c77` (`pedersen(commitment2, commitment3)`) and a root hash of `0x215597bacd9c7e977dfc170f320074155de974be494579d2586e5b268fa3b629`. 2. Users will input their information into the circuit and generate a proof (see example inputs in [Prover.toml](./circuits/Prover.toml) and run `nargo prove` to generate the proof.) 1. Public inputs and outputs are printed in [Verifier.toml](./circuits/Verifier.toml). @@ -38,8 +38,8 @@ See the test file [here](./test/zkVote.t.sol). Run tests with `forge test`. 1. Run `nargo compile` to compile the circuit. 2. Run `nargo prove` to generate the proof (with the inputs in Prover.toml). -3. Run `yarn test` to run the Foundry test the Solidity verifier contract at `./test/zkVote.t.sol`. -4. Run `yarn integration-test` to run Javascript tests (at `./test/integration.test.ts`) using [bb.js](https://www.npmjs.com/package/@aztec/bb.js). +3. Run `nargo codegen-verifier` to generate the solidity verifier contract. +4. Run `yarn test` to run the Foundry test the Solidity verifier contract at `./test/zkVote.t.sol`. ## Development diff --git a/foundry-voting/test/zkVote.t.sol b/foundry-voting/test/zkVote.t.sol index a5d92b1..383e2b8 100644 --- a/foundry-voting/test/zkVote.t.sol +++ b/foundry-voting/test/zkVote.t.sol @@ -42,7 +42,7 @@ contract VotingTest is Test { } function test_invalidProof() public { - vm.expectRevert(BaseUltraVerifier.EC_SCALAR_MUL_FAILURE.selector); + vm.expectRevert(); voteContract.castVote(hex"12", 0, 1, nullifierHash); } @@ -54,7 +54,7 @@ contract VotingTest is Test { } function test_changedVote() public { - vm.expectRevert(BaseUltraVerifier.PROOF_FAILURE.selector); + vm.expectRevert(); voteContract.castVote(proofBytes, 0, 0, nullifierHash); }