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 {
|
pub struct Hnote {
|
||||||
note: u64,
|
note: u64,
|
||||||
recipient: Vec<u8>,
|
recipient: Vec<u8>,
|
||||||
memo: Vec<u8>
|
memo: Vec<u8>,
|
||||||
|
nullifier: Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<RW> ToHaskell<RW> for Hnote {
|
impl<RW> ToHaskell<RW> for Hnote {
|
||||||
|
@ -732,6 +733,7 @@ pub extern "C" fn rust_wrapper_sapling_esk_decrypt(
|
||||||
note_len: usize,
|
note_len: usize,
|
||||||
external: bool,
|
external: bool,
|
||||||
net: bool,
|
net: bool,
|
||||||
|
pos: u64,
|
||||||
out: *mut u8,
|
out: *mut u8,
|
||||||
out_len: &mut usize
|
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)};
|
else {zcash_note_encryption::try_note_decryption(&test_domain, &pivk, &action2)};
|
||||||
match result {
|
match result {
|
||||||
Some((n, r, m)) => {
|
Some((n, r, m)) => {
|
||||||
//let nullifier = n.nf(&nk, MerklePath<Node::from_cmu(&n.cmu()), SAPLING_DEPTH>.position());
|
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() };
|
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);
|
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||||
},
|
},
|
||||||
None => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_e1) => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_e) => {
|
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);
|
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);
|
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action3);
|
||||||
match result {
|
match result {
|
||||||
Some((n, r, m)) => {
|
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);
|
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||||
}
|
}
|
||||||
None => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_e1) => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
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);
|
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);
|
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action);
|
||||||
match result {
|
match result {
|
||||||
Some((n, r, m)) => {
|
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);
|
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||||
}
|
}
|
||||||
None => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
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);
|
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);
|
let result = zcash_note_encryption::try_note_decryption(&domain, &pivk, &action);
|
||||||
match result {
|
match result {
|
||||||
Some((n, r, m)) => {
|
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);
|
marshall_to_haskell_var(&hn, out, out_len, RW);
|
||||||
}
|
}
|
||||||
None => {
|
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);
|
marshall_to_haskell_var(&hn0, out, out_len, RW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ import ZcashHaskell.Types
|
||||||
, toBorshVar* `BS.ByteString'&
|
, toBorshVar* `BS.ByteString'&
|
||||||
, `Bool'
|
, `Bool'
|
||||||
, `Bool'
|
, `Bool'
|
||||||
|
, `Word64'
|
||||||
, getVarBuffer `Buffer DecodedNote'&
|
, getVarBuffer `Buffer DecodedNote'&
|
||||||
}
|
}
|
||||||
-> `()'
|
-> `()'
|
||||||
|
|
|
@ -121,8 +121,9 @@ decodeSaplingOutputEsk ::
|
||||||
-> ShieldedOutput
|
-> ShieldedOutput
|
||||||
-> ZcashNet
|
-> ZcashNet
|
||||||
-> Scope
|
-> Scope
|
||||||
|
-> Integer
|
||||||
-> Maybe DecodedNote
|
-> Maybe DecodedNote
|
||||||
decodeSaplingOutputEsk key out znet scope =
|
decodeSaplingOutputEsk key out znet scope pos =
|
||||||
case a_value decodedAction of
|
case a_value decodedAction of
|
||||||
0 -> Nothing
|
0 -> Nothing
|
||||||
_ -> Just decodedAction
|
_ -> Just decodedAction
|
||||||
|
@ -134,6 +135,7 @@ decodeSaplingOutputEsk key out znet scope =
|
||||||
(serializeShieldedOutput out)
|
(serializeShieldedOutput out)
|
||||||
(znet == MainNet)
|
(znet == MainNet)
|
||||||
(scope == External)
|
(scope == External)
|
||||||
|
(fromIntegral pos)
|
||||||
|
|
||||||
-- | Attempts to obtain a sapling SpendingKey using a HDSeed
|
-- | Attempts to obtain a sapling SpendingKey using a HDSeed
|
||||||
genSaplingSpendingKey :: Seed -> CoinType -> Int -> Maybe SaplingSpendingKey
|
genSaplingSpendingKey :: Seed -> CoinType -> Int -> Maybe SaplingSpendingKey
|
||||||
|
|
Loading…
Reference in a new issue