diff --git a/zebra-chain/src/lib.rs b/zebra-chain/src/lib.rs index 8f982899..2f895e45 100644 --- a/zebra-chain/src/lib.rs +++ b/zebra-chain/src/lib.rs @@ -15,7 +15,6 @@ mod merkle_tree; pub mod addresses; pub mod keys; -pub mod notes; pub mod amount; pub mod block; diff --git a/zebra-chain/src/notes.rs b/zebra-chain/src/notes.rs deleted file mode 100644 index 24b15871..00000000 --- a/zebra-chain/src/notes.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Notes, note encryption, and nullifier types. - -#[cfg(test)] -mod arbitrary; -pub mod memo; diff --git a/zebra-chain/src/notes/arbitrary.rs b/zebra-chain/src/notes/arbitrary.rs deleted file mode 100644 index c562f784..00000000 --- a/zebra-chain/src/notes/arbitrary.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::notes::memo::Memo; - -use proptest::{arbitrary::any, collection::vec, prelude::*}; - -impl Arbitrary for Memo { - type Parameters = (); - - fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { - (vec(any::(), 512)) - .prop_map(|v| { - let mut bytes = [0; 512]; - bytes.copy_from_slice(v.as_slice()); - Memo(Box::new(bytes)) - }) - .boxed() - } - - type Strategy = BoxedStrategy; -} diff --git a/zebra-chain/src/notes/test_vectors.rs b/zebra-chain/src/notes/test_vectors.rs deleted file mode 100644 index 1be708b1..00000000 --- a/zebra-chain/src/notes/test_vectors.rs +++ /dev/null @@ -1,58 +0,0 @@ -pub const MEMO_FIELD_INVALID_UTF8_BYTES = [0xf6, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00]; diff --git a/zebra-chain/src/sapling/note.rs b/zebra-chain/src/sapling/note.rs index ad10703d..82936dc0 100644 --- a/zebra-chain/src/sapling/note.rs +++ b/zebra-chain/src/sapling/note.rs @@ -11,7 +11,7 @@ mod arbitrary; use crate::{ amount::{Amount, NonNegative}, - notes::memo::Memo, + transaction::Memo, }; use super::{ diff --git a/zebra-chain/src/sprout/note.rs b/zebra-chain/src/sprout/note.rs index bbcd532e..0dacf1f9 100644 --- a/zebra-chain/src/sprout/note.rs +++ b/zebra-chain/src/sprout/note.rs @@ -11,7 +11,7 @@ mod nullifiers; use crate::{ amount::{Amount, NonNegative}, - notes::memo::Memo, + transaction::Memo, }; use super::{commitment::CommitmentRandomness, keys::PayingKey}; diff --git a/zebra-chain/src/sprout/note/arbitrary.rs b/zebra-chain/src/sprout/note/arbitrary.rs index 1e6e02ad..e151b8a2 100644 --- a/zebra-chain/src/sprout/note/arbitrary.rs +++ b/zebra-chain/src/sprout/note/arbitrary.rs @@ -1,6 +1,5 @@ use proptest::{arbitrary::any, collection::vec, prelude::*}; - impl Arbitrary for super::EncryptedCiphertext { type Parameters = (); diff --git a/zebra-chain/src/transaction.rs b/zebra-chain/src/transaction.rs index 41d743fb..d8d59744 100644 --- a/zebra-chain/src/transaction.rs +++ b/zebra-chain/src/transaction.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; mod hash; mod joinsplit; mod lock_time; +mod memo; mod serialize; mod shielded_data; mod transparent; @@ -15,6 +16,7 @@ mod tests; pub use hash::TransactionHash; pub use joinsplit::{JoinSplit, JoinSplitData}; pub use lock_time::LockTime; +pub use memo::Memo; pub use shielded_data::{Output, ShieldedData, Spend}; pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput}; diff --git a/zebra-chain/src/transaction/joinsplit.rs b/zebra-chain/src/transaction/joinsplit.rs index 54ef5901..1d59834a 100644 --- a/zebra-chain/src/transaction/joinsplit.rs +++ b/zebra-chain/src/transaction/joinsplit.rs @@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::{ amount::{Amount, NonNegative}, - sprout, primitives::{ed25519, x25519, ZkSnarkProof}, + sprout, }; /// A _JoinSplit Description_, as described in [protocol specification §7.2][ps]. diff --git a/zebra-chain/src/notes/memo.rs b/zebra-chain/src/transaction/memo.rs similarity index 98% rename from zebra-chain/src/notes/memo.rs rename to zebra-chain/src/transaction/memo.rs index dec549a8..e5d0ad52 100644 --- a/zebra-chain/src/notes/memo.rs +++ b/zebra-chain/src/transaction/memo.rs @@ -1,6 +1,6 @@ use std::{cmp, convert::TryFrom, fmt}; -/// A 512-byte _Memo_ field associated with a note, as described in +/// A 512-byte (plaintext) memo associated with a note, as described in /// [protocol specification §5.5][ps]. /// /// The _Memo_ field of a note is a plaintext type; the parent note is diff --git a/zebra-chain/src/transaction/tests/arbitrary.rs b/zebra-chain/src/transaction/tests/arbitrary.rs index d22c39e4..0d45b58c 100644 --- a/zebra-chain/src/transaction/tests/arbitrary.rs +++ b/zebra-chain/src/transaction/tests/arbitrary.rs @@ -6,12 +6,12 @@ use crate::{ amount::{Amount, NonNegative}, block::BlockHeight, primitives::{Bctv14Proof, Groth16Proof, Script, ZkSnarkProof}, - sapling, - sprout, - transaction::{ - CoinbaseData, JoinSplit, JoinSplitData, LockTime, OutPoint, Output, ShieldedData, Spend, - Transaction, TransparentInput, TransparentOutput, - }, + sapling, sprout, +}; + +use super::super::{ + CoinbaseData, JoinSplit, JoinSplitData, LockTime, Memo, OutPoint, Output, ShieldedData, Spend, + Transaction, TransparentInput, TransparentOutput, }; impl Transaction { @@ -100,6 +100,22 @@ impl Transaction { } } +impl Arbitrary for Memo { + type Parameters = (); + + fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { + (vec(any::(), 512)) + .prop_map(|v| { + let mut bytes = [0; 512]; + bytes.copy_from_slice(v.as_slice()); + Memo(Box::new(bytes)) + }) + .boxed() + } + + type Strategy = BoxedStrategy; +} + impl Arbitrary for LockTime { type Parameters = ();