Update to use commitment trees for anchors

This commit is contained in:
Rene Vergara 2024-05-02 12:35:36 -05:00
parent 652e95c361
commit 2d14ef6b22
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
2 changed files with 10 additions and 10 deletions

View File

@ -1647,24 +1647,24 @@ pub extern "C" fn rust_wrapper_create_transaction(
out_len: &mut usize){
let sap_wit_in: Vec<u8> = marshall_from_haskell_var(sap_wit, sap_wit_len, RW);
let sap_wit_reader = Cursor::new(sap_wit_in);
let sap_iw: Option<IncrementalWitness<Node, SAPLING_DEPTH>> = read_incremental_witness(sap_wit_reader).ok();
let sap_iw = read_commitment_tree::<Node, Cursor<Vec<u8>>, 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<u8> = marshall_from_haskell_var(orch_wit, orch_wit_len, RW);
let orch_wit_reader = Cursor::new(orch_wit_in);
let orch_iw: Option<IncrementalWitness<MerkleHashOrchard, 32>> = read_incremental_witness(orch_wit_reader).ok();
let orch_iw = read_commitment_tree::<MerkleHashOrchard, Cursor<Vec<u8>>, 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
}
};

View File

@ -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