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: *mut u8,
|
||||||
out_len: &mut usize
|
out_len: &mut usize
|
||||||
){
|
){
|
||||||
let tree_in: Vec<u8> = marshall_from_haskell_var(tree, tree_len, RW);
|
let tree_in: Hfrontier = marshall_from_haskell_var(tree, tree_len, RW);
|
||||||
let tree_reader = Cursor::new(tree_in);
|
let leaf = Node::from_bytes(to_array(tree_in.leaf.bytes)).unwrap();
|
||||||
let ct: CommitmentTree<Node, SAPLING_DEPTH> = read_commitment_tree(tree_reader).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 inc_wit = IncrementalWitness::from_tree(ct);
|
||||||
let mut out_bytes: Vec<u8> = Vec::new();
|
let mut out_bytes: Vec<u8> = Vec::new();
|
||||||
let result = write_incremental_witness(&inc_wit, &mut out_bytes);
|
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
|
{# fun unsafe rust_wrapper_read_sapling_witness as rustWrapperReadSaplingWitness
|
||||||
{ toBorshVar* `BS.ByteString'&
|
{ toBorshVar* `SaplingFrontier'&
|
||||||
, getVarBuffer `Buffer HexString'&
|
, getVarBuffer `Buffer HexString'&
|
||||||
}
|
}
|
||||||
-> `()'
|
-> `()'
|
||||||
|
|
|
@ -210,15 +210,13 @@ updateSaplingCommitmentTree tree cmu =
|
||||||
rustWrapperReadSaplingCommitmentTree tree (hexBytes cmu)
|
rustWrapperReadSaplingCommitmentTree tree (hexBytes cmu)
|
||||||
|
|
||||||
-- | Get the Sapling incremental witness from a commitment tree
|
-- | Get the Sapling incremental witness from a commitment tree
|
||||||
getSaplingWitness :: SaplingCommitmentTree -> Maybe SaplingWitness
|
getSaplingWitness :: SaplingFrontier -> Maybe SaplingWitness
|
||||||
getSaplingWitness tree =
|
getSaplingWitness tree =
|
||||||
if BS.length (hexBytes wit) > 1
|
if BS.length (hexBytes wit) > 1
|
||||||
then Just $ SaplingWitness wit
|
then Just $ SaplingWitness wit
|
||||||
else Nothing
|
else Nothing
|
||||||
where
|
where
|
||||||
wit =
|
wit = withPureBorshVarBuffer $ rustWrapperReadSaplingWitness tree
|
||||||
withPureBorshVarBuffer $
|
|
||||||
rustWrapperReadSaplingWitness (hexBytes $ sapTree tree)
|
|
||||||
|
|
||||||
-- | Get the Sapling note position from a witness
|
-- | Get the Sapling note position from a witness
|
||||||
getSaplingNotePosition :: SaplingWitness -> Integer
|
getSaplingNotePosition :: SaplingWitness -> Integer
|
||||||
|
|
Loading…
Reference in a new issue