Skip to content

Commit

Permalink
Update: make structs and fields related to proof generation public (#73)
Browse files Browse the repository at this point in the history
* Update: make all the fields in `ProvingKey` public

* Update: make more necessary structs/fields public

* Fix: format doc
  • Loading branch information
winderica authored Jun 22, 2022
1 parent 08f24d4 commit d3d9532
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion plonk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod testing_apis;
pub mod prelude {
pub use crate::{
circuit::{Arithmetization, Circuit, PlonkCircuit},
errors::PlonkError,
errors::{PlonkError, SnarkError},
proof_system::{structs::*, PlonkKzgSnark, Snark},
transcript::{PlonkTranscript, StandardTranscript},
};
Expand Down
46 changes: 24 additions & 22 deletions plonk/src/proof_system/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ impl<E: PairingEngine> UniversalSrs<E> {
}
}

pub(crate) type CommitKey<'a, E> = Powers<'a, E>;
/// Key for committing to and creating evaluation proofs
/// (alias to kzg10::Powers).
pub type CommitKey<'a, E> = Powers<'a, E>;

/// Key for verifying PCS opening proof (alias to kzg10::VerifierKey).
pub type OpenKey<E> = VerifierKey<E>;
Expand All @@ -48,23 +50,23 @@ pub type OpenKey<E> = VerifierKey<E>;
#[derivative(Hash(bound = "E:PairingEngine"))]
pub struct Proof<E: PairingEngine> {
/// Wire witness polynomials commitments.
pub(crate) wires_poly_comms: Vec<Commitment<E>>,
pub wires_poly_comms: Vec<Commitment<E>>,

/// The polynomial commitment for the wire permutation argument.
pub(crate) prod_perm_poly_comm: Commitment<E>,
pub prod_perm_poly_comm: Commitment<E>,

/// Splitted quotient polynomial commitments.
pub(crate) split_quot_poly_comms: Vec<Commitment<E>>,
pub split_quot_poly_comms: Vec<Commitment<E>>,

/// (Aggregated) proof of evaluations at challenge point `zeta`.
pub(crate) opening_proof: Commitment<E>,
pub opening_proof: Commitment<E>,

/// (Aggregated) proof of evaluation at challenge point `zeta * g` where `g`
/// is the root of unity.
pub(crate) shifted_opening_proof: Commitment<E>,
pub shifted_opening_proof: Commitment<E>,

/// Polynomial evaluations.
pub(crate) poly_evals: ProofEvaluations<E::Fr>,
pub poly_evals: ProofEvaluations<E::Fr>,
}

impl<E, P> TryFrom<Vec<E::Fq>> for Proof<E>
Expand Down Expand Up @@ -260,14 +262,14 @@ impl<E: PairingEngine> From<Proof<E>> for BatchProof<E> {
#[derive(Debug, Clone, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub struct ProofEvaluations<F: Field> {
/// Wire witness polynomials evaluations at point `zeta`.
pub(crate) wires_evals: Vec<F>,
pub wires_evals: Vec<F>,

/// Extended permutation (sigma) polynomials evaluations at point `zeta`.
/// We do not include the last sigma polynomial evaluation.
pub(crate) wire_sigma_evals: Vec<F>,
pub wire_sigma_evals: Vec<F>,

/// Permutation product polynomial evaluation at point `zeta * g`.
pub(crate) perm_next_eval: F,
pub perm_next_eval: F,
}

impl<F: Field> TryFrom<Vec<F>> for ProofEvaluations<F> {
Expand Down Expand Up @@ -328,30 +330,30 @@ where
#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct ProvingKey<'a, E: PairingEngine> {
/// Extended permutation (sigma) polynomials.
pub(crate) sigmas: Vec<DensePolynomial<E::Fr>>,
pub sigmas: Vec<DensePolynomial<E::Fr>>,

/// Selector polynomials.
pub(crate) selectors: Vec<DensePolynomial<E::Fr>>,
pub selectors: Vec<DensePolynomial<E::Fr>>,

// KZG PCS committing key.
pub(crate) commit_key: CommitKey<'a, E>,
/// KZG PCS committing key.
pub commit_key: CommitKey<'a, E>,

/// The verifying key. It is used by prover to initialize transcripts.
pub vk: VerifyingKey<E>,
}

impl<'a, E: PairingEngine> ProvingKey<'a, E> {
/// The size of the evaluation domain. Should be a power of two.
pub(crate) fn domain_size(&self) -> usize {
pub fn domain_size(&self) -> usize {
self.vk.domain_size
}
/// The number of public inputs.
#[allow(dead_code)]
pub(crate) fn num_inputs(&self) -> usize {
pub fn num_inputs(&self) -> usize {
self.vk.num_inputs
}
/// The constants K0, ..., K4 that ensure wire subsets are disjoint.
pub(crate) fn k(&self) -> &[E::Fr] {
pub fn k(&self) -> &[E::Fr] {
&self.vk.k
}
}
Expand All @@ -361,20 +363,20 @@ impl<'a, E: PairingEngine> ProvingKey<'a, E> {
#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifyingKey<E: PairingEngine> {
/// The size of the evaluation domain. Should be a power of two.
pub(crate) domain_size: usize,
pub domain_size: usize,

/// The number of public inputs.
pub(crate) num_inputs: usize,
pub num_inputs: usize,

/// The permutation polynomial commitments. The commitments are not hiding.
pub(crate) sigma_comms: Vec<Commitment<E>>,
pub sigma_comms: Vec<Commitment<E>>,

/// The selector polynomial commitments. The commitments are not hiding.
pub(crate) selector_comms: Vec<Commitment<E>>,
pub selector_comms: Vec<Commitment<E>>,

/// The constants K0, ..., K_num_wire_types that ensure wire subsets are
/// disjoint.
pub(crate) k: Vec<E::Fr>,
pub k: Vec<E::Fr>,

/// KZG PCS opening key.
pub open_key: OpenKey<E>,
Expand Down

0 comments on commit d3d9532

Please sign in to comment.