From 7af9b80f3be7cf17e40f2dc64a956177b690fa70 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Fri, 13 Mar 2020 18:58:02 -0400 Subject: [PATCH] Add the beginnings of Sprout and Sapling key types --- zebra-chain/src/addresses.rs | 2 ++ zebra-chain/src/keys/sapling.rs | 7 +++++++ zebra-chain/src/keys/sprout.rs | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/zebra-chain/src/addresses.rs b/zebra-chain/src/addresses.rs index 7e200d1b..13b47325 100644 --- a/zebra-chain/src/addresses.rs +++ b/zebra-chain/src/addresses.rs @@ -1,3 +1,5 @@ //! Address types. +pub mod sapling; +pub mod sprout; pub mod transparent; diff --git a/zebra-chain/src/keys/sapling.rs b/zebra-chain/src/keys/sapling.rs index 0605a25e..486dc8d0 100644 --- a/zebra-chain/src/keys/sapling.rs +++ b/zebra-chain/src/keys/sapling.rs @@ -1,4 +1,11 @@ //! Sapling key types +//! +//! "The spend authorizing key ask, proof authorizing key (ak, nsk), +//! full viewing key (ak, nk, ovk), incoming viewing key ivk, and each +//! diversied payment address addr_d = (d, pk_d ) are derived from sk, +//! as described in [Sapling Key Components][ps]." +//! +//! [ps]: https://zips.z.cash/protocol/protocol.pdf#saplingkeycomponents use std::{ fmt, diff --git a/zebra-chain/src/keys/sprout.rs b/zebra-chain/src/keys/sprout.rs index 583d00fe..d910e602 100644 --- a/zebra-chain/src/keys/sprout.rs +++ b/zebra-chain/src/keys/sprout.rs @@ -1,4 +1,10 @@ //! 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 use std::{ fmt, @@ -12,6 +18,20 @@ use proptest_derive::Arbitrary; use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}; +/// All other Sprout key types derive from the SpendingKey value. +pub struct SpendingKey; + +pub struct ReceivingKey; + +pub struct PayingKey; + +pub struct TransmissionKey; + +pub struct IncomingViewingKey { + paying_key: PayingKey, + receiving_key: ReceivingKey, +} + #[cfg(test)] proptest! {