zebra/zebra-chain/src/keys/sprout.rs

57 lines
1.3 KiB
Rust
Raw Normal View History

2020-03-13 14:38:42 -07:00
//! Sprout key types
//!
//! "The receiving key sk_enc, the incoming viewing key ivk = (apk,
//! sk_enc), and the shielded payment address addr_pk = (a_pk, pk_enc) are
//! derived from a_sk, as described in [Sprout Key Components][ps]
//!
//! [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
2020-03-13 14:38:42 -07:00
2020-02-25 15:14:59 -08:00
use std::{
fmt,
io::{self},
};
#[cfg(test)]
use proptest::{array, collection::vec, prelude::*};
#[cfg(test)]
use proptest_derive::Arbitrary;
use sha2::sha256_utils::compress256;
2020-02-25 15:14:59 -08:00
use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize};
/// Our root secret key of the Sprout key derivation tree.
///
/// All other Sprout key types derive from the SpendingKey value.
/// Actually 252 bits.
pub struct SpendingKey(pub [u8; 32]);
/// Derived from a _SpendingKey_.
pub type ReceivingKey = x25519_dalek::StaticSecret;
impl From<SpendingKey> for ReceivingKey {
fn from(spending_key: SpendingKey) -> ReceivingKey {
ReceivingKey::from(spending_key.0)
}
}
/// Derived from a _SpendingKey_.
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PayingKey(pub [u8; 32]);
/// Derived from a _ReceivingKey_.
pub type TransmissionKey = x25519_dalek::PublicKey;
///
pub struct IncomingViewingKey {
paying_key: PayingKey,
receiving_key: ReceivingKey,
}
2020-02-25 15:14:59 -08:00
#[cfg(test)]
proptest! {
// #[test]
// fn test() {}
2020-02-25 15:14:59 -08:00
}