Rename EncryptedCiphertext to EncryptedNote
This commit is contained in:
parent
005ec6c57c
commit
df89a049cb
|
@ -7,11 +7,11 @@ use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize,
|
||||||
|
|
||||||
/// A ciphertext component for encrypted output notes.
|
/// A ciphertext component for encrypted output notes.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[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 {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
f.debug_tuple("EncryptedCiphertext")
|
f.debug_tuple("EncryptedNote")
|
||||||
.field(&hex::encode(&self.0[..]))
|
.field(&hex::encode(&self.0[..]))
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ impl fmt::Debug for EncryptedCiphertext {
|
||||||
|
|
||||||
// These impls all only exist because of array length restrictions.
|
// 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 {
|
fn clone(&self) -> Self {
|
||||||
let mut bytes = [0; 580];
|
let mut bytes = [0; 580];
|
||||||
bytes[..].copy_from_slice(&self.0[..]);
|
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 {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.0[..] == other.0[..]
|
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> {
|
fn zcash_serialize<W: io::Write>(&self, mut writer: W) -> Result<(), io::Error> {
|
||||||
writer.write_all(&self.0[..])?;
|
writer.write_all(&self.0[..])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ZcashDeserialize for EncryptedCiphertext {
|
impl ZcashDeserialize for EncryptedNote {
|
||||||
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
|
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
|
||||||
let mut bytes = [0; 580];
|
let mut bytes = [0; 580];
|
||||||
reader.read_exact(&mut bytes[..])?;
|
reader.read_exact(&mut bytes[..])?;
|
||||||
|
@ -103,13 +103,13 @@ impl ZcashDeserialize for OutCiphertext {
|
||||||
proptest! {
|
proptest! {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedCiphertext>()) {
|
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedNote>()) {
|
||||||
|
|
||||||
let mut data = Vec::new();
|
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];
|
prop_assert_eq![ec, ec2];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue