From 6efe5586758bae6cb14db6431238622d46980543 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Wed, 21 Apr 2021 00:57:15 -0400 Subject: [PATCH] Clean up Arbitray impl for Halo2Proof --- zebra-chain/src/primitives/proofs/halo2.rs | 50 +++++----------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/zebra-chain/src/primitives/proofs/halo2.rs b/zebra-chain/src/primitives/proofs/halo2.rs index 4e90463af..0b22297ee 100644 --- a/zebra-chain/src/primitives/proofs/halo2.rs +++ b/zebra-chain/src/primitives/proofs/halo2.rs @@ -20,27 +20,6 @@ impl fmt::Debug for Halo2Proof { } } -// These impls all only exist because of array length restrictions. -// TODO: use const generics https://github.com/ZcashFoundation/zebra/issues/2042 - -// impl Copy for Halo2Proof {} - -// impl Clone for Halo2Proof { -// fn clone(&self) -> Self { -// let mut bytes = [0; 192]; -// bytes[..].copy_from_slice(&self.0[..]); -// Self(bytes) -// } -// } - -// impl PartialEq for Halo2Proof { -// fn eq(&self, other: &Self) -> bool { -// self.0[..] == other.0[..] -// } -// } - -// impl Eq for Halo2Proof {} - impl ZcashSerialize for Halo2Proof { fn zcash_serialize(&self, mut writer: W) -> Result<(), io::Error> { writer.write_all(&self.0[..])?; @@ -56,23 +35,16 @@ impl ZcashDeserialize for Halo2Proof { Ok(Self(bytes)) } } -// TODO: figure how a Halo2Proof Strategy for generating proofs for proptesting. -// #[cfg(any(test, feature = "proptest-impl"))] -// use proptest::{arbitrary::Arbitrary, collection::vec, prelude::*}; -// -// #[cfg(any(test, feature = "proptest-impl"))] -// impl Arbitrary for Halo2Proof { -// type Parameters = (); +#[cfg(any(test, feature = "proptest-impl"))] +use proptest::{arbitrary::Arbitrary, prelude::*}; -// fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { -// (vec(any::(), 192)) -// .prop_map(|v| { -// let mut bytes = [0; 192]; -// bytes.copy_from_slice(v.as_slice()); -// Self(bytes) -// }) -// .boxed() -// } +#[cfg(any(test, feature = "proptest-impl"))] +impl Arbitrary for Halo2Proof { + type Parameters = (); -// type Strategy = BoxedStrategy; -// } + fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { + (any::>()).prop_map(Self).boxed() + } + + type Strategy = BoxedStrategy; +}