Impl Arbitrary for JoinSplitData<P>
Wraps the construction of ed25519 PublicKeyBytes and Signature so we don't need an explicit impl for ed25519 types.
This commit is contained in:
parent
7e34a543ff
commit
7632863454
|
|
@ -64,7 +64,6 @@ pub struct JoinSplit<P: ZkSnarkProof> {
|
||||||
|
|
||||||
/// A bundle of JoinSplit descriptions and signature data.
|
/// A bundle of JoinSplit descriptions and signature data.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
#[cfg_attr(test, derive(Arbitrary))]
|
|
||||||
pub struct JoinSplitData<P: ZkSnarkProof> {
|
pub struct JoinSplitData<P: ZkSnarkProof> {
|
||||||
/// The first JoinSplit description, using proofs of type `P`.
|
/// The first JoinSplit description, using proofs of type `P`.
|
||||||
///
|
///
|
||||||
|
|
@ -93,6 +92,31 @@ impl<P: ZkSnarkProof> JoinSplitData<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl<P: ZkSnarkProof> Arbitrary for JoinSplitData<P> {
|
||||||
|
type Parameters = ();
|
||||||
|
|
||||||
|
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
|
||||||
|
(
|
||||||
|
any::<JoinSplit<P>>(),
|
||||||
|
vec(any::<JoinSplit<P>>()),
|
||||||
|
vec(any::<u8>(), 32),
|
||||||
|
vec(any::<u8>(), 64),
|
||||||
|
)
|
||||||
|
.prop_map(|first, rest, pub_key_bytes, sig_bytes| {
|
||||||
|
return Self {
|
||||||
|
first: first,
|
||||||
|
rest: rest,
|
||||||
|
pub_key: ed25519_zebra::PublicKeyBytes::from(pub_key_bytes),
|
||||||
|
sig: ed25519_zebra::Signature::from(sig_bytes),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.boxed()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Strategy = BoxedStrategy<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
/// A ciphertext component for encrypted output notes.
|
/// A ciphertext component for encrypted output notes.
|
||||||
pub struct EncryptedCiphertext(pub [u8; 601]);
|
pub struct EncryptedCiphertext(pub [u8; 601]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue