chain: move Memo into transaction

This commit is contained in:
Henry de Valence 2020-08-15 18:50:18 -07:00
parent 312c66264a
commit e8f923ec86
11 changed files with 28 additions and 94 deletions

View File

@ -15,7 +15,6 @@ mod merkle_tree;
pub mod addresses; pub mod addresses;
pub mod keys; pub mod keys;
pub mod notes;
pub mod amount; pub mod amount;
pub mod block; pub mod block;

View File

@ -1,5 +0,0 @@
//! Notes, note encryption, and nullifier types.
#[cfg(test)]
mod arbitrary;
pub mod memo;

View File

@ -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::<u8>(), 512))
.prop_map(|v| {
let mut bytes = [0; 512];
bytes.copy_from_slice(v.as_slice());
Memo(Box::new(bytes))
})
.boxed()
}
type Strategy = BoxedStrategy<Self>;
}

View File

@ -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];

View File

@ -11,7 +11,7 @@ mod arbitrary;
use crate::{ use crate::{
amount::{Amount, NonNegative}, amount::{Amount, NonNegative},
notes::memo::Memo, transaction::Memo,
}; };
use super::{ use super::{

View File

@ -11,7 +11,7 @@ mod nullifiers;
use crate::{ use crate::{
amount::{Amount, NonNegative}, amount::{Amount, NonNegative},
notes::memo::Memo, transaction::Memo,
}; };
use super::{commitment::CommitmentRandomness, keys::PayingKey}; use super::{commitment::CommitmentRandomness, keys::PayingKey};

View File

@ -1,6 +1,5 @@
use proptest::{arbitrary::any, collection::vec, prelude::*}; use proptest::{arbitrary::any, collection::vec, prelude::*};
impl Arbitrary for super::EncryptedCiphertext { impl Arbitrary for super::EncryptedCiphertext {
type Parameters = (); type Parameters = ();

View File

@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
mod hash; mod hash;
mod joinsplit; mod joinsplit;
mod lock_time; mod lock_time;
mod memo;
mod serialize; mod serialize;
mod shielded_data; mod shielded_data;
mod transparent; mod transparent;
@ -15,6 +16,7 @@ mod tests;
pub use hash::TransactionHash; pub use hash::TransactionHash;
pub use joinsplit::{JoinSplit, JoinSplitData}; pub use joinsplit::{JoinSplit, JoinSplitData};
pub use lock_time::LockTime; pub use lock_time::LockTime;
pub use memo::Memo;
pub use shielded_data::{Output, ShieldedData, Spend}; pub use shielded_data::{Output, ShieldedData, Spend};
pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput}; pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput};

View File

@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
use crate::{ use crate::{
amount::{Amount, NonNegative}, amount::{Amount, NonNegative},
sprout,
primitives::{ed25519, x25519, ZkSnarkProof}, primitives::{ed25519, x25519, ZkSnarkProof},
sprout,
}; };
/// A _JoinSplit Description_, as described in [protocol specification §7.2][ps]. /// A _JoinSplit Description_, as described in [protocol specification §7.2][ps].

View File

@ -1,6 +1,6 @@
use std::{cmp, convert::TryFrom, fmt}; 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]. /// [protocol specification §5.5][ps].
/// ///
/// The _Memo_ field of a note is a plaintext type; the parent note is /// The _Memo_ field of a note is a plaintext type; the parent note is

View File

@ -6,12 +6,12 @@ use crate::{
amount::{Amount, NonNegative}, amount::{Amount, NonNegative},
block::BlockHeight, block::BlockHeight,
primitives::{Bctv14Proof, Groth16Proof, Script, ZkSnarkProof}, primitives::{Bctv14Proof, Groth16Proof, Script, ZkSnarkProof},
sapling, sapling, sprout,
sprout, };
transaction::{
CoinbaseData, JoinSplit, JoinSplitData, LockTime, OutPoint, Output, ShieldedData, Spend, use super::super::{
Transaction, TransparentInput, TransparentOutput, CoinbaseData, JoinSplit, JoinSplitData, LockTime, Memo, OutPoint, Output, ShieldedData, Spend,
}, Transaction, TransparentInput, TransparentOutput,
}; };
impl Transaction { impl Transaction {
@ -100,6 +100,22 @@ impl Transaction {
} }
} }
impl Arbitrary for Memo {
type Parameters = ();
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
(vec(any::<u8>(), 512))
.prop_map(|v| {
let mut bytes = [0; 512];
bytes.copy_from_slice(v.as_slice());
Memo(Box::new(bytes))
})
.boxed()
}
type Strategy = BoxedStrategy<Self>;
}
impl Arbitrary for LockTime { impl Arbitrary for LockTime {
type Parameters = (); type Parameters = ();