From fd80a62776d82bc42f03ec8e8628d90533d23a07 Mon Sep 17 00:00:00 2001 From: Eduard S Date: Mon, 22 Jan 2024 16:03:06 +0000 Subject: [PATCH] Checkpoint --- backend/src/lib.rs | 3 +++ backend/src/plonk/prover.rs | 18 ++++++++---------- common/src/lib.rs | 6 ++++-- common/src/plonk.rs | 38 ++++++++++++++++++------------------- common/src/plonk/circuit.rs | 2 +- common/src/plonk/lookup.rs | 4 ++-- common/src/poly.rs | 2 +- 7 files changed, 38 insertions(+), 35 deletions(-) diff --git a/backend/src/lib.rs b/backend/src/lib.rs index c3120151..904a19c0 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -1 +1,4 @@ +#![allow(dead_code)] // TODO: Remove +#![allow(unused_imports)] // TODO: Remove + pub mod plonk; diff --git a/backend/src/plonk/prover.rs b/backend/src/plonk/prover.rs index d99c79c5..3ae9b1f6 100644 --- a/backend/src/plonk/prover.rs +++ b/backend/src/plonk/prover.rs @@ -2,21 +2,17 @@ use group::Curve; use halo2_middleware::ff::{Field, FromUniformBytes, WithSmallOrderMulGroup}; use rand_core::RngCore; use std::collections::{BTreeSet, HashSet}; -use std::ops::RangeTo; use std::{collections::HashMap, iter}; -use super::{ - circuit::{ - compile_circuit, - sealed::{self}, - Assignment, Circuit, Selector, WitnessCalculator, - }, +use halo2_common::plonk::{ + circuit::{sealed, Assignment, Circuit, Selector}, lookup, permutation, shuffle, vanishing, ChallengeBeta, ChallengeGamma, ChallengeTheta, ChallengeX, ChallengeY, Error, ProvingKey, }; use halo2_middleware::circuit::{Advice, Any, Challenge, Column, Fixed, Instance}; -use crate::{ +use group::prime::PrimeCurveAffine; +use halo2_common::{ arithmetic::{eval_polynomial, CurveAffine}, circuit::Value, plonk::Assigned, @@ -25,11 +21,10 @@ use crate::{ Basis, Coeff, LagrangeCoeff, Polynomial, ProverQuery, }, }; -use crate::{ +use halo2_common::{ poly::batch_invert_assigned, transcript::{EncodedChallenge, TranscriptWrite}, }; -use group::prime::PrimeCurveAffine; /// Collection of instance data used during proving for a single circuit proof. #[derive(Debug)] @@ -742,6 +737,8 @@ impl< } } +// TODO: Move this to halo2_proofs as a legacy wrapper +/* /// This creates a proof for the provided `circuit` when given the public /// parameters `params` and the proving key [`ProvingKey`] that was /// generated previously for the same circuit. The provided `instances` @@ -853,3 +850,4 @@ fn test_create_proof() { ) .expect("proof generation should not fail"); } +*/ diff --git a/common/src/lib.rs b/common/src/lib.rs index acc26aff..832d3ee8 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,11 +1,13 @@ //! # halo2_proofs +#![allow(dead_code)] // TODO: Remove +#![allow(unused_imports)] // TODO: Remove #![cfg_attr(docsrs, feature(doc_cfg))] // The actual lints we want to disable. #![allow(clippy::op_ref, clippy::many_single_char_names)] #![deny(rustdoc::broken_intra_doc_links)] -#![deny(missing_debug_implementations)] -#![deny(missing_docs)] +// #![deny(missing_debug_implementations)] // TODO: Uncomment +// #![deny(missing_docs)] // TODO: Uncomment #![deny(unsafe_code)] pub mod arithmetic; diff --git a/common/src/plonk.rs b/common/src/plonk.rs index 7a072cd2..f7bcd4c6 100644 --- a/common/src/plonk.rs +++ b/common/src/plonk.rs @@ -25,17 +25,17 @@ use halo2_middleware::circuit::{ }; use halo2_middleware::poly::Rotation; -mod assigned; -mod circuit; -mod error; -mod evaluation; -mod keygen; -mod lookup; +pub mod assigned; +pub mod circuit; +pub mod error; +pub mod evaluation; +pub mod keygen; +pub mod lookup; pub mod permutation; -mod shuffle; -mod vanishing; +pub mod shuffle; +pub mod vanishing; -mod verifier; +pub mod verifier; pub use assigned::*; pub use circuit::*; @@ -532,21 +532,21 @@ impl VerifyingKey { } #[derive(Clone, Copy, Debug)] -struct Theta; -type ChallengeTheta = ChallengeScalar; +pub struct Theta; +pub type ChallengeTheta = ChallengeScalar; #[derive(Clone, Copy, Debug)] -struct Beta; -type ChallengeBeta = ChallengeScalar; +pub struct Beta; +pub type ChallengeBeta = ChallengeScalar; #[derive(Clone, Copy, Debug)] -struct Gamma; -type ChallengeGamma = ChallengeScalar; +pub struct Gamma; +pub type ChallengeGamma = ChallengeScalar; #[derive(Clone, Copy, Debug)] -struct Y; -type ChallengeY = ChallengeScalar; +pub struct Y; +pub type ChallengeY = ChallengeScalar; #[derive(Clone, Copy, Debug)] -struct X; -type ChallengeX = ChallengeScalar; +pub struct X; +pub type ChallengeX = ChallengeScalar; diff --git a/common/src/plonk/circuit.rs b/common/src/plonk/circuit.rs index a5b0365a..c0b18bf5 100644 --- a/common/src/plonk/circuit.rs +++ b/common/src/plonk/circuit.rs @@ -28,7 +28,7 @@ use std::{ mod compress_selectors; // TODO: Move sealed phase to frontend, and always use u8 in middleware and backend -pub(crate) mod sealed { +pub mod sealed { /// Phase of advice column #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct Phase(pub(crate) u8); diff --git a/common/src/plonk/lookup.rs b/common/src/plonk/lookup.rs index 80ecd082..34426a29 100644 --- a/common/src/plonk/lookup.rs +++ b/common/src/plonk/lookup.rs @@ -3,8 +3,8 @@ use halo2_middleware::circuit::ExpressionMid; use halo2_middleware::ff::Field; use std::fmt::{self, Debug}; -pub(crate) mod prover; -pub(crate) mod verifier; +pub mod prover; +pub mod verifier; /// Expressions involved in a lookup argument, with a name as metadata. #[derive(Clone)] diff --git a/common/src/poly.rs b/common/src/poly.rs index 100ee10e..9fe12b5d 100644 --- a/common/src/poly.rs +++ b/common/src/poly.rs @@ -197,7 +197,7 @@ impl Polynomial { } } -pub(crate) fn batch_invert_assigned( +pub fn batch_invert_assigned( assigned: Vec, LagrangeCoeff>>, ) -> Vec> { let mut assigned_denominators: Vec<_> = assigned