Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct the pub types/fields(post frontend-backend split) #276

Merged
merged 8 commits into from
Feb 21, 2024
6 changes: 3 additions & 3 deletions halo2_backend/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::io;
pub(crate) use halo2_common::helpers::{pack, unpack, CurveRead, SerdeCurveAffine};

/// Reads a vector of polynomials from buffer
pub fn read_polynomial_vec<R: io::Read, F: SerdePrimeField, B>(
pub(crate) fn read_polynomial_vec<R: io::Read, F: SerdePrimeField, B>(
reader: &mut R,
format: SerdeFormat,
) -> io::Result<Vec<Polynomial<F, B>>> {
Expand All @@ -20,7 +20,7 @@ pub fn read_polynomial_vec<R: io::Read, F: SerdePrimeField, B>(
}

/// Writes a slice of polynomials to buffer
pub fn write_polynomial_slice<W: io::Write, F: SerdePrimeField, B>(
pub(crate) fn write_polynomial_slice<W: io::Write, F: SerdePrimeField, B>(
slice: &[Polynomial<F, B>],
writer: &mut W,
format: SerdeFormat,
Expand All @@ -33,7 +33,7 @@ pub fn write_polynomial_slice<W: io::Write, F: SerdePrimeField, B>(
}

/// Gets the total number of bytes of a slice of polynomials, assuming all polynomials are the same length
pub fn polynomial_slice_byte_length<F: PrimeField, B>(slice: &[Polynomial<F, B>]) -> usize {
pub(crate) fn polynomial_slice_byte_length<F: PrimeField, B>(slice: &[Polynomial<F, B>]) -> usize {
let field_len = F::default().to_repr().as_ref().len();
4 + slice.len() * (4 + field_len * slice.get(0).map(|poly| poly.len()).unwrap_or(0))
}
4 changes: 2 additions & 2 deletions halo2_backend/src/plonk/lookup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod prover;
pub mod verifier;
pub(crate) mod prover;
pub(crate) mod verifier;

pub use halo2_common::plonk::lookup::Argument;
2 changes: 1 addition & 1 deletion halo2_backend/src/plonk/permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<C: CurveAffine> VerifyingKey<C> {

/// The proving key for a single permutation argument.
#[derive(Clone, Debug)]
pub struct ProvingKey<C: CurveAffine> {
pub(crate) struct ProvingKey<C: CurveAffine> {
permutations: Vec<Polynomial<C::Scalar, LagrangeCoeff>>,
polys: Vec<Polynomial<C::Scalar, Coeff>>,
pub(super) cosets: Vec<Polynomial<C::Scalar, ExtendedLagrangeCoeff>>,
Expand Down
2 changes: 1 addition & 1 deletion halo2_backend/src/plonk/permutation/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) struct Committed<C: CurveAffine> {
pub(crate) sets: Vec<CommittedSet<C>>,
}

pub struct ConstructedSet<C: CurveAffine> {
pub(crate) struct ConstructedSet<C: CurveAffine> {
permutation_product_poly: Polynomial<C::Scalar, Coeff>,
permutation_product_blind: Blind<C::Scalar>,
}
Expand Down
8 changes: 4 additions & 4 deletions halo2_backend/src/plonk/permutation/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ use halo2_common::plonk::{ChallengeBeta, ChallengeGamma, ChallengeX, Error};
use halo2_middleware::circuit::Any;
use halo2_middleware::poly::Rotation;

pub struct Committed<C: CurveAffine> {
pub(crate) struct Committed<C: CurveAffine> {
permutation_product_commitments: Vec<C>,
}

pub struct EvaluatedSet<C: CurveAffine> {
pub(crate) struct EvaluatedSet<C: CurveAffine> {
permutation_product_commitment: C,
permutation_product_eval: C::Scalar,
permutation_product_next_eval: C::Scalar,
permutation_product_last_eval: Option<C::Scalar>,
}

pub struct CommonEvaluated<C: CurveAffine> {
pub(crate) struct CommonEvaluated<C: CurveAffine> {
permutation_evals: Vec<C::Scalar>,
}

pub struct Evaluated<C: CurveAffine> {
pub(crate) struct Evaluated<C: CurveAffine> {
sets: Vec<EvaluatedSet<C>>,
}

Expand Down
4 changes: 2 additions & 2 deletions halo2_backend/src/plonk/shuffle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod prover;
pub mod verifier;
pub(crate) mod prover;
pub(crate) mod verifier;

pub use halo2_common::plonk::shuffle::Argument;
4 changes: 2 additions & 2 deletions halo2_backend/src/plonk/shuffle/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use halo2_common::plonk::{ChallengeGamma, ChallengeTheta, ChallengeX, Error, Exp
use halo2_middleware::ff::Field;
use halo2_middleware::poly::Rotation;

pub struct Committed<C: CurveAffine> {
pub(crate) struct Committed<C: CurveAffine> {
product_commitment: C,
}

pub struct Evaluated<C: CurveAffine> {
pub(crate) struct Evaluated<C: CurveAffine> {
committed: Committed<C>,
product_eval: C::Scalar,
product_next_eval: C::Scalar,
Expand Down
8 changes: 6 additions & 2 deletions halo2_backend/src/poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<F, B> Polynomial<F, B> {

impl<F: SerdePrimeField, B> Polynomial<F, B> {
/// Reads polynomial from buffer using `SerdePrimeField::read`.
pub fn read<R: io::Read>(reader: &mut R, format: SerdeFormat) -> io::Result<Self> {
pub(crate) fn read<R: io::Read>(reader: &mut R, format: SerdeFormat) -> io::Result<Self> {
let mut poly_len = [0u8; 4];
reader.read_exact(&mut poly_len)?;
let poly_len = u32::from_be_bytes(poly_len);
Expand All @@ -187,7 +187,11 @@ impl<F: SerdePrimeField, B> Polynomial<F, B> {
}

/// Writes polynomial to buffer using `SerdePrimeField::write`.
pub fn write<W: io::Write>(&self, writer: &mut W, format: SerdeFormat) -> io::Result<()> {
pub(crate) fn write<W: io::Write>(
&self,
writer: &mut W,
format: SerdeFormat,
) -> io::Result<()> {
writer.write_all(&(self.values.len() as u32).to_be_bytes())?;
for value in self.values.iter() {
value.write(writer, format)?;
Expand Down
12 changes: 6 additions & 6 deletions halo2_backend/src/poly/ipa/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ use std::io;
/// Public parameters for IPA commitment scheme
#[derive(Debug, Clone)]
pub struct ParamsIPA<C: CurveAffine> {
pub k: u32,
pub n: u64,
pub g: Vec<C>,
pub g_lagrange: Vec<C>,
pub w: C,
pub u: C,
pub(crate) k: u32,
pub(crate) n: u64,
pub(crate) g: Vec<C>,
pub(crate) g_lagrange: Vec<C>,
pub(crate) w: C,
pub(crate) u: C,
}

/// Concrete IPA commitment scheme
Expand Down
2 changes: 1 addition & 1 deletion halo2_backend/src/poly/ipa/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::BTreeMap;
/// A multiscalar multiplication in the polynomial commitment scheme
#[derive(Debug, Clone)]
pub struct MSMIPA<'params, C: CurveAffine> {
pub params: &'params ParamsVerifierIPA<C>,
pub(crate) params: &'params ParamsVerifierIPA<C>,
g_scalars: Option<Vec<C::Scalar>>,
w_scalar: Option<C::Scalar>,
u_scalar: Option<C::Scalar>,
Expand Down
8 changes: 4 additions & 4 deletions halo2_backend/src/poly/ipa/multiopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ type ChallengeX4<F> = ChallengeScalar<F, X4>;

#[derive(Debug)]
struct CommitmentData<F, T: PartialEq> {
pub commitment: T,
pub set_index: usize,
pub point_indices: Vec<usize>,
pub evals: Vec<F>,
pub(crate) commitment: T,
pub(crate) set_index: usize,
pub(crate) point_indices: Vec<usize>,
pub(crate) evals: Vec<F>,
}

impl<F, T: PartialEq> CommitmentData<F, T> {
Expand Down
2 changes: 1 addition & 1 deletion halo2_backend/src/poly/ipa/multiopen/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::marker::PhantomData;
/// IPA multi-open prover
#[derive(Debug)]
pub struct ProverIPA<'params, C: CurveAffine> {
pub params: &'params ParamsIPA<C>,
pub(crate) params: &'params ParamsIPA<C>,
}

impl<'params, C: CurveAffine> Prover<'params, IPACommitmentScheme<C>> for ProverIPA<'params, C> {
Expand Down
8 changes: 4 additions & 4 deletions halo2_backend/src/poly/ipa/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ use rand_core::OsRng;
/// Wrapper for verification accumulator
#[derive(Debug, Clone)]
pub struct GuardIPA<'params, C: CurveAffine> {
pub msm: MSMIPA<'params, C>,
pub neg_c: C::Scalar,
pub u: Vec<C::Scalar>,
pub u_packed: Vec<C::Scalar>,
pub(crate) msm: MSMIPA<'params, C>,
pub(crate) neg_c: C::Scalar,
pub(crate) u: Vec<C::Scalar>,
pub(crate) u_packed: Vec<C::Scalar>,
}

/// An accumulator instance consisting of an evaluation claim and a proof.
Expand Down
12 changes: 6 additions & 6 deletions halo2_backend/src/poly/kzg/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use super::msm::MSMKZG;
/// These are the public parameters for the polynomial commitment scheme.
#[derive(Debug, Clone)]
pub struct ParamsKZG<E: Engine> {
pub k: u32,
pub n: u64,
pub g: Vec<E::G1Affine>,
pub g_lagrange: Vec<E::G1Affine>,
pub g2: E::G2Affine,
pub s_g2: E::G2Affine,
pub(crate) k: u32,
pub(crate) n: u64,
pub(crate) g: Vec<E::G1Affine>,
pub(crate) g_lagrange: Vec<E::G1Affine>,
pub(crate) g2: E::G2Affine,
pub(crate) s_g2: E::G2Affine,
}

/// Umbrella commitment scheme construction for all KZG variants
Expand Down
16 changes: 8 additions & 8 deletions halo2_backend/src/poly/kzg/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub scalars: Vec<E::Fr>,
pub bases: Vec<E::G1>,
pub(crate) scalars: Vec<E::Fr>,
pub(crate) bases: Vec<E::G1>,
}

impl<E: Engine> MSMKZG<E>
Expand Down Expand Up @@ -95,7 +95,7 @@ where

/// A projective point collector
#[derive(Debug, Clone)]
pub struct PreMSM<E: Engine>
pub(crate) struct PreMSM<E: Engine>
where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
Expand All @@ -120,7 +120,7 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub fn normalize(self) -> MSMKZG<E> {
pub(crate) fn normalize(self) -> MSMKZG<E> {
let (scalars, bases) = self
.projectives_msms
.into_iter()
Expand All @@ -133,7 +133,7 @@ where
}
}

pub fn add_msm(&mut self, other: MSMKZG<E>) {
pub(crate) fn add_msm(&mut self, other: MSMKZG<E>) {
self.projectives_msms.push(other);
}
}
Expand All @@ -155,9 +155,9 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub params: &'a ParamsKZG<E>,
pub left: MSMKZG<E>,
pub right: MSMKZG<E>,
pub(crate) params: &'a ParamsKZG<E>,
pub(crate) left: MSMKZG<E>,
pub(crate) right: MSMKZG<E>,
}

impl<'a, E: MultiMillerLoop + Debug> DualMSM<'a, E>
Expand Down
8 changes: 4 additions & 4 deletions halo2_backend/src/poly/kzg/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub msm_accumulator: DualMSM<'params, E>,
pub(crate) msm_accumulator: DualMSM<'params, E>,
}

/// Define accumulator type as `DualMSM`
Expand All @@ -45,7 +45,7 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub fn new(msm_accumulator: DualMSM<'params, E>) -> Self {
pub(crate) fn new(msm_accumulator: DualMSM<'params, E>) -> Self {
Self { msm_accumulator }
}
}
Expand All @@ -57,7 +57,7 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub msm_accumulator: DualMSM<'params, E>,
pub(crate) msm_accumulator: DualMSM<'params, E>,
}

impl<'params, E: MultiMillerLoop + Debug> AccumulatorStrategy<'params, E>
Expand Down Expand Up @@ -85,7 +85,7 @@ where
E::G1Affine: CurveAffine<ScalarExt = <E as Engine>::Fr, CurveExt = <E as Engine>::G1>,
E::G1: CurveExt<AffineExt = E::G1Affine>,
{
pub msm: DualMSM<'params, E>,
pub(crate) msm: DualMSM<'params, E>,
}

impl<'params, E: MultiMillerLoop + Debug> SingleStrategy<'params, E>
Expand Down
16 changes: 8 additions & 8 deletions halo2_backend/src/poly/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pub trait Query<F>: Sized + Clone + Send + Sync {
#[derive(Debug, Clone, Copy)]
pub struct ProverQuery<'com, C: CurveAffine> {
/// Point at which polynomial is queried
pub point: C::Scalar,
pub(crate) point: C::Scalar,
/// Coefficients of polynomial
pub poly: &'com Polynomial<C::Scalar, Coeff>,
pub(crate) poly: &'com Polynomial<C::Scalar, Coeff>,
/// Blinding factor of polynomial
pub blind: Blind<C::Scalar>,
pub(crate) blind: Blind<C::Scalar>,
}

impl<'com, C> ProverQuery<'com, C>
Expand All @@ -44,8 +44,8 @@ where
#[doc(hidden)]
#[derive(Copy, Clone)]
pub struct PolynomialPointer<'com, C: CurveAffine> {
pub poly: &'com Polynomial<C::Scalar, Coeff>,
pub blind: Blind<C::Scalar>,
pub(crate) poly: &'com Polynomial<C::Scalar, Coeff>,
pub(crate) blind: Blind<C::Scalar>,
}

impl<'com, C: CurveAffine> PartialEq for PolynomialPointer<'com, C> {
Expand Down Expand Up @@ -96,11 +96,11 @@ impl<'com, C: CurveAffine, M: MSM<C>> VerifierQuery<'com, C, M> {
#[derive(Debug, Clone, Copy)]
pub struct VerifierQuery<'com, C: CurveAffine, M: MSM<C>> {
/// Point at which polynomial is queried
pub point: C::Scalar,
pub(crate) point: C::Scalar,
/// Commitment to polynomial
pub commitment: CommitmentReference<'com, C, M>,
pub(crate) commitment: CommitmentReference<'com, C, M>,
/// Evaluation of polynomial at query point
pub eval: C::Scalar,
pub(crate) eval: C::Scalar,
}

impl<'com, C, M> VerifierQuery<'com, C, M>
Expand Down
8 changes: 4 additions & 4 deletions halo2_common/src/circuit/floor_planner/v1/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ impl PartialOrd for AllocatedRegion {
}

/// An area of empty space within a column.
pub struct EmptySpace {
pub(crate) struct EmptySpace {
// The starting position (inclusive) of the empty space.
start: usize,
// The ending position (exclusive) of the empty space, or `None` if unbounded.
end: Option<usize>,
}

impl EmptySpace {
pub fn range(&self) -> Option<Range<usize>> {
pub(crate) fn range(&self) -> Option<Range<usize>> {
self.end.map(|end| self.start..end)
}
}
Expand All @@ -51,7 +51,7 @@ pub struct Allocations(BTreeSet<AllocatedRegion>);

impl Allocations {
/// Returns the row that forms the unbounded unallocated interval [row, None).
pub fn unbounded_interval_start(&self) -> usize {
pub(crate) fn unbounded_interval_start(&self) -> usize {
self.0
.iter()
.last()
Expand All @@ -62,7 +62,7 @@ impl Allocations {
/// Return all the *unallocated* nonempty intervals intersecting [start, end).
///
/// `end = None` represents an unbounded end.
pub fn free_intervals(
pub(crate) fn free_intervals(
&self,
start: usize,
end: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion halo2_common/src/circuit/table_layouter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'r, 'a, F: Field, CS: Assignment<F> + 'a> TableLayouter<F>
}
}

pub fn compute_table_lengths<F: Debug>(
pub(crate) fn compute_table_lengths<F: Debug>(
default_and_assigned: &HashMap<TableColumn, (DefaultTableValue<F>, Vec<bool>)>,
) -> Result<usize, Error> {
let column_lengths: Result<Vec<_>, Error> = default_and_assigned
Expand Down
Loading
Loading