zebra_chain/sprout/
arbitrary.rs
1use proptest::{array, prelude::*};
2
3use crate::{
4 amount::{Amount, NonNegative},
5 primitives::ZkSnarkProof,
6};
7
8use super::{commitment, joinsplit, note, tree, JoinSplit};
9
10impl<P: ZkSnarkProof + Arbitrary + 'static> Arbitrary for JoinSplit<P> {
11 type Parameters = ();
12
13 fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
14 (
15 any::<Amount<NonNegative>>(),
16 any::<Amount<NonNegative>>(),
17 any::<tree::Root>(),
18 array::uniform2(any::<note::Nullifier>()),
19 array::uniform2(any::<commitment::NoteCommitment>()),
20 array::uniform32(any::<u8>()),
21 any::<joinsplit::RandomSeed>(),
22 array::uniform2(any::<note::Mac>()),
23 any::<P>(),
24 array::uniform2(any::<note::EncryptedNote>()),
25 )
26 .prop_map(
27 |(
28 vpub_old,
29 vpub_new,
30 anchor,
31 nullifiers,
32 commitments,
33 ephemeral_key_bytes,
34 random_seed,
35 vmacs,
36 zkproof,
37 enc_ciphertexts,
38 )| {
39 Self {
40 vpub_old,
41 vpub_new,
42 anchor,
43 nullifiers,
44 commitments,
45 ephemeral_key: x25519_dalek::PublicKey::from(ephemeral_key_bytes),
46 random_seed,
47 vmacs,
48 zkproof,
49 enc_ciphertexts,
50 }
51 },
52 )
53 .boxed()
54 }
55
56 type Strategy = BoxedStrategy<Self>;
57}