From 0d3abdb49bac98b27b14febe99f837b8673aef3b Mon Sep 17 00:00:00 2001 From: Ahmad Date: Sun, 31 Mar 2024 05:05:31 +1000 Subject: [PATCH] Update workflow and batch circuit --- .github/workflows/noir.yml | 8 ++++---- circuits/batch_smt_op/Prover.toml | 2 +- circuits/batch_smt_op/src/main.nr | 11 +++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/noir.yml b/.github/workflows/noir.yml index bb6a857..d649a5a 100644 --- a/.github/workflows/noir.yml +++ b/.github/workflows/noir.yml @@ -18,11 +18,11 @@ jobs: uses: noir-lang/noirup@v0.1.3 with: toolchain: nightly - - name: Execute single SMT OP circuit + - name: Prove single SMT OP circuit run: | cd circuits/single_smt_op - nargo execute - - name: Execute batch SMT OP circuit + nargo prove + - name: Prove batch SMT OP circuit run: | cd circuits/batch_smt_op - nargo execute + nargo prove diff --git a/circuits/batch_smt_op/Prover.toml b/circuits/batch_smt_op/Prover.toml index 0999374..e1ae334 100644 --- a/circuits/batch_smt_op/Prover.toml +++ b/circuits/batch_smt_op/Prover.toml @@ -1,4 +1,4 @@ -address = ["0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00"] +address = ["0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf","0x7e5f4552091a69125d5dfcb7b8c2659029395bdf"] new_root = "0" num_transactions = "0" op = ["0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00"] diff --git a/circuits/batch_smt_op/src/main.nr b/circuits/batch_smt_op/src/main.nr index f6e80da..9e738c5 100644 --- a/circuits/batch_smt_op/src/main.nr +++ b/circuits/batch_smt_op/src/main.nr @@ -61,12 +61,11 @@ fn main(num_transactions: pub u32, proof: [SMTProof; N for i in 0..NUM_TRANSACTIONS { - if i < num_transactions - { - assert(address_from_pubkey(signature[i].pub_key) == address[i]); // Check address - assert(check_op(op[i], address[i], op_value[i], cur_root, signature[i].msg_hash)); // Check message - cur_root = smt.compute_root(smt.process(proof[i], op[i], address[i], op_value[i], cur_root)); // Compute new root - } + let range_ind = i < num_transactions; + assert(!range_ind | (address_from_pubkey(signature[i].pub_key) == address[i])); // Check address + assert(!range_ind | check_op(op[i], address[i], op_value[i], cur_root, signature[i].msg_hash)); // Check message + + cur_root = (range_ind as Field) * smt.compute_root(smt.process(proof[i], op[i], address[i], op_value[i], (range_ind as Field) * cur_root)) + (1 - range_ind as Field) * cur_root; // Compute new root assert(signature[i].verify()); // Check signature }