zebra_chain/sprout/
keys.rs

1//! Sprout key types.
2//!
3//! Unused key types are not implemented, see PR #5476.
4//!
5//! "The receiving key sk_enc, the incoming viewing key ivk = (apk,
6//! sk_enc), and the shielded payment address addr_pk = (a_pk, pk_enc) are
7//! derived from a_sk, as described in ['Sprout Key Components'][ps]
8//!
9//! [ps]: https://zips.z.cash/protocol/protocol.pdf#sproutkeycomponents
10
11use std::fmt;
12
13/// A Sprout _paying key_.
14///
15/// Derived from a Sprout _spending key.
16#[derive(Copy, Clone, Eq, PartialEq)]
17#[cfg_attr(
18    any(test, feature = "proptest-impl"),
19    derive(proptest_derive::Arbitrary)
20)]
21pub struct PayingKey(pub [u8; 32]);
22
23impl AsRef<[u8]> for PayingKey {
24    fn as_ref(&self) -> &[u8] {
25        &self.0
26    }
27}
28
29impl fmt::Debug for PayingKey {
30    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31        f.debug_tuple("PayingKey")
32            .field(&hex::encode(self.0))
33            .finish()
34    }
35}