More Note refinements

This commit is contained in:
Deirdre Connolly 2020-07-09 21:20:50 -04:00 committed by Deirdre Connolly
parent 2c285985c8
commit 15899bc6d3
2 changed files with 15 additions and 2 deletions

View File

@ -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 /// A Note represents that a value is spendable by the recipient who
/// holds the spending key corresponding to a given shielded payment /// holds the spending key corresponding to a given shielded payment
/// address. /// address.
@ -53,8 +57,7 @@ pub struct Note {
/// The decrypted form of encrypted Sapling notes on the blockchain. /// The decrypted form of encrypted Sapling notes on the blockchain.
pub struct NotePlaintext { pub struct NotePlaintext {
diversifier: Diversifier, diversifier: Diversifier,
value: u64, value: Amount<NonNegative>,
// TODO: refine as jub-jub appropriate in the base field.
note_commitment_randomness: NoteCommitmentRandomness, note_commitment_randomness: NoteCommitmentRandomness,
memo: memo::Memo, memo: memo::Memo,
} }

View File

@ -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 /// A Note represents that a value is spendable by the recipient who
/// holds the spending key corresponding to a given shielded payment /// holds the spending key corresponding to a given shielded payment
/// address. /// address.