mirror of https://github.com/zcash/orchard.git
Add internal DiversifiedTransmissionKey type
This commit is contained in:
parent
a61be5d58b
commit
71542f7ec2
|
@ -1,6 +1,4 @@
|
|||
use halo2::pasta::pallas;
|
||||
|
||||
use crate::keys::Diversifier;
|
||||
use crate::keys::{DiversifiedTransmissionKey, Diversifier};
|
||||
|
||||
/// A shielded payment address.
|
||||
///
|
||||
|
@ -15,11 +13,11 @@ use crate::keys::Diversifier;
|
|||
#[derive(Debug)]
|
||||
pub struct Address {
|
||||
d: Diversifier,
|
||||
pk_d: pallas::Point,
|
||||
pk_d: DiversifiedTransmissionKey,
|
||||
}
|
||||
|
||||
impl Address {
|
||||
pub(crate) fn from_parts(d: Diversifier, pk_d: pallas::Point) -> Self {
|
||||
pub(crate) fn from_parts(d: Diversifier, pk_d: DiversifiedTransmissionKey) -> Self {
|
||||
Address { d, pk_d }
|
||||
}
|
||||
}
|
||||
|
|
18
src/keys.rs
18
src/keys.rs
|
@ -214,8 +214,8 @@ impl From<&FullViewingKey> for IncomingViewingKey {
|
|||
impl IncomingViewingKey {
|
||||
/// Returns the payment address for this key corresponding to the given diversifier.
|
||||
pub fn address(&self, d: Diversifier) -> Address {
|
||||
let g_d = diversify_hash(&d.0);
|
||||
Address::from_parts(d, ka_orchard(&self.0, &g_d))
|
||||
let pk_d = DiversifiedTransmissionKey::derive(self, &d);
|
||||
Address::from_parts(d, pk_d)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,3 +232,17 @@ impl From<&FullViewingKey> for OutgoingViewingKey {
|
|||
fvk.derive_dk_ovk().1
|
||||
}
|
||||
}
|
||||
|
||||
/// The diversified transmission key for a given payment address.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct DiversifiedTransmissionKey(pallas::Point);
|
||||
|
||||
impl DiversifiedTransmissionKey {
|
||||
/// Defined in [Zcash Protocol Spec § 4.2.3: Orchard Key Components][§4.2.3].
|
||||
///
|
||||
/// [§4.2.3]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents
|
||||
fn derive(ivk: &IncomingViewingKey, d: &Diversifier) -> Self {
|
||||
let g_d = diversify_hash(&d.0);
|
||||
DiversifiedTransmissionKey(ka_orchard(&ivk.0, &g_d))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue