Compare commits

..

3 commits

Author SHA1 Message Date
f6b8a77277
feat: add function to test empty trees 2024-10-30 13:23:46 -05:00
3f441e28a1
Merge branch 'milestone2' into rav001 2024-10-30 13:02:15 -05:00
6d4b6840d3
Optimize transaction creation (#98)
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/98
Co-authored-by: Rene Vergara <rene@vergara.network>
Co-committed-by: Rene Vergara <rene@vergara.network>
2024-10-30 16:47:11 +00:00
3 changed files with 24 additions and 1 deletions

View file

@ -36,7 +36,8 @@ use incrementalmerkletree::{
frontier::{ frontier::{
CommitmentTree, CommitmentTree,
Frontier, Frontier,
NonEmptyFrontier NonEmptyFrontier,
PathFiller
}, },
witness::IncrementalWitness witness::IncrementalWitness
}; };
@ -1618,6 +1619,17 @@ pub extern "C" fn rust_wrapper_combine_orchard_nodes(
} }
} }
#[no_mangle]
pub extern "C" fn rust_wrapper_get_orchard_root(
level: u8,
out: *mut u8,
out_len: &mut usize
){
let tree: CommitmentTree<MerkleHashOrchard, 32> = CommitmentTree::empty();
let root = tree.root_at_depth(level, PathFiller::empty());
let h = Hhex { bytes: root.to_bytes().to_vec() };
marshall_to_haskell_var(&h, out, out_len, RW);
}
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_wrapper_read_orchard_commitment_tree( pub extern "C" fn rust_wrapper_read_orchard_commitment_tree(

View file

@ -276,6 +276,13 @@ import ZcashHaskell.Types
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_get_orchard_root as rustWrapperGetOrchardRootTest
{ `Int8'
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_commitment_tree as rustWrapperReadOrchardCommitmentTree {# fun unsafe rust_wrapper_read_orchard_commitment_tree as rustWrapperReadOrchardCommitmentTree
{ toBorshVar* `OrchardFrontier'& { toBorshVar* `OrchardFrontier'&
, toBorshVar* `BS.ByteString'& , toBorshVar* `BS.ByteString'&

View file

@ -218,6 +218,10 @@ getOrchardWitnessAnchor wit =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperReadOrchardWitnessAnchor $ toBytes $ orchWit wit rustWrapperReadOrchardWitnessAnchor $ toBytes $ orchWit wit
getOrchardRootTest :: Int -> HexString
getOrchardRootTest level =
withPureBorshVarBuffer $ rustWrapperGetOrchardRootTest $ fromIntegral level
-- | Update a Orchard commitment tree -- | Update a Orchard commitment tree
updateOrchardCommitmentTree :: updateOrchardCommitmentTree ::
OrchardFrontier -- ^ the base tree OrchardFrontier -- ^ the base tree