Skip to main content

commonware_cryptography/zk/bulletproofs/
mod.rs

1pub mod circuit;
2pub mod ipa;
3
4#[cfg(feature = "fuzz")]
5pub mod fuzz {
6    use arbitrary::{Arbitrary, Unstructured};
7
8    pub enum Plan {
9        Ipa(crate::zk::bulletproofs::ipa::fuzz::Plan),
10        Circuit(crate::zk::bulletproofs::circuit::fuzz::Plan),
11    }
12
13    impl<'a> Arbitrary<'a> for Plan {
14        fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
15            match u.int_in_range(0..=1)? {
16                0 => Ok(Self::Ipa(u.arbitrary()?)),
17                1 => Ok(Self::Circuit(u.arbitrary()?)),
18                _ => unreachable!("plan variant out of range"),
19            }
20        }
21    }
22
23    impl Plan {
24        pub(in crate::zk) fn run(self, u: &mut Unstructured<'_>) -> arbitrary::Result<()> {
25            match self {
26                Self::Ipa(plan) => plan.run(u),
27                Self::Circuit(plan) => plan.run(u),
28            }
29        }
30    }
31}