Rename EncryptedCiphertext to EncryptedNote

This commit is contained in:
Deirdre Connolly 2020-08-25 13:16:52 -04:00 committed by Deirdre Connolly
parent 005ec6c57c
commit df89a049cb
1 changed files with 12 additions and 12 deletions

View File

@ -7,11 +7,11 @@ use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize,
/// A ciphertext component for encrypted output notes.
#[derive(Deserialize, Serialize)]
pub struct EncryptedCiphertext(#[serde(with = "serde_helpers::BigArray")] pub [u8; 580]);
pub struct EncryptedNote(#[serde(with = "serde_helpers::BigArray")] pub [u8; 580]);
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()
}
@ -19,9 +19,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; 580];
bytes[..].copy_from_slice(&self.0[..]);
@ -29,22 +29,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<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
writer.write_all(&self.0[..])?;
Ok(())
}
}
impl ZcashDeserialize for EncryptedCiphertext {
impl ZcashDeserialize for EncryptedNote {
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
let mut bytes = [0; 580];
reader.read_exact(&mut bytes[..])?;
@ -103,13 +103,13 @@ impl ZcashDeserialize for OutCiphertext {
proptest! {
#[test]
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedCiphertext>()) {
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedNote>()) {
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];
}