From d6eecbe9354d89696747ab22364e436deb81711d Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Fri, 28 Aug 2020 00:29:40 -0400 Subject: [PATCH] Rename Sprout EncyptedCiphertext to EncryptedNote --- zebra-chain/src/sprout/joinsplit.rs | 6 ++--- zebra-chain/src/sprout/note.rs | 2 +- zebra-chain/src/sprout/note/arbitrary.rs | 2 +- zebra-chain/src/sprout/note/ciphertexts.rs | 26 ++++++++++++---------- zebra-chain/src/sprout/tests/arbitrary.rs | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/zebra-chain/src/sprout/joinsplit.rs b/zebra-chain/src/sprout/joinsplit.rs index 77fc7c74..fbd432d6 100644 --- a/zebra-chain/src/sprout/joinsplit.rs +++ b/zebra-chain/src/sprout/joinsplit.rs @@ -46,7 +46,7 @@ pub struct JoinSplit { #[serde(bound(serialize = "P: ZkSnarkProof", deserialize = "P: ZkSnarkProof"))] pub zkproof: P, /// A ciphertext component for this output note. - pub enc_ciphertexts: [note::EncryptedCiphertext; 2], + pub enc_ciphertexts: [note::EncryptedNote; 2], } // Because x25519_dalek::PublicKey does not impl PartialEq @@ -110,8 +110,8 @@ impl ZcashDeserialize for JoinSplit

{ ], zkproof: P::zcash_deserialize(&mut reader)?, enc_ciphertexts: [ - note::EncryptedCiphertext::zcash_deserialize(&mut reader)?, - note::EncryptedCiphertext::zcash_deserialize(&mut reader)?, + note::EncryptedNote::zcash_deserialize(&mut reader)?, + note::EncryptedNote::zcash_deserialize(&mut reader)?, ], }) } diff --git a/zebra-chain/src/sprout/note.rs b/zebra-chain/src/sprout/note.rs index 0dacf1f9..16ffac98 100644 --- a/zebra-chain/src/sprout/note.rs +++ b/zebra-chain/src/sprout/note.rs @@ -18,7 +18,7 @@ use super::{commitment::CommitmentRandomness, keys::PayingKey}; pub use mac::MAC; -pub use ciphertexts::EncryptedCiphertext; +pub use ciphertexts::EncryptedNote; pub use nullifiers::{Nullifier, NullifierSeed}; diff --git a/zebra-chain/src/sprout/note/arbitrary.rs b/zebra-chain/src/sprout/note/arbitrary.rs index e151b8a2..ae7090f5 100644 --- a/zebra-chain/src/sprout/note/arbitrary.rs +++ b/zebra-chain/src/sprout/note/arbitrary.rs @@ -1,6 +1,6 @@ use proptest::{arbitrary::any, collection::vec, prelude::*}; -impl Arbitrary for super::EncryptedCiphertext { +impl Arbitrary for super::EncryptedNote { type Parameters = (); fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { diff --git a/zebra-chain/src/sprout/note/ciphertexts.rs b/zebra-chain/src/sprout/note/ciphertexts.rs index 414c44d3..032c8202 100644 --- a/zebra-chain/src/sprout/note/ciphertexts.rs +++ b/zebra-chain/src/sprout/note/ciphertexts.rs @@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize}; use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize}; /// A ciphertext component for encrypted output notes. +/// +/// Corresponds to the Sprout 'encCiphertext's #[derive(Serialize, Deserialize)] -pub struct EncryptedCiphertext(#[serde(with = "serde_helpers::BigArray")] pub [u8; 601]); +pub struct EncryptedNote(#[serde(with = "serde_helpers::BigArray")] pub [u8; 601]); -impl fmt::Debug for EncryptedCiphertext { +impl fmt::Debug for EncryptedNote { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("EncryptedCiphertext") + f.debug_tuple("EncryptedNote") .field(&hex::encode(&self.0[..])) .finish() } @@ -21,9 +23,9 @@ impl fmt::Debug for EncryptedCiphertext { // These impls all only exist because of array length restrictions. -impl Copy for EncryptedCiphertext {} +impl Copy for EncryptedNote {} -impl Clone for EncryptedCiphertext { +impl Clone for EncryptedNote { fn clone(&self) -> Self { let mut bytes = [0; 601]; bytes[..].copy_from_slice(&self.0[..]); @@ -31,22 +33,22 @@ impl Clone for EncryptedCiphertext { } } -impl PartialEq for EncryptedCiphertext { +impl PartialEq for EncryptedNote { fn eq(&self, other: &Self) -> bool { self.0[..] == other.0[..] } } -impl Eq for EncryptedCiphertext {} +impl Eq for EncryptedNote {} -impl ZcashSerialize for EncryptedCiphertext { +impl ZcashSerialize for EncryptedNote { fn zcash_serialize(&self, mut writer: W) -> Result<(), io::Error> { writer.write_all(&self.0[..])?; Ok(()) } } -impl ZcashDeserialize for EncryptedCiphertext { +impl ZcashDeserialize for EncryptedNote { fn zcash_deserialize(mut reader: R) -> Result { let mut bytes = [0; 601]; reader.read_exact(&mut bytes[..])?; @@ -58,13 +60,13 @@ impl ZcashDeserialize for EncryptedCiphertext { proptest! { #[test] - fn encrypted_ciphertext_roundtrip(ec in any::()) { + fn encrypted_ciphertext_roundtrip(ec in any::()) { let mut data = Vec::new(); - ec.zcash_serialize(&mut data).expect("EncryptedCiphertext should serialize"); + ec.zcash_serialize(&mut data).expect("EncryptedNote should serialize"); - let ec2 = EncryptedCiphertext::zcash_deserialize(&data[..]).expect("randomized EncryptedCiphertext should deserialize"); + let ec2 = EncryptedNote::zcash_deserialize(&data[..]).expect("randomized EncryptedNote should deserialize"); prop_assert_eq![ec, ec2]; } diff --git a/zebra-chain/src/sprout/tests/arbitrary.rs b/zebra-chain/src/sprout/tests/arbitrary.rs index 465d9dbc..68191379 100644 --- a/zebra-chain/src/sprout/tests/arbitrary.rs +++ b/zebra-chain/src/sprout/tests/arbitrary.rs @@ -21,7 +21,7 @@ impl Arbitrary for JoinSplit

{ array::uniform32(any::()), array::uniform2(any::()), any::

(), - array::uniform2(any::()), + array::uniform2(any::()), ) .prop_map( |(