Compare commits

...

4 commits

Author SHA1 Message Date
ef8dba474e
feat: add sapling node creation 2024-11-05 14:35:19 -06:00
b68ee96583
Merge branch 'milestone2' into rav001 2024-11-05 12:43:22 -06:00
62cda9cc15
docs: version bump 2024-11-05 12:42:03 -06:00
5ce149c54f
Functions to create and manage Orchard commitment trees (#99)
This PR contains the functions to create, update and validate Orchard commitment trees.

Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/99
Co-authored-by: Rene Vergara <rene@vergara.network>
Co-committed-by: Rene Vergara <rene@vergara.network>
2024-11-05 18:28:45 +00:00
5 changed files with 42 additions and 1 deletions

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.7.4.0]
### Added
- `MerklePath`
## [0.7.3.0] ## [0.7.3.0]
### Added ### Added

View file

@ -1542,6 +1542,25 @@ pub extern "C" fn rust_wrapper_update_sapling_witness(
} }
} }
#[no_mangle]
pub extern "C" fn rust_wrapper_read_sapling_node(
cmu: *const u8,
cmu_len: usize,
out: *mut u8,
out_len: &mut usize
){
let node_in: Vec<u8> = marshall_from_haskell_var(cmu, cmu_len, RW);
let sapling_note_comm = SaplingNoteCommitment::from_bytes(&to_array(node_in));
if sapling_note_comm.is_some().into() {
let n = Node::from_cmu(&sapling_note_comm.unwrap());
let h = Hhex { bytes: n.to_bytes().to_vec()};
marshall_to_haskell_var(&h, out, out_len, RW);
} else {
let h0 = Hhex { bytes: vec![0] };
marshall_to_haskell_var(&h0, out, out_len, RW);
}
}
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_wrapper_read_orchard_frontier( pub extern "C" fn rust_wrapper_read_orchard_frontier(
tree: *const u8, tree: *const u8,

View file

@ -246,6 +246,13 @@ import ZcashHaskell.Types
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_read_sapling_node as rustWrapperReadSaplingNode
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_node as rustWrapperReadOrchardNode {# fun unsafe rust_wrapper_read_orchard_node as rustWrapperReadOrchardNode
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'& , getVarBuffer `Buffer HexString'&

View file

@ -22,6 +22,7 @@ import C.Zcash
, rustWrapperIsShielded , rustWrapperIsShielded
, rustWrapperReadSaplingCommitmentTree , rustWrapperReadSaplingCommitmentTree
, rustWrapperReadSaplingFrontier , rustWrapperReadSaplingFrontier
, rustWrapperReadSaplingNode
, rustWrapperReadSaplingPosition , rustWrapperReadSaplingPosition
, rustWrapperReadSaplingWitness , rustWrapperReadSaplingWitness
, rustWrapperSaplingCheck , rustWrapperSaplingCheck
@ -185,6 +186,14 @@ genSaplingInternalAddress sk =
res = res =
withPureBorshVarBuffer (rustWrapperSaplingChgPaymentAddress $ getBytes sk) withPureBorshVarBuffer (rustWrapperSaplingChgPaymentAddress $ getBytes sk)
getSaplingNodeValue :: BS.ByteString -> Maybe HexString
getSaplingNodeValue cmu =
if BS.length (hexBytes n) > 1
then Just n
else Nothing
where
n = withPureBorshVarBuffer $ rustWrapperReadSaplingNode cmu
getSaplingFrontier :: SaplingCommitmentTree -> Maybe SaplingFrontier getSaplingFrontier :: SaplingCommitmentTree -> Maybe SaplingFrontier
getSaplingFrontier tree = getSaplingFrontier tree =
if sf_pos updatedTree > 1 if sf_pos updatedTree > 1

View file

@ -5,7 +5,7 @@ cabal-version: 3.0
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: zcash-haskell name: zcash-haskell
version: 0.7.3.0 version: 0.7.4.0
synopsis: Utilities to interact with the Zcash blockchain synopsis: Utilities to interact with the Zcash blockchain
description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme> description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme>
category: Blockchain category: Blockchain