From a6a3a640ca346733697bdf5fe98e1080b62820fe Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Sat, 22 Feb 2020 18:22:28 -0500 Subject: [PATCH] Tidied up some note encryption types --- zebra-chain/src/note_encryption.rs | 4 +--- zebra-chain/src/note_encryption/sapling.rs | 13 +++++++++++-- zebra-chain/src/note_encryption/sprout.rs | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/zebra-chain/src/note_encryption.rs b/zebra-chain/src/note_encryption.rs index bdf3125e..76027533 100644 --- a/zebra-chain/src/note_encryption.rs +++ b/zebra-chain/src/note_encryption.rs @@ -3,8 +3,6 @@ mod memo; mod sapling; mod sprout; -#[derive(Copy, Clone, Debug, PartialEq)] -pub struct Diversifier(pub [u8; 11]); - +/// The randomness used in the Pedersen Hash for note commitment. #[derive(Copy, Clone, Debug, PartialEq)] pub struct NoteCommitmentRandomness(pub [u8; 32]); diff --git a/zebra-chain/src/note_encryption/sapling.rs b/zebra-chain/src/note_encryption/sapling.rs index b78ab3d0..45ae8755 100644 --- a/zebra-chain/src/note_encryption/sapling.rs +++ b/zebra-chain/src/note_encryption/sapling.rs @@ -5,19 +5,28 @@ use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*}; use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}; -use super::{Diversifier, Memo, NoteCommitmentRandomness}; +use super::*; + +/// A _Diversifier_, an 11 byte value used to randomize the +/// recipient's final public shielded payment address to create a +/// _diversified payment address_. +/// +/// When used, this value is mapped to an affine JubJub group element. +#[derive(Copy, Clone, Debug, PartialEq)] +pub struct Diversifier(pub [u8; 11]); pub struct Note { value: u64, diversifier: Diversifier, } +/// The decrypted form of encrypted Sapling notes on the blockchain. pub struct NotePlaintext { diversifier: Diversifier, value: u64, // TODO: refine as jub-jub appropriate in the base field. note_committment_randomness: NoteCommitmentRandomness, - memo: Memo, + memo: memo::Memo, } /// A ciphertext component for encrypted output notes. diff --git a/zebra-chain/src/note_encryption/sprout.rs b/zebra-chain/src/note_encryption/sprout.rs index ff5005e8..b248dfd5 100644 --- a/zebra-chain/src/note_encryption/sprout.rs +++ b/zebra-chain/src/note_encryption/sprout.rs @@ -8,15 +8,18 @@ use proptest::{collection::vec, prelude::*}; use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}; +use super::*; + pub struct Note {} +/// The decrypted form of encrypted Sprout notes on the blockchain. pub struct NotePlaintext { value: u64, // TODO: refine type rho: [u8; 32], // TODO: refine as jub-jub appropriate in the base field. note_committment_randomness: NoteCommitmentRandomness, - memo: Memo, + memo: memo::Memo, } /// A ciphertext component for encrypted output notes.