diff --git a/Cargo.lock b/Cargo.lock index 6fab48aa..982faef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -233,6 +242,17 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838#d3ebe9dd6488fac1923db120a7498079e55dd838" +dependencies = [ + "arbitrary", "ff", "group", "pairing", @@ -518,6 +538,17 @@ dependencies = [ "uuid", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.7" @@ -826,7 +857,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" dependencies = [ "bitvec", - "bls12_381", + "bls12_381 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ff", + "group", + "rand_core", + "subtle", +] + +[[package]] +name = "jubjub" +version = "0.10.0" +source = "git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19#e887d6964985f267a1085d480756f20d9eaceb19" +dependencies = [ + "arbitrary", + "bitvec", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "ff", "group", "rand_core", @@ -887,6 +932,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" name = "masp_note_encryption" version = "1.0.0" dependencies = [ + "arbitrary", "borsh", "chacha20", "chacha20poly1305", @@ -900,12 +946,13 @@ name = "masp_primitives" version = "1.0.0" dependencies = [ "aes", + "arbitrary", "assert_matches", "bip0039", "bitvec", "blake2b_simd", "blake2s_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "borsh", "byteorder", "chacha20poly1305", @@ -915,7 +962,7 @@ dependencies = [ "group", "hex", "incrementalmerkletree", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_note_encryption", "memuse", @@ -936,14 +983,14 @@ version = "1.0.0" dependencies = [ "bellman", "blake2b_simd", - "bls12_381", + "bls12_381 0.8.0 (git+https://github.com/heliaxdev/bls12_381.git?rev=d3ebe9dd6488fac1923db120a7498079e55dd838)", "byteorder", "criterion", "directories", "getrandom", "group", "itertools 0.11.0", - "jubjub", + "jubjub 0.10.0 (git+https://github.com/heliaxdev/jubjub.git?rev=e887d6964985f267a1085d480756f20d9eaceb19)", "lazy_static", "masp_primitives", "minreq", @@ -1403,7 +1450,7 @@ dependencies = [ "byteorder", "group", "hex", - "jubjub", + "jubjub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "pasta_curves", "rand_core", "serde", diff --git a/masp_note_encryption/Cargo.toml b/masp_note_encryption/Cargo.toml index 4d790ffe..8bd27006 100644 --- a/masp_note_encryption/Cargo.toml +++ b/masp_note_encryption/Cargo.toml @@ -25,11 +25,13 @@ chacha20poly1305 = { version = "0.10", default-features = false } rand_core = { version = "0.6", default-features = false } subtle = { version = "2.3", default-features = false } borsh = {version = "1.2.0", features = ["unstable__schema", "derive"]} +arbitrary = {version = "1.3", features = ["derive"], optional = true } [features] default = ["alloc"] alloc = [] pre-zip-212 = [] +arbitrary = ["dep:arbitrary"] [lib] bench = false diff --git a/masp_note_encryption/src/lib.rs b/masp_note_encryption/src/lib.rs index 24d9f4bb..135b2c52 100644 --- a/masp_note_encryption/src/lib.rs +++ b/masp_note_encryption/src/lib.rs @@ -11,7 +11,7 @@ //! [in-band secret distribution scheme]: https://zips.z.cash/protocol/protocol.pdf#saplingandorchardinband //! [`masp_primitives`]: https://github.com/anoma/masp -#![no_std] +#![cfg_attr(not(feature = "arbitrary"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] // Catch documentation errors caused by code changes. #![deny(rustdoc::broken_intra_doc_links)] @@ -75,10 +75,10 @@ impl AsRef<[u8]> for OutgoingCipherKey { &self.0 } } - /// Newtype representing the byte encoding of an [`EphemeralPublicKey`]. /// /// [`EphemeralPublicKey`]: Domain::EphemeralPublicKey +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( BorshSerialize, BorshDeserialize, diff --git a/masp_primitives/Cargo.toml b/masp_primitives/Cargo.toml index 1c696803..6ee5c051 100644 --- a/masp_primitives/Cargo.toml +++ b/masp_primitives/Cargo.toml @@ -43,11 +43,13 @@ num-traits = { version = "0.2.19", git = "https://github.com/heliaxdev/num-trait subtle = "2.2.3" # - Shielded protocols -bls12_381 = "0.8" +# branch "tomas/arbitrary" +bls12_381 = { git = "https://github.com/heliaxdev/bls12_381.git", rev = "d3ebe9dd6488fac1923db120a7498079e55dd838" } ff = "0.13" group = { version = "0.13", features = ["wnaf-memuse"] } incrementalmerkletree = "0.3" -jubjub = "0.10" +# branch "tomas/arbitrary" +jubjub = { git = "https://github.com/heliaxdev/jubjub.git", rev = "a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" } nonempty = "0.7" # - Static constants @@ -74,6 +76,8 @@ aes = "0.8" fpe = "0.6" borsh = {version = "1.2.0", features = ["unstable__schema", "derive"]} +arbitrary = {version = "1.3", features = ["derive"], optional = true } + [dependencies.masp_note_encryption] version = "1.0.0" path = "../masp_note_encryption" @@ -90,6 +94,7 @@ rand_xorshift = "0.3" transparent-inputs = [] test-dependencies = ["proptest"] default = ["transparent-inputs"] +arbitrary = ["dep:arbitrary", "masp_note_encryption/arbitrary", "bls12_381/arbitrary", "jubjub/arbitrary"] [badges] maintenance = { status = "actively-developed" } diff --git a/masp_primitives/src/asset_type.rs b/masp_primitives/src/asset_type.rs index 91de6458..4043361d 100644 --- a/masp_primitives/src/asset_type.rs +++ b/masp_primitives/src/asset_type.rs @@ -15,6 +15,7 @@ use std::{ hash::{Hash, Hasher}, }; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, BorshSerialize, BorshDeserialize, Clone, Copy, Eq, BorshSchema)] pub struct AssetType { identifier: [u8; ASSET_IDENTIFIER_LENGTH], //32 byte asset type preimage diff --git a/masp_primitives/src/consensus.rs b/masp_primitives/src/consensus.rs index bea5de0e..00edcc81 100644 --- a/masp_primitives/src/consensus.rs +++ b/masp_primitives/src/consensus.rs @@ -13,6 +13,7 @@ use std::ops::{Add, Bound, RangeBounds, Sub}; /// A wrapper type representing blockchain heights. Safe conversion from /// various integer types, as well as addition and subtraction, are provided. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[repr(transparent)] #[derive( Clone, Copy, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, @@ -244,6 +245,7 @@ pub const ZIP212_GRACE_PERIOD: u32 = 0; /// See [ZIP 200](https://zips.z.cash/zip-0200) for more details. /// /// [`signature_hash`]: crate::transaction::sighash::signature_hash +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BranchId { /// The consensus rules deployed by [`NetworkUpgrade::MASP`]. diff --git a/masp_primitives/src/merkle_tree.rs b/masp_primitives/src/merkle_tree.rs index 87e7fd25..75cd3d8f 100644 --- a/masp_primitives/src/merkle_tree.rs +++ b/masp_primitives/src/merkle_tree.rs @@ -716,6 +716,7 @@ impl BorshDeserialize for IncrementalWitness { } /// A path from a position in a particular commitment tree to the root of that tree. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Debug, PartialEq, Eq)] pub struct MerklePath { pub auth_path: Vec<(Node, bool)>, diff --git a/masp_primitives/src/sapling.rs b/masp_primitives/src/sapling.rs index 53c4fce8..1b5ee1ee 100644 --- a/masp_primitives/src/sapling.rs +++ b/masp_primitives/src/sapling.rs @@ -85,6 +85,7 @@ pub fn merkle_hash(depth: usize, lhs: &[u8; 32], rhs: &[u8; 32]) -> [u8; 32] { } /// A node within the Sapling commitment tree. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize, Default)] pub struct Node { repr: [u8; 32], @@ -450,6 +451,7 @@ impl SaplingIvk { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] @@ -624,6 +626,7 @@ impl BorshSchema for PaymentAddress { /// Before ZIP 212, the note commitment trapdoor `rcm` must be a scalar value. /// After ZIP 212, the note randomness `rseed` is a 32-byte sequence, used to derive /// both the note commitment trapdoor `rcm` and the ephemeral private key `esk`. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Copy, Clone, Debug)] pub enum Rseed { BeforeZip212(jubjub::Fr), @@ -686,6 +689,7 @@ impl BorshDeserialize for Rseed { } /// Typesafe wrapper for nullifier values. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Copy, Clone, @@ -743,6 +747,7 @@ impl From for u64 { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Debug, Copy)] pub struct Note { /// The asset type that the note represents diff --git a/masp_primitives/src/sapling/keys.rs b/masp_primitives/src/sapling/keys.rs index 0cfe59d1..c7ff4243 100644 --- a/masp_primitives/src/sapling/keys.rs +++ b/masp_primitives/src/sapling/keys.rs @@ -38,12 +38,14 @@ pub enum DecodingError { } /// An outgoing viewing key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] pub struct OutgoingViewingKey(pub [u8; 32]); /// A Sapling expanded spending key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq, Copy)] pub struct ExpandedSpendingKey { pub ask: jubjub::Fr, diff --git a/masp_primitives/src/sapling/redjubjub.rs b/masp_primitives/src/sapling/redjubjub.rs index 856a12c7..a528b687 100644 --- a/masp_primitives/src/sapling/redjubjub.rs +++ b/masp_primitives/src/sapling/redjubjub.rs @@ -38,6 +38,7 @@ fn h_star(a: &[u8], b: &[u8]) -> jubjub::Fr { hash_to_scalar(b"MASP__RedJubjubH", a, b) } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Copy, Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Hash, BorshSchema)] pub struct Signature { rbar: [u8; 32], @@ -46,6 +47,7 @@ pub struct Signature { pub struct PrivateKey(pub jubjub::Fr); +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, PartialEq, Eq, Copy)] pub struct PublicKey(pub ExtendedPoint); diff --git a/masp_primitives/src/transaction.rs b/masp_primitives/src/transaction.rs index a4cd3f70..948ca62d 100644 --- a/masp_primitives/src/transaction.rs +++ b/masp_primitives/src/transaction.rs @@ -39,6 +39,7 @@ use borsh::schema::Fields; use borsh::schema::{Declaration, Definition}; use std::ops::RangeInclusive; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, @@ -60,6 +61,7 @@ pub type GrothProofBytes = [u8; GROTH_PROOF_SIZE]; const MASPV5_TX_VERSION: u32 = 2; const MASPV5_VERSION_GROUP_ID: u32 = 0x26A7270A; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] @@ -114,6 +116,7 @@ impl TxId { /// transaction fields. Note that this is not dependent on epoch, only on transaction encoding. /// For example, if a particular epoch defines a new transaction version but also allows the /// previous version, then only the new version would be added to this enum. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum TxVersion { MASPv5, @@ -192,11 +195,27 @@ impl BorshSchema for TxVersion { /// Authorization state for a bundle of transaction data. pub trait Authorization { + #[cfg(not(feature = "arbitrary"))] type TransparentAuth: transparent::Authorization + PartialEq + BorshDeserialize + BorshSerialize; + #[cfg(not(feature = "arbitrary"))] type SaplingAuth: sapling::Authorization + PartialEq + BorshDeserialize + BorshSerialize; + + #[cfg(feature = "arbitrary")] + type TransparentAuth: transparent::Authorization + + PartialEq + + BorshDeserialize + + BorshSerialize + + for<'a> arbitrary::Arbitrary<'a>; + #[cfg(feature = "arbitrary")] + type SaplingAuth: sapling::Authorization + + PartialEq + + BorshDeserialize + + BorshSerialize + + for<'a> arbitrary::Arbitrary<'a>; } #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Unproven; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, PartialEq, Eq, Clone)] pub struct Authorized; @@ -213,6 +232,7 @@ impl Authorization for Unauthorized { } /// A MASP transaction. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone)] pub struct Transaction { txid: TxId, @@ -233,6 +253,7 @@ impl PartialEq for Transaction { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, PartialEq, Clone)] pub struct TransactionData { version: TxVersion, diff --git a/masp_primitives/src/transaction/components/amount.rs b/masp_primitives/src/transaction/components/amount.rs index 3ed1141d..f27e4fe4 100644 --- a/masp_primitives/src/transaction/components/amount.rs +++ b/masp_primitives/src/transaction/components/amount.rs @@ -50,6 +50,7 @@ pub type I128Sum = ValueSum; pub type U128Sum = ValueSum; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Default, Debug, PartialEq, Eq, Hash)] pub struct ValueSum< Unit: Hash + Ord + BorshSerialize + BorshDeserialize, diff --git a/masp_primitives/src/transaction/components/sapling.rs b/masp_primitives/src/transaction/components/sapling.rs index 61d87c2c..e1c716e7 100644 --- a/masp_primitives/src/transaction/components/sapling.rs +++ b/masp_primitives/src/transaction/components/sapling.rs @@ -35,8 +35,15 @@ pub mod builder; pub mod fees; pub trait Authorization: Debug { + #[cfg(not(feature = "arbitrary"))] type Proof: Clone + Debug + PartialEq + Hash; + #[cfg(not(feature = "arbitrary"))] type AuthSig: Clone + Debug + PartialEq; + + #[cfg(feature = "arbitrary")] + type Proof: Clone + Debug + PartialEq + Hash + for<'a> arbitrary::Arbitrary<'a>; + #[cfg(feature = "arbitrary")] + type AuthSig: Clone + Debug + PartialEq + for<'a> arbitrary::Arbitrary<'a>; } #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -47,6 +54,7 @@ impl Authorization for Unproven { type AuthSig = (); } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Copy, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema)] pub struct Authorized { pub binding_sig: redjubjub::Signature, @@ -89,6 +97,7 @@ impl MapAuth for () { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Debug, PartialEq)] pub struct Bundle { pub shielded_spends: Vec>, @@ -146,6 +155,7 @@ impl Bundle } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq)] pub struct SpendDescription { pub cv: jubjub::ExtendedPoint, @@ -299,6 +309,7 @@ impl BorshSchema for SpendDescriptionV5 { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq)] pub struct OutputDescription { pub cv: jubjub::ExtendedPoint, @@ -507,6 +518,8 @@ impl Hash for OutputDescription { self.zkproof.hash(state); } } + +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq)] pub struct ConvertDescription { pub cv: jubjub::ExtendedPoint, diff --git a/masp_primitives/src/transaction/components/sapling/builder.rs b/masp_primitives/src/transaction/components/sapling/builder.rs index 55dfc50a..d46f58bf 100644 --- a/masp_primitives/src/transaction/components/sapling/builder.rs +++ b/masp_primitives/src/transaction/components/sapling/builder.rs @@ -425,6 +425,7 @@ impl fmt::Display for Error { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, PartialEq)] pub struct SpendDescriptionInfo { extsk: Key, @@ -599,6 +600,7 @@ impl fees::OutputView for SaplingOutputInfo { } /// Metadata about a transaction created by a [`SaplingBuilder`]. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema)] pub struct SaplingMetadata { spend_indices: Vec, @@ -745,6 +747,7 @@ impl BorshDeserialize for SaplingBui } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] pub struct Unauthorized { tx_metadata: SaplingMetadata, diff --git a/masp_primitives/src/transaction/components/transparent.rs b/masp_primitives/src/transaction/components/transparent.rs index ef4758fd..bb2a2e24 100644 --- a/masp_primitives/src/transaction/components/transparent.rs +++ b/masp_primitives/src/transaction/components/transparent.rs @@ -18,9 +18,14 @@ pub mod builder; pub mod fees; pub trait Authorization: fmt::Debug { + #[cfg(not(feature = "arbitrary"))] type TransparentSig: fmt::Debug + Clone + PartialEq; + + #[cfg(feature = "arbitrary")] + type TransparentSig: fmt::Debug + Clone + PartialEq + for<'a> arbitrary::Arbitrary<'a>; } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Copy, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] pub struct Authorized; @@ -33,6 +38,7 @@ pub trait MapAuth { fn map_authorization(&self, s: A) -> B; } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, PartialEq)] pub struct Bundle { pub vin: Vec>, @@ -85,6 +91,7 @@ impl Bundle { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct TxIn { pub asset_type: AssetType, pub value: u64, @@ -162,6 +169,7 @@ impl BorshSchema for TxIn { } #[derive(Clone, Debug, Hash, PartialOrd, PartialEq, Ord, Eq)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct TxOut { pub asset_type: AssetType, pub value: u64, diff --git a/masp_primitives/src/transaction/components/transparent/builder.rs b/masp_primitives/src/transaction/components/transparent/builder.rs index 5cb1fa35..fbbddeb9 100644 --- a/masp_primitives/src/transaction/components/transparent/builder.rs +++ b/masp_primitives/src/transaction/components/transparent/builder.rs @@ -45,6 +45,7 @@ impl fees::InputView for InvalidTransparentInput { } } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[cfg(feature = "transparent-inputs")] #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema)] struct TransparentInputInfo { @@ -65,6 +66,7 @@ pub struct TransparentBuilder { vout: Vec, } +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] pub struct Unauthorized { #[cfg(feature = "transparent-inputs")] diff --git a/masp_primitives/src/zip32.rs b/masp_primitives/src/zip32.rs index c21e0961..870acb75 100644 --- a/masp_primitives/src/zip32.rs +++ b/masp_primitives/src/zip32.rs @@ -28,6 +28,7 @@ use std::io::{Read, Write}; // ZIP 32 structures /// A child index for a derived key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum ChildIndex { NonHardened(u32), @@ -81,6 +82,7 @@ impl BorshSchema for ChildIndex { } /// A BIP-32 chain code +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] diff --git a/masp_primitives/src/zip32/sapling.rs b/masp_primitives/src/zip32/sapling.rs index 83b122e7..cf2b70f8 100644 --- a/masp_primitives/src/zip32/sapling.rs +++ b/masp_primitives/src/zip32/sapling.rs @@ -143,6 +143,7 @@ impl FvkFingerprint { } /// A Sapling full viewing key tag +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] @@ -159,6 +160,7 @@ impl FvkTag { } /// A key used to derive diversifiers for a particular child key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Clone, Copy, Debug, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, BorshSchema, )] @@ -245,6 +247,7 @@ impl DiversifierKey { } /// A Sapling extended spending key +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Eq, Hash, Copy)] pub struct ExtendedSpendingKey { depth: u8, diff --git a/masp_proofs/Cargo.toml b/masp_proofs/Cargo.toml index deaa55c3..1ac3538f 100644 --- a/masp_proofs/Cargo.toml +++ b/masp_proofs/Cargo.toml @@ -20,9 +20,11 @@ masp_primitives = { version = "1.0.0", path = "../masp_primitives" } # Dependencies exposed in a public API: # (Breaking upgrades to these require a breaking upgrade to this crate.) bellman = { version = "0.14", default-features = false, features = ["groth16"] } -bls12_381 = "0.8" +# branch "tomas/arbitrary" +bls12_381 = { git = "https://github.com/heliaxdev/bls12_381.git", rev = "d3ebe9dd6488fac1923db120a7498079e55dd838" } group = "0.13" -jubjub = "0.10" +# branch "tomas/arbitrary" +jubjub = { git = "https://github.com/heliaxdev/jubjub.git", rev = "a373686962f4e9d0edb3b4716f86ff6bbd9aa86c" } lazy_static = "1" minreq = { version = "2.11.0", features = ["https"], optional = true } rand_core = "0.6"