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