feat: use SaplingFrontier
for witnesses
This commit is contained in:
parent
3203c7e8ff
commit
96cfe3a52a
3 changed files with 7 additions and 8 deletions
|
@ -1445,9 +1445,10 @@ pub extern "C" fn rust_wrapper_read_sapling_witness(
|
|||
out: *mut u8,
|
||||
out_len: &mut usize
|
||||
){
|
||||
let tree_in: Vec<u8> = marshall_from_haskell_var(tree, tree_len, RW);
|
||||
let tree_reader = Cursor::new(tree_in);
|
||||
let ct: CommitmentTree<Node, SAPLING_DEPTH> = read_commitment_tree(tree_reader).unwrap();
|
||||
let tree_in: Hfrontier = marshall_from_haskell_var(tree, tree_len, RW);
|
||||
let leaf = Node::from_bytes(to_array(tree_in.leaf.bytes)).unwrap();
|
||||
let frontier: Frontier<Node, SAPLING_DEPTH> = Frontier::from_parts(Position::from(tree_in.position), leaf, tree_in.ommers.iter().map(|x| Node::from_bytes(to_array(x.clone())).unwrap() ).collect()).unwrap();
|
||||
let ct: CommitmentTree<Node, SAPLING_DEPTH> = CommitmentTree::from_frontier(&frontier);
|
||||
let inc_wit = IncrementalWitness::from_tree(ct);
|
||||
let mut out_bytes: Vec<u8> = Vec::new();
|
||||
let result = write_incremental_witness(&inc_wit, &mut out_bytes);
|
||||
|
|
|
@ -212,7 +212,7 @@ import ZcashHaskell.Types
|
|||
#}
|
||||
|
||||
{# fun unsafe rust_wrapper_read_sapling_witness as rustWrapperReadSaplingWitness
|
||||
{ toBorshVar* `BS.ByteString'&
|
||||
{ toBorshVar* `SaplingFrontier'&
|
||||
, getVarBuffer `Buffer HexString'&
|
||||
}
|
||||
-> `()'
|
||||
|
|
|
@ -210,15 +210,13 @@ updateSaplingCommitmentTree tree cmu =
|
|||
rustWrapperReadSaplingCommitmentTree tree (hexBytes cmu)
|
||||
|
||||
-- | Get the Sapling incremental witness from a commitment tree
|
||||
getSaplingWitness :: SaplingCommitmentTree -> Maybe SaplingWitness
|
||||
getSaplingWitness :: SaplingFrontier -> Maybe SaplingWitness
|
||||
getSaplingWitness tree =
|
||||
if BS.length (hexBytes wit) > 1
|
||||
then Just $ SaplingWitness wit
|
||||
else Nothing
|
||||
where
|
||||
wit =
|
||||
withPureBorshVarBuffer $
|
||||
rustWrapperReadSaplingWitness (hexBytes $ sapTree tree)
|
||||
wit = withPureBorshVarBuffer $ rustWrapperReadSaplingWitness tree
|
||||
|
||||
-- | Get the Sapling note position from a witness
|
||||
getSaplingNotePosition :: SaplingWitness -> Integer
|
||||
|
|
Loading…
Reference in a new issue