From f8a62fe7c9f0711244d0148b090807d52f392148 Mon Sep 17 00:00:00 2001 From: David Rusu Date: Fri, 6 Dec 2024 15:12:36 +0400 Subject: [PATCH] update ptx proof to use MMR's --- emmarin/cl/ledger_proof_statements/src/ptx.rs | 2 +- emmarin/cl/risc0_proofs/ptx/src/main.rs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/emmarin/cl/ledger_proof_statements/src/ptx.rs b/emmarin/cl/ledger_proof_statements/src/ptx.rs index 5f63f46..6f25761 100644 --- a/emmarin/cl/ledger_proof_statements/src/ptx.rs +++ b/emmarin/cl/ledger_proof_statements/src/ptx.rs @@ -13,6 +13,6 @@ pub struct PtxPublic { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct PtxPrivate { pub ptx: PartialTxWitness, - pub input_cm_paths: Vec, + pub input_cm_proofs: Vec, pub cm_mmr: MMR, } diff --git a/emmarin/cl/risc0_proofs/ptx/src/main.rs b/emmarin/cl/risc0_proofs/ptx/src/main.rs index 7b03f68..2ab181a 100644 --- a/emmarin/cl/risc0_proofs/ptx/src/main.rs +++ b/emmarin/cl/risc0_proofs/ptx/src/main.rs @@ -1,20 +1,18 @@ /// Input Proof -use cl::cl::merkle; use ledger_proof_statements::ptx::{PtxPrivate, PtxPublic}; use risc0_zkvm::guest::env; fn main() { let PtxPrivate { ptx, - input_cm_paths, - cm_roots, + input_cm_proofs, + cm_mmr, } = env::read(); - assert_eq!(ptx.inputs.len(), input_cm_paths.len()); - for ((input, cm_path), cm_root) in ptx.inputs.iter().zip(input_cm_paths).zip(&cm_roots) { + assert_eq!(ptx.inputs.len(), input_cm_proofs.len()); + for (input, cm_mmr_proof) in ptx.inputs.iter().zip(input_cm_proofs) { let note_cm = input.note_commitment(); - let cm_leaf = merkle::leaf(note_cm.as_bytes()); - assert_eq!(*cm_root, merkle::path_root(cm_leaf, &cm_path)); + assert!(cm_mmr.verify_proof(¬e_cm.0, &cm_mmr_proof)); } for output in ptx.outputs.iter() { @@ -23,6 +21,6 @@ fn main() { env::commit(&PtxPublic { ptx: ptx.commit(), - cm_roots, + cm_mmr, }); }