Rename Sprout EncyptedCiphertext to EncryptedNote
This commit is contained in:
parent
99b4a400af
commit
d6eecbe935
|
|
@ -46,7 +46,7 @@ pub struct JoinSplit<P: ZkSnarkProof> {
|
||||||
#[serde(bound(serialize = "P: ZkSnarkProof", deserialize = "P: ZkSnarkProof"))]
|
#[serde(bound(serialize = "P: ZkSnarkProof", deserialize = "P: ZkSnarkProof"))]
|
||||||
pub zkproof: P,
|
pub zkproof: P,
|
||||||
/// A ciphertext component for this output note.
|
/// 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
|
// Because x25519_dalek::PublicKey does not impl PartialEq
|
||||||
|
|
@ -110,8 +110,8 @@ impl<P: ZkSnarkProof> ZcashDeserialize for JoinSplit<P> {
|
||||||
],
|
],
|
||||||
zkproof: P::zcash_deserialize(&mut reader)?,
|
zkproof: P::zcash_deserialize(&mut reader)?,
|
||||||
enc_ciphertexts: [
|
enc_ciphertexts: [
|
||||||
note::EncryptedCiphertext::zcash_deserialize(&mut reader)?,
|
note::EncryptedNote::zcash_deserialize(&mut reader)?,
|
||||||
note::EncryptedCiphertext::zcash_deserialize(&mut reader)?,
|
note::EncryptedNote::zcash_deserialize(&mut reader)?,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use super::{commitment::CommitmentRandomness, keys::PayingKey};
|
||||||
|
|
||||||
pub use mac::MAC;
|
pub use mac::MAC;
|
||||||
|
|
||||||
pub use ciphertexts::EncryptedCiphertext;
|
pub use ciphertexts::EncryptedNote;
|
||||||
|
|
||||||
pub use nullifiers::{Nullifier, NullifierSeed};
|
pub use nullifiers::{Nullifier, NullifierSeed};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use proptest::{arbitrary::any, collection::vec, prelude::*};
|
use proptest::{arbitrary::any, collection::vec, prelude::*};
|
||||||
|
|
||||||
impl Arbitrary for super::EncryptedCiphertext {
|
impl Arbitrary for super::EncryptedNote {
|
||||||
type Parameters = ();
|
type Parameters = ();
|
||||||
|
|
||||||
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@ use serde::{Deserialize, Serialize};
|
||||||
use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
|
use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
|
||||||
|
|
||||||
/// A ciphertext component for encrypted output notes.
|
/// A ciphertext component for encrypted output notes.
|
||||||
|
///
|
||||||
|
/// Corresponds to the Sprout 'encCiphertext's
|
||||||
#[derive(Serialize, Deserialize)]
|
#[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 {
|
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()
|
||||||
}
|
}
|
||||||
|
|
@ -21,9 +23,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; 601];
|
let mut bytes = [0; 601];
|
||||||
bytes[..].copy_from_slice(&self.0[..]);
|
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 {
|
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; 601];
|
let mut bytes = [0; 601];
|
||||||
reader.read_exact(&mut bytes[..])?;
|
reader.read_exact(&mut bytes[..])?;
|
||||||
|
|
@ -58,13 +60,13 @@ impl ZcashDeserialize for EncryptedCiphertext {
|
||||||
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];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
|
||||||
array::uniform32(any::<u8>()),
|
array::uniform32(any::<u8>()),
|
||||||
array::uniform2(any::<note::MAC>()),
|
array::uniform2(any::<note::MAC>()),
|
||||||
any::<P>(),
|
any::<P>(),
|
||||||
array::uniform2(any::<note::EncryptedCiphertext>()),
|
array::uniform2(any::<note::EncryptedNote>()),
|
||||||
)
|
)
|
||||||
.prop_map(
|
.prop_map(
|
||||||
|(
|
|(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue