Add Sapling nullifier calculation to decoding
This commit is contained in:
parent
0f19e376dc
commit
6a2849aae0
3 changed files with 21 additions and 16 deletions
|
@ -240,7 +240,8 @@ impl Haction {
|
|||
pub struct Hnote {
|
||||
note: u64,
|
||||
recipient: Vec<u8>,
|
||||
memo: Vec<u8>
|
||||
memo: Vec<u8>,
|
||||
nullifier: Vec<u8>
|
||||
}
|
||||
|
||||
impl<RW> ToHaskell<RW> for Hnote {
|
||||
|
@ -732,6 +733,7 @@ pub extern "C" fn rust_wrapper_sapling_esk_decrypt(
|
|||
note_len: usize,
|
||||
external: bool,
|
||||
net: bool,
|
||||
pos: u64,
|
||||
out: *mut u8,
|
||||
out_len: &mut usize
|
||||
){
|
||||
|
@ -759,24 +761,24 @@ pub extern "C" fn rust_wrapper_sapling_esk_decrypt(
|
|||
else {zcash_note_encryption::try_note_decryption(&test_domain, &pivk, &action2)};
|
||||
match result {
|
||||
Some((n, r, m)) => {
|
||||
//let nullifier = n.nf(&nk, MerklePath<Node::from_cmu(&n.cmu()), SAPLING_DEPTH>.position());
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_bytes().to_vec(), memo: m.as_slice().to_vec() };
|
||||
let nullifier = n.nf(&nk, pos);
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_bytes().to_vec(), memo: m.as_slice().to_vec(), nullifier: nullifier.to_vec() };
|
||||
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||
},
|
||||
None => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(_e1) => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0] };
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0] };
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(_e) => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0] };
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0] };
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
|
@ -806,23 +808,23 @@ pub extern "C" fn rust_wrapper_sapling_note_decrypt_v2(
|
|||
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action3);
|
||||
match result {
|
||||
Some((n, r, m)) => {
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_bytes().to_vec(), memo: m.as_slice().to_vec()};
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_bytes().to_vec(), memo: m.as_slice().to_vec(), nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||
}
|
||||
None => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(_e1) => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0] };
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0] , nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_e) => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
|
@ -856,17 +858,17 @@ pub extern "C" fn rust_wrapper_orchard_note_decrypt(
|
|||
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action);
|
||||
match result {
|
||||
Some((n, r, m)) => {
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_raw_address_bytes().to_vec(), memo: m.to_vec()};
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_raw_address_bytes().to_vec(), memo: m.to_vec(), nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||
}
|
||||
None => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
|
@ -904,11 +906,11 @@ pub extern "C" fn rust_wrapper_orchard_note_decrypt_sk(
|
|||
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action);
|
||||
match result {
|
||||
Some((n, r, m)) => {
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_raw_address_bytes().to_vec(), memo: m.to_vec()};
|
||||
let hn = Hnote {note: n.value().inner(), recipient: r.to_raw_address_bytes().to_vec(), memo: m.to_vec(), nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||
}
|
||||
None => {
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0]};
|
||||
let hn0 = Hnote { note: 0, recipient: vec![0], memo: vec![0], nullifier: vec![0]};
|
||||
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ import ZcashHaskell.Types
|
|||
, toBorshVar* `BS.ByteString'&
|
||||
, `Bool'
|
||||
, `Bool'
|
||||
, `Word64'
|
||||
, getVarBuffer `Buffer DecodedNote'&
|
||||
}
|
||||
-> `()'
|
||||
|
|
|
@ -121,8 +121,9 @@ decodeSaplingOutputEsk ::
|
|||
-> ShieldedOutput
|
||||
-> ZcashNet
|
||||
-> Scope
|
||||
-> Integer
|
||||
-> Maybe DecodedNote
|
||||
decodeSaplingOutputEsk key out znet scope =
|
||||
decodeSaplingOutputEsk key out znet scope pos =
|
||||
case a_value decodedAction of
|
||||
0 -> Nothing
|
||||
_ -> Just decodedAction
|
||||
|
@ -134,6 +135,7 @@ decodeSaplingOutputEsk key out znet scope =
|
|||
(serializeShieldedOutput out)
|
||||
(znet == MainNet)
|
||||
(scope == External)
|
||||
(fromIntegral pos)
|
||||
|
||||
-- | Attempts to obtain a sapling SpendingKey using a HDSeed
|
||||
genSaplingSpendingKey :: Seed -> CoinType -> Int -> Maybe SaplingSpendingKey
|
||||
|
|
Loading…
Reference in a new issue