From 15899bc6d3acdbc9cd3fd49e5d515d016b34a6d9 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Thu, 9 Jul 2020 21:20:50 -0400 Subject: [PATCH] More Note refinements --- zebra-chain/src/notes/sapling.rs | 7 +++++-- zebra-chain/src/notes/sprout.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/zebra-chain/src/notes/sapling.rs b/zebra-chain/src/notes/sapling.rs index f09e7ffc2..9a3195e29 100644 --- a/zebra-chain/src/notes/sapling.rs +++ b/zebra-chain/src/notes/sapling.rs @@ -40,6 +40,10 @@ impl ZcashSerialize for Nullifier { } } +/// The randomness used in the Pedersen Hash for note commitment. +#[derive(Copy, Clone, Debug, PartialEq)] +pub struct NoteCommitmentRandomness(redjubjub::Randomizer); + /// A Note represents that a value is spendable by the recipient who /// holds the spending key corresponding to a given shielded payment /// address. @@ -53,8 +57,7 @@ pub struct Note { /// 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. + value: Amount, note_commitment_randomness: NoteCommitmentRandomness, memo: memo::Memo, } diff --git a/zebra-chain/src/notes/sprout.rs b/zebra-chain/src/notes/sprout.rs index 41e7fe3ff..12ab06a30 100644 --- a/zebra-chain/src/notes/sprout.rs +++ b/zebra-chain/src/notes/sprout.rs @@ -53,6 +53,16 @@ impl ZcashSerialize for Nullifier { } } +/// The randomness used in the Pedersen Hash for note commitment. +#[derive(Copy, Clone, Debug, PartialEq)] +pub struct NoteCommitmentRandomness(pub [u8; 32]); + +impl AsRef<[u8]> for NoteCommitmentRandomness { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + /// A Note represents that a value is spendable by the recipient who /// holds the spending key corresponding to a given shielded payment /// address.