From 2d14ef6b22664bc85d5193cdc3d5837e37bd6b2b Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 2 May 2024 12:35:36 -0500 Subject: [PATCH] Update to use commitment trees for anchors --- librustzcash-wrapper/src/lib.rs | 12 ++++++------ src/ZcashHaskell/Utils.hs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index 2291f48..6e2a5f5 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -1647,24 +1647,24 @@ pub extern "C" fn rust_wrapper_create_transaction( out_len: &mut usize){ let sap_wit_in: Vec = marshall_from_haskell_var(sap_wit, sap_wit_len, RW); let sap_wit_reader = Cursor::new(sap_wit_in); - let sap_iw: Option> = read_incremental_witness(sap_wit_reader).ok(); + let sap_iw = read_commitment_tree::>, SAPLING_DEPTH>(sap_wit_reader); let sap_anchor = match sap_iw { - Some(s_iw) => { + Ok(s_iw) => { Some(SaplingAnchor::from(s_iw.root())) }, - None => { + Err(_e) => { None } }; println!("{:?}", sap_anchor); let orch_wit_in: Vec = marshall_from_haskell_var(orch_wit, orch_wit_len, RW); let orch_wit_reader = Cursor::new(orch_wit_in); - let orch_iw: Option> = read_incremental_witness(orch_wit_reader).ok(); + let orch_iw = read_commitment_tree::>, 32>(orch_wit_reader); let orch_anchor = match orch_iw { - Some(o_iw) => { + Ok(o_iw) => { Some(OrchardAnchor::from(o_iw.root())) }, - None => { + Err(_e) => { None } }; diff --git a/src/ZcashHaskell/Utils.hs b/src/ZcashHaskell/Utils.hs index 9c87f39..db001c8 100644 --- a/src/ZcashHaskell/Utils.hs +++ b/src/ZcashHaskell/Utils.hs @@ -123,8 +123,8 @@ readZebraTransaction hex = rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex createTransaction :: - Maybe SaplingWitness -- ^ to obtain the Sapling anchor - -> Maybe OrchardWitness -- ^ to obtain the Orchard anchor + Maybe SaplingCommitmentTree -- ^ to obtain the Sapling anchor + -> Maybe OrchardCommitmentTree -- ^ to obtain the Orchard anchor -> [TransparentTxSpend] -- ^ the list of transparent notes to spend -> [SaplingTxSpend] -- ^ the list of Sapling notes to spend -> [OrchardTxSpend] -- ^ the list of Orchard notes to spend @@ -156,10 +156,10 @@ createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oPa rustWrapperCreateTx (case sapAnchor of Nothing -> "0" - Just sA -> toBytes $ sapWit sA) + Just sA -> toBytes $ sapTree sA) (case orchAnchor of Nothing -> "0" - Just oA -> toBytes $ orchWit oA) + Just oA -> toBytes $ orchTree oA) tSpend sSpend oSpend