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

chore: remove V2 from type names #312

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions halo2_backend/src/plonk/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
},
};
use halo2_middleware::circuit::{
Any, ColumnMid, CompiledCircuitV2, ConstraintSystemMid, ExpressionMid, VarMid,
Any, ColumnMid, CompiledCircuit, ConstraintSystemMid, ExpressionMid, VarMid,
};
use halo2_middleware::{lookup, poly::Rotation, shuffle};
use std::collections::HashMap;
Expand All @@ -39,9 +39,9 @@ where
}

/// Generate a `VerifyingKey` from an instance of `CompiledCircuit`.
pub fn keygen_vk_v2<'params, C, P>(
pub fn keygen_vk<'params, C, P>(
params: &P,
circuit: &CompiledCircuitV2<C::Scalar>,
circuit: &CompiledCircuit<C::Scalar>,
) -> Result<VerifyingKey<C>, Error>
where
C: CurveAffine,
Expand Down Expand Up @@ -86,10 +86,10 @@ where
}

/// Generate a `ProvingKey` from a `VerifyingKey` and an instance of `CompiledCircuit`.
pub fn keygen_pk_v2<'params, C, P>(
pub fn keygen_pk<'params, C, P>(
params: &P,
vk: VerifyingKey<C>,
circuit: &CompiledCircuitV2<C::Scalar>,
circuit: &CompiledCircuit<C::Scalar>,
) -> Result<ProvingKey<C>, Error>
where
C: CurveAffine,
Expand Down
32 changes: 13 additions & 19 deletions halo2_backend/src/plonk/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::plonk::{
ProvingKey,
};
use crate::poly::{
commitment::{Blind, CommitmentScheme, Params, Prover},
commitment::{self, Blind, CommitmentScheme, Params},
Basis, Coeff, LagrangeCoeff, Polynomial, ProverQuery,
};
use crate::transcript::{EncodedChallenge, TranscriptWrite};
Expand All @@ -35,27 +35,27 @@ struct AdviceSingle<C: CurveAffine, B: Basis> {
}

/// The prover object used to create proofs interactively by passing the witnesses to commit at
/// each phase. This works for a single proof. This is a wrapper over ProverV2.
/// each phase. This works for a single proof. This is a wrapper over Prover.
#[derive(Debug)]
pub struct ProverV2Single<
pub struct ProverSingle<
'a,
'params,
Scheme: CommitmentScheme,
P: Prover<'params, Scheme>,
P: commitment::Prover<'params, Scheme>,
E: EncodedChallenge<Scheme::Curve>,
R: RngCore,
T: TranscriptWrite<Scheme::Curve, E>,
>(ProverV2<'a, 'params, Scheme, P, E, R, T>);
>(Prover<'a, 'params, Scheme, P, E, R, T>);

impl<
'a,
'params,
Scheme: CommitmentScheme,
P: Prover<'params, Scheme>,
P: commitment::Prover<'params, Scheme>,
E: EncodedChallenge<Scheme::Curve>,
R: RngCore,
T: TranscriptWrite<Scheme::Curve, E>,
> ProverV2Single<'a, 'params, Scheme, P, E, R, T>
> ProverSingle<'a, 'params, Scheme, P, E, R, T>
{
/// Create a new prover object
pub fn new(
Expand All @@ -70,13 +70,7 @@ impl<
where
Scheme::Scalar: WithSmallOrderMulGroup<3> + FromUniformBytes<64>,
{
Ok(Self(ProverV2::new(
params,
pk,
&[instance],
rng,
transcript,
)?))
Ok(Self(Prover::new(params, pk, &[instance], rng, transcript)?))
}

/// Commit the `witness` at `phase` and return the challenges after `phase`.
Expand All @@ -103,11 +97,11 @@ impl<
/// The prover object used to create proofs interactively by passing the witnesses to commit at
/// each phase. This supports batch proving.
#[derive(Debug)]
pub struct ProverV2<
pub struct Prover<
'a,
'params,
Scheme: CommitmentScheme,
P: Prover<'params, Scheme>,
P: commitment::Prover<'params, Scheme>,
E: EncodedChallenge<Scheme::Curve>,
R: RngCore,
T: TranscriptWrite<Scheme::Curve, E>,
Expand Down Expand Up @@ -137,11 +131,11 @@ impl<
'a,
'params,
Scheme: CommitmentScheme,
P: Prover<'params, Scheme>,
P: commitment::Prover<'params, Scheme>,
E: EncodedChallenge<Scheme::Curve>,
R: RngCore,
T: TranscriptWrite<Scheme::Curve, E>,
> ProverV2<'a, 'params, Scheme, P, E, R, T>
> Prover<'a, 'params, Scheme, P, E, R, T>
{
/// Create a new prover object
pub fn new(
Expand Down Expand Up @@ -259,7 +253,7 @@ impl<

let challenges = HashMap::<usize, Scheme::Scalar>::with_capacity(meta.num_challenges);

Ok(ProverV2 {
Ok(Prover {
params,
pk,
phases,
Expand Down
8 changes: 4 additions & 4 deletions halo2_frontend/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::plonk::{
Advice, Assignment, Circuit, ConstraintSystem, FirstPhase, Fixed, FloorPlanner, Instance,
SecondPhase, SelectorsToFixed, ThirdPhase,
};
use halo2_middleware::circuit::{Any, CompiledCircuitV2, PreprocessingV2};
use halo2_middleware::circuit::{Any, CompiledCircuit, Preprocessing};
use halo2_middleware::ff::{BatchInvert, Field};
use std::collections::BTreeSet;
use std::collections::HashMap;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn compile_circuit<F: Field, ConcreteCircuit: Circuit<F>>(
compress_selectors: bool,
) -> Result<
(
CompiledCircuitV2<F>,
CompiledCircuit<F>,
ConcreteCircuit::Config,
ConstraintSystem<F>,
),
Expand Down Expand Up @@ -116,15 +116,15 @@ pub fn compile_circuit<F: Field, ConcreteCircuit: Circuit<F>>(
#[cfg(feature = "thread-safe-region")]
assembly.permutation.copies.sort();

let preprocessing = PreprocessingV2 {
let preprocessing = Preprocessing {
permutation: halo2_middleware::permutation::AssemblyMid {
copies: assembly.permutation.copies,
},
fixed,
};

Ok((
CompiledCircuitV2 {
CompiledCircuit {
cs: cs.clone().into(),
preprocessing,
},
Expand Down
6 changes: 3 additions & 3 deletions halo2_middleware/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ pub struct ConstraintSystemMid<F: Field> {

/// Data that needs to be preprocessed from a circuit
#[derive(Debug, Clone)]
pub struct PreprocessingV2<F: Field> {
pub struct Preprocessing<F: Field> {
pub permutation: permutation::AssemblyMid,
pub fixed: Vec<Vec<F>>,
}

/// This is a description of a low level Plonkish compiled circuit. Contains the Constraint System
/// as well as the fixed columns and copy constraints information.
#[derive(Debug, Clone)]
pub struct CompiledCircuitV2<F: Field> {
pub preprocessing: PreprocessingV2<F>,
pub struct CompiledCircuit<F: Field> {
pub preprocessing: Preprocessing<F>,
pub cs: ConstraintSystemMid<F>,
}

Expand Down
6 changes: 3 additions & 3 deletions halo2_proofs/src/plonk/keygen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::plonk::Error;
use halo2_backend::plonk::{
keygen::{keygen_pk_v2, keygen_vk_v2},
keygen::{keygen_pk as backend_keygen_pk, keygen_vk as backend_keygen_vk},
ProvingKey, VerifyingKey,
};
use halo2_backend::{arithmetic::CurveAffine, poly::commitment::Params};
Expand Down Expand Up @@ -38,7 +38,7 @@ where
C::Scalar: FromUniformBytes<64>,
{
let (compiled_circuit, _, _) = compile_circuit(params.k(), circuit, compress_selectors)?;
let mut vk = keygen_vk_v2(params, &compiled_circuit)?;
let mut vk = backend_keygen_vk(params, &compiled_circuit)?;
vk.compress_selectors = Some(compress_selectors);
Ok(vk)
}
Expand All @@ -59,5 +59,5 @@ where
circuit,
vk.compress_selectors.unwrap_or_default(),
)?;
Ok(keygen_pk_v2(params, vk, &compiled_circuit)?)
Ok(backend_keygen_pk(params, vk, &compiled_circuit)?)
}
8 changes: 4 additions & 4 deletions halo2_proofs/src/plonk/prover.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::plonk::{Error, ErrorBack};
use crate::poly::commitment::{CommitmentScheme, Params, Prover};
use crate::poly::commitment::{self, CommitmentScheme, Params};
use crate::transcript::{EncodedChallenge, TranscriptWrite};
use halo2_backend::plonk::{prover::ProverV2, ProvingKey};
use halo2_backend::plonk::{prover::Prover, ProvingKey};
use halo2_frontend::circuit::{compile_circuit_cs, WitnessCalculator};
use halo2_frontend::plonk::Circuit;
use halo2_middleware::ff::{FromUniformBytes, WithSmallOrderMulGroup};
Expand All @@ -15,7 +15,7 @@ use std::collections::HashMap;
pub fn create_proof<
'params,
Scheme: CommitmentScheme,
P: Prover<'params, Scheme>,
P: commitment::Prover<'params, Scheme>,
E: EncodedChallenge<Scheme::Curve>,
R: RngCore,
T: TranscriptWrite<Scheme::Curve, E>,
Expand Down Expand Up @@ -44,7 +44,7 @@ where
.enumerate()
.map(|(i, circuit)| WitnessCalculator::new(params.k(), circuit, &config, &cs, instances[i]))
.collect();
let mut prover = ProverV2::<Scheme, P, _, _, _>::new(params, pk, instances, rng, transcript)?;
let mut prover = Prover::<Scheme, P, _, _, _>::new(params, pk, instances, rng, transcript)?;
let mut challenges = HashMap::new();
let phases = prover.phases().to_vec();
for phase in phases.iter() {
Expand Down
19 changes: 10 additions & 9 deletions halo2_proofs/tests/frontend_backend_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ static ALLOC: dhat::Alloc = dhat::Alloc;

use halo2_backend::{
plonk::{
keygen::{keygen_pk_v2, keygen_vk_v2},
prover::ProverV2Single,
keygen::{keygen_pk, keygen_vk},
prover::ProverSingle,
verifier::{verify_proof, verify_proof_single},
},
transcript::{
Expand Down Expand Up @@ -508,7 +508,9 @@ fn test_mycircuit_full_legacy() {
#[cfg(feature = "heap-profiling")]
let _profiler = dhat::Profiler::new_heap();

use halo2_proofs::plonk::{create_proof, keygen_pk, keygen_vk};
use halo2_proofs::plonk::{
create_proof, keygen_pk as keygen_pk_legacy, keygen_vk as keygen_vk_legacy,
};

let k = K;
let circuit: MyCircuit<Fr, WIDTH_FACTOR> = MyCircuit::new(k, 42);
Expand All @@ -518,8 +520,8 @@ fn test_mycircuit_full_legacy() {
let params = ParamsKZG::<Bn256>::setup(k, &mut rng);
let verifier_params = params.verifier_params();
let start = Instant::now();
let vk = keygen_vk(&params, &circuit).expect("keygen_vk should not fail");
let pk = keygen_pk(&params, vk.clone(), &circuit).expect("keygen_pk should not fail");
let vk = keygen_vk_legacy(&params, &circuit).expect("keygen_vk should not fail");
let pk = keygen_pk_legacy(&params, vk.clone(), &circuit).expect("keygen_pk should not fail");
println!("Keygen: {:?}", start.elapsed());

// Proving
Expand Down Expand Up @@ -574,9 +576,8 @@ fn test_mycircuit_full_split() {
let params = ParamsKZG::<Bn256>::setup(k, &mut rng);
let verifier_params = params.verifier_params();
let start = Instant::now();
let vk = keygen_vk_v2(&params, &compiled_circuit).expect("keygen_vk should not fail");
let pk =
keygen_pk_v2(&params, vk.clone(), &compiled_circuit).expect("keygen_pk should not fail");
let vk = keygen_vk(&params, &compiled_circuit).expect("keygen_vk should not fail");
let pk = keygen_pk(&params, vk.clone(), &compiled_circuit).expect("keygen_pk should not fail");
println!("Keygen: {:?}", start.elapsed());
drop(compiled_circuit);

Expand All @@ -592,7 +593,7 @@ fn test_mycircuit_full_split() {
let mut witness_calc = WitnessCalculator::new(k, &circuit, &config, &cs, instances_slice);
let mut transcript = Blake2bWrite::<_, G1Affine, Challenge255<_>>::init(vec![]);
let mut prover =
ProverV2Single::<KZGCommitmentScheme<Bn256>, ProverSHPLONK<'_, Bn256>, _, _, _>::new(
ProverSingle::<KZGCommitmentScheme<Bn256>, ProverSHPLONK<'_, Bn256>, _, _, _>::new(
&params,
&pk,
instances_slice,
Expand Down
Loading