Update FFI to use scoped APIs for viewing keys and addresses
This commit is contained in:
parent
72b27fb906
commit
bc33ba5a9f
|
@ -1260,8 +1260,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||
[[package]]
|
||||
name = "orchard"
|
||||
version = "0.1.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b48e6e124c3f7e9ed7f48b29f66069288235cecd16aa6053e98f8aff16efe827"
|
||||
source = "git+https://github.com/zcash/orchard.git?rev=eaa0cfdbf6a52a023752ac8e29d10308318424a0#eaa0cfdbf6a52a023752ac8e29d10308318424a0"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"arrayvec 0.7.2",
|
||||
|
|
|
@ -93,3 +93,4 @@ zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1e
|
|||
zcash_note_encryption = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||
zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||
zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||
orchard = { git = "https://github.com/zcash/orchard.git", rev = "eaa0cfdbf6a52a023752ac8e29d10308318424a0" }
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::slice;
|
|||
use tracing::error;
|
||||
|
||||
use orchard::{
|
||||
keys::{DiversifierIndex, FullViewingKey, IncomingViewingKey, OutgoingViewingKey, SpendingKey},
|
||||
keys::{DiversifierIndex, FullViewingKey, IncomingViewingKey, Scope, SpendingKey},
|
||||
Address,
|
||||
};
|
||||
|
||||
|
@ -268,7 +268,7 @@ pub extern "C" fn orchard_full_viewing_key_to_incoming_viewing_key(
|
|||
key: *const FullViewingKey,
|
||||
) -> *mut IncomingViewingKey {
|
||||
unsafe { key.as_ref() }
|
||||
.map(|key| Box::into_raw(Box::new(IncomingViewingKey::from(key))))
|
||||
.map(|key| Box::into_raw(Box::new(key.to_ivk(Scope::External))))
|
||||
.unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
|
@ -277,10 +277,7 @@ pub extern "C" fn orchard_full_viewing_key_to_internal_incoming_viewing_key(
|
|||
fvk: *const FullViewingKey,
|
||||
) -> *mut IncomingViewingKey {
|
||||
unsafe { fvk.as_ref() }
|
||||
.map(|fvk| {
|
||||
let internal_fvk = fvk.derive_internal();
|
||||
Box::into_raw(Box::new(IncomingViewingKey::from(&internal_fvk)))
|
||||
})
|
||||
.map(|fvk| Box::into_raw(Box::new(fvk.to_ivk(Scope::Internal))))
|
||||
.unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
|
@ -292,7 +289,7 @@ pub extern "C" fn orchard_full_viewing_key_to_external_outgoing_viewing_key(
|
|||
let fvk = unsafe { fvk.as_ref() }.expect("fvk must not be null");
|
||||
let ovk_ret = unsafe { ovk_ret.as_mut() }.expect("ovk_ret must not be null");
|
||||
|
||||
let ovk = OutgoingViewingKey::from(fvk);
|
||||
let ovk = fvk.to_ovk(Scope::External);
|
||||
*ovk_ret = *ovk.as_ref();
|
||||
}
|
||||
|
||||
|
@ -304,8 +301,7 @@ pub extern "C" fn orchard_full_viewing_key_to_internal_outgoing_viewing_key(
|
|||
let fvk = unsafe { fvk.as_ref() }.expect("fvk must not be null");
|
||||
let ovk_ret = unsafe { ovk_ret.as_mut() }.expect("ovk_ret must not be null");
|
||||
|
||||
let internal_fvk = fvk.derive_internal();
|
||||
let ovk = OutgoingViewingKey::from(&internal_fvk);
|
||||
let ovk = fvk.to_ovk(Scope::Internal);
|
||||
*ovk_ret = *ovk.as_ref();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use zcash_primitives::{
|
|||
|
||||
use orchard::{
|
||||
bundle::Authorized,
|
||||
keys::{FullViewingKey, IncomingViewingKey, OutgoingViewingKey, SpendingKey},
|
||||
keys::{FullViewingKey, IncomingViewingKey, OutgoingViewingKey, Scope, SpendingKey},
|
||||
note::Nullifier,
|
||||
tree::{MerkleHashOrchard, MerklePath},
|
||||
Address, Bundle, Note,
|
||||
|
@ -92,8 +92,8 @@ impl KeyStore {
|
|||
pub fn add_full_viewing_key(&mut self, fvk: FullViewingKey) {
|
||||
// When we add a full viewing key, we need to add both the internal and external
|
||||
// incoming viewing keys.
|
||||
let external_ivk = IncomingViewingKey::from(&fvk);
|
||||
let internal_ivk = IncomingViewingKey::from(&fvk.derive_internal());
|
||||
let external_ivk = fvk.to_ivk(Scope::External);
|
||||
let internal_ivk = fvk.to_ivk(Scope::Internal);
|
||||
self.viewing_keys.insert(external_ivk, fvk.clone());
|
||||
self.viewing_keys.insert(internal_ivk, fvk);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue