From ff0afeebd7ed163cf7ea59e43bbe3dcc9da2ed40 Mon Sep 17 00:00:00 2001 From: Giacomo Pasini <21265557+zeegomo@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:12:10 +0200 Subject: [PATCH] Provide state roots instead of whole state (#33) --- goas/atomic_asset_transfer/executor/src/lib.rs | 2 +- .../proof_statements/src/zone_funds.rs | 4 ++-- .../risc0_proofs/spend_zone_funds/src/main.rs | 9 +++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/goas/atomic_asset_transfer/executor/src/lib.rs b/goas/atomic_asset_transfer/executor/src/lib.rs index 7e4937f..e129eb7 100644 --- a/goas/atomic_asset_transfer/executor/src/lib.rs +++ b/goas/atomic_asset_transfer/executor/src/lib.rs @@ -165,7 +165,7 @@ pub fn prove_zone_fund_constraint( let private_inputs = SpendFundsPrivate { in_zone_funds, zone_note, - state_witness: out_zone_state.clone(), + state_roots: out_zone_state.state_roots(), }; let env = risc0_zkvm::ExecutorEnv::builder() diff --git a/goas/atomic_asset_transfer/proof_statements/src/zone_funds.rs b/goas/atomic_asset_transfer/proof_statements/src/zone_funds.rs index a78da34..48f236b 100644 --- a/goas/atomic_asset_transfer/proof_statements/src/zone_funds.rs +++ b/goas/atomic_asset_transfer/proof_statements/src/zone_funds.rs @@ -6,6 +6,6 @@ pub struct SpendFundsPrivate { pub in_zone_funds: cl::PartialTxInputWitness, /// The zone note that is authorizing the spend pub zone_note: cl::PartialTxOutputWitness, - /// The state of the zone - pub state_witness: common::StateWitness, + /// Proof of identity of the above note + pub state_roots: common::StateRoots, } diff --git a/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs b/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs index a34e90f..8b2abc1 100644 --- a/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs +++ b/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs @@ -11,7 +11,7 @@ fn main() { let SpendFundsPrivate { in_zone_funds, zone_note, - state_witness, + state_roots, } = env::read(); let input_root = in_zone_funds.input_root(); @@ -20,11 +20,8 @@ fn main() { let ptx_root = PtxRoot(merkle::node(input_root, output_root)); // 1) Check the zone note is the correct one - assert_eq!( - in_zone_funds.input.note.state, - state_witness.zone_metadata.id() - ); - assert_eq!(zone_note.output.note.state, state_witness.commit().0); + assert_eq!(in_zone_funds.input.note.state, state_roots.zone_id); + assert_eq!(zone_note.output.note.state, state_roots.commit().0); let nf = in_zone_funds.input.nullifier();