hyperplonk/hyperplonk/src/lib.rs
hyperplonk/src/lib.rsRaw
1//! Main module for the HyperPlonk SNARK.
2
3use ark_ec::PairingEngine;
4use errors::HyperPlonkErrors;
5use pcs::prelude::PolynomialCommitmentScheme;
6use poly_iop::prelude::PermutationCheck;
7use witness::WitnessColumn;
8
9mod custom_gate;
10mod errors;
11mod mock;
12pub mod prelude;
13mod selectors;
14mod snark;
15mod structs;
16mod utils;
17mod witness;
18
19/// A trait for HyperPlonk SNARKs.
20/// A HyperPlonk is derived from ZeroChecks and PermutationChecks.
21pub trait HyperPlonkSNARK<E, PCS>: PermutationCheck<E, PCS>
22where
23 E: PairingEngine,
24 PCS: PolynomialCommitmentScheme<E>,
25{
26 type Index;
27 type ProvingKey;
28 type VerifyingKey;
29 type Proof;
30
31 /// Generate the preprocessed polynomials output by the indexer.
32 ///
33 /// Inputs:
34 /// - `index`: HyperPlonk index
35 /// - `pcs_srs`: Polynomial commitment structured reference string
36 /// Outputs:
37 /// - The HyperPlonk proving key, which includes the preprocessed
38 /// polynomials.
39 /// - The HyperPlonk verifying key, which includes the preprocessed
40 /// polynomial commitments
41 fn preprocess(
42 index: &Self::Index,
43 pcs_srs: &PCS::SRS,
44 ) -> Result<(Self::ProvingKey, Self::VerifyingKey), HyperPlonkErrors>;
45
46 /// Generate HyperPlonk SNARK proof.
47 ///
48 /// Inputs:
49 /// - `pk`: circuit proving key
50 /// - `pub_input`: online public input
51 /// - `witness`: witness assignment
52 /// Outputs:
53 /// - The HyperPlonk SNARK proof.
54 fn prove(
55 pk: &Self::ProvingKey,
56 pub_input: &[E::Fr],
57 witnesses: &[WitnessColumn<E::Fr>],
58 ) -> Result<Self::Proof, HyperPlonkErrors>;
59
60 /// Verify the HyperPlonk proof.
61 ///
62 /// Inputs:
63 /// - `vk`: verifying key
64 /// - `pub_input`: online public input
65 /// - `proof`: HyperPlonk SNARK proof challenges
66 /// Outputs:
67 /// - Return a boolean on whether the verification is successful
68 fn verify(
69 vk: &Self::VerifyingKey,
70 pub_input: &[E::Fr],
71 proof: &Self::Proof,
72 ) -> Result<bool, HyperPlonkErrors>;
73}