Skip to content

Commit

Permalink
Rename PallasLookupRC(Config)
Browse files Browse the repository at this point in the history
PallasLookupRangeCheck <- PallasLookupRC
PallasLookupRangeCheckConfig <- PallasLookupRCConfig
  • Loading branch information
ConstanceBeguier committed Jul 2, 2024
1 parent 372c216 commit 1fe4680
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 82 deletions.
9 changes: 5 additions & 4 deletions halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ pub(crate) mod tests {
};
use crate::{
tests::test_utils::test_against_stored_circuit,
utilities::lookup_range_check::{LookupRangeCheck, PallasLookupRCConfig},
utilities::lookup_range_check::{LookupRangeCheck, PallasLookupRangeCheckConfig},
};

#[derive(Debug, Eq, PartialEq, Clone)]
Expand Down Expand Up @@ -732,7 +732,7 @@ pub(crate) mod tests {

#[allow(non_snake_case)]
impl Circuit<pallas::Base> for MyCircuit {
type Config = EccConfig<TestFixedBases, PallasLookupRCConfig>;
type Config = EccConfig<TestFixedBases, PallasLookupRangeCheckConfig>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
Expand Down Expand Up @@ -767,8 +767,9 @@ pub(crate) mod tests {
let constants = meta.fixed_column();
meta.enable_constant(constants);

let range_check = PallasLookupRCConfig::configure(meta, advices[9], lookup_table);
EccChip::<TestFixedBases, PallasLookupRCConfig>::configure(
let range_check =
PallasLookupRangeCheckConfig::configure(meta, advices[9], lookup_table);
EccChip::<TestFixedBases, PallasLookupRangeCheckConfig>::configure(
meta,
advices,
lagrange_coeffs,
Expand Down
20 changes: 10 additions & 10 deletions halo2_gadgets/src/ecc/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::{BaseFitsInScalarInstructions, EccInstructions, FixedPoints};
use crate::utilities::{
lookup_range_check::{PallasLookupRC, PallasLookupRCConfig},
lookup_range_check::{PallasLookupRangeCheck, PallasLookupRangeCheckConfig},
UtilitiesInstructions,
};
use arrayvec::ArrayVec;
Expand Down Expand Up @@ -139,7 +139,7 @@ impl From<NonIdentityEccPoint> for EccPoint {
#[allow(non_snake_case)]
pub struct EccConfig<
FixedPoints: super::FixedPoints<pallas::Affine>,
Lookup: PallasLookupRC = PallasLookupRCConfig,
Lookup: PallasLookupRangeCheck = PallasLookupRangeCheckConfig,
> {
/// Advice columns needed by instructions in the ECC chip.
pub advices: [Column<Advice>; 10],
Expand Down Expand Up @@ -232,13 +232,13 @@ pub trait FixedPoint<C: CurveAffine>: std::fmt::Debug + Eq + Clone {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EccChip<
FixedPoints: super::FixedPoints<pallas::Affine>,
Lookup: PallasLookupRC = PallasLookupRCConfig,
Lookup: PallasLookupRangeCheck = PallasLookupRangeCheckConfig,
> {
config: EccConfig<FixedPoints, Lookup>,
}

impl<FixedPoints: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRC> Chip<pallas::Base>
for EccChip<FixedPoints, Lookup>
impl<FixedPoints: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck>
Chip<pallas::Base> for EccChip<FixedPoints, Lookup>
{
type Config = EccConfig<FixedPoints, Lookup>;
type Loaded = ();
Expand All @@ -252,13 +252,13 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRC> Ch
}
}

impl<Fixed: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRC>
impl<Fixed: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck>
UtilitiesInstructions<pallas::Base> for EccChip<Fixed, Lookup>
{
type Var = AssignedCell<pallas::Base, pallas::Base>;
}

impl<FixedPoints: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRC>
impl<FixedPoints: super::FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck>
EccChip<FixedPoints, Lookup>
{
/// Reconstructs this chip from the given config.
Expand Down Expand Up @@ -418,8 +418,8 @@ pub enum ScalarVar {
FullWidth,
}

impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRC> EccInstructions<pallas::Affine>
for EccChip<Fixed, Lookup>
impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck>
EccInstructions<pallas::Affine> for EccChip<Fixed, Lookup>
where
<Fixed as FixedPoints<pallas::Affine>>::Base:
FixedPoint<pallas::Affine, FixedScalarKind = BaseFieldElem>,
Expand Down Expand Up @@ -606,7 +606,7 @@ where
}
}

impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRC>
impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck>
BaseFitsInScalarInstructions<pallas::Affine> for EccChip<Fixed, Lookup>
where
<Fixed as FixedPoints<pallas::Affine>>::Base:
Expand Down
10 changes: 5 additions & 5 deletions halo2_gadgets/src/ecc/chip/mul.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{add, EccPoint, NonIdentityEccPoint, ScalarVar, T_Q};
use crate::utilities::{
lookup_range_check::{PallasLookupRC, PallasLookupRCConfig},
lookup_range_check::{PallasLookupRangeCheck, PallasLookupRangeCheckConfig},
{bool_check, ternary},
};
use std::{
Expand Down Expand Up @@ -46,7 +46,7 @@ const INCOMPLETE_LO_LEN: usize = INCOMPLETE_LEN - INCOMPLETE_HI_LEN;
const COMPLETE_RANGE: Range<usize> = INCOMPLETE_LEN..(INCOMPLETE_LEN + NUM_COMPLETE_BITS);

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Config<Lookup: PallasLookupRC = PallasLookupRCConfig> {
pub struct Config<Lookup: PallasLookupRangeCheck = PallasLookupRangeCheckConfig> {
// Selector used to check switching logic on LSB
q_mul_lsb: Selector,
// Configuration used in complete addition
Expand All @@ -61,7 +61,7 @@ pub struct Config<Lookup: PallasLookupRC = PallasLookupRCConfig> {
overflow_config: overflow::Config<Lookup>,
}

impl<Lookup: PallasLookupRC> Config<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Config<Lookup> {
pub(super) fn configure(
meta: &mut ConstraintSystem<pallas::Base>,
add_config: add::Config,
Expand Down Expand Up @@ -473,10 +473,10 @@ pub mod tests {
tests::TestFixedBases,
EccInstructions, NonIdentityPoint, Point, ScalarVar,
},
utilities::{lookup_range_check::PallasLookupRC, UtilitiesInstructions},
utilities::{lookup_range_check::PallasLookupRangeCheck, UtilitiesInstructions},
};

pub(crate) fn test_mul<Lookup: PallasLookupRC>(
pub(crate) fn test_mul<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
p: &NonIdentityPoint<pallas::Affine, EccChip<TestFixedBases, Lookup>>,
Expand Down
6 changes: 3 additions & 3 deletions halo2_gadgets/src/ecc/chip/mul/overflow.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{T_Q, Z};
use crate::{
sinsemilla::primitives as sinsemilla,
utilities::lookup_range_check::{PallasLookupRC, PallasLookupRCConfig},
utilities::lookup_range_check::{PallasLookupRangeCheck, PallasLookupRangeCheckConfig},
};

use group::ff::PrimeField;
Expand All @@ -16,7 +16,7 @@ use pasta_curves::pallas;
use std::iter;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Config<Lookup: PallasLookupRC = PallasLookupRCConfig> {
pub struct Config<Lookup: PallasLookupRangeCheck = PallasLookupRangeCheckConfig> {
// Selector to check z_0 = alpha + t_q (mod p)
q_mul_overflow: Selector,
// 10-bit lookup table
Expand All @@ -25,7 +25,7 @@ pub struct Config<Lookup: PallasLookupRC = PallasLookupRCConfig> {
advices: [Column<Advice>; 3],
}

impl<Lookup: PallasLookupRC> Config<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Config<Lookup> {
pub(super) fn configure(
meta: &mut ConstraintSystem<pallas::Base>,
lookup_config: Lookup,
Expand Down
18 changes: 10 additions & 8 deletions halo2_gadgets/src/ecc/chip/mul_fixed/base_field_elem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::H_BASE;

use crate::utilities::{
bitrange_subset, bool_check,
lookup_range_check::{PallasLookupRC, PallasLookupRCConfig},
lookup_range_check::{PallasLookupRangeCheck, PallasLookupRangeCheckConfig},
range_check,
};

Expand All @@ -18,15 +18,17 @@ use pasta_curves::pallas;
use std::convert::TryInto;

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Config<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRC = PallasLookupRCConfig>
{
pub struct Config<
Fixed: FixedPoints<pallas::Affine>,
Lookup: PallasLookupRangeCheck = PallasLookupRangeCheckConfig,
> {
q_mul_fixed_base_field: Selector,
canon_advices: [Column<Advice>; 3],
lookup_config: Lookup,
super_config: super::Config<Fixed>,
}

impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRC> Config<Fixed, Lookup> {
impl<Fixed: FixedPoints<pallas::Affine>, Lookup: PallasLookupRangeCheck> Config<Fixed, Lookup> {
pub(crate) fn configure(
meta: &mut ConstraintSystem<pallas::Base>,
canon_advices: [Column<Advice>; 3],
Expand Down Expand Up @@ -389,7 +391,7 @@ pub mod tests {
use pasta_curves::pallas;
use rand::rngs::OsRng;

use crate::utilities::lookup_range_check::PallasLookupRC;
use crate::utilities::lookup_range_check::PallasLookupRangeCheck;
use crate::{
ecc::{
chip::{EccChip, FixedPoint, H},
Expand All @@ -399,7 +401,7 @@ pub mod tests {
utilities::UtilitiesInstructions,
};

pub(crate) fn test_mul_fixed_base_field<Lookup: PallasLookupRC>(
pub(crate) fn test_mul_fixed_base_field<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
) -> Result<(), Error> {
Expand All @@ -412,7 +414,7 @@ pub mod tests {
}

#[allow(clippy::op_ref)]
fn test_single_base<Lookup: PallasLookupRC>(
fn test_single_base<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
base: FixedPointBaseField<pallas::Affine, EccChip<TestFixedBases, Lookup>>,
Expand All @@ -422,7 +424,7 @@ pub mod tests {

let column = chip.config().advices[0];

fn constrain_equal_non_id<Lookup: PallasLookupRC>(
fn constrain_equal_non_id<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
base_val: pallas::Affine,
Expand Down
8 changes: 4 additions & 4 deletions halo2_gadgets/src/ecc/chip/mul_fixed/full_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ pub mod tests {
tests::{FullWidth, TestFixedBases},
FixedPoint, NonIdentityPoint, Point, ScalarFixed,
},
utilities::lookup_range_check::PallasLookupRC,
utilities::lookup_range_check::PallasLookupRangeCheck,
};

pub(crate) fn test_mul_fixed<Lookup: PallasLookupRC>(
pub(crate) fn test_mul_fixed<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
) -> Result<(), Error> {
Expand All @@ -212,13 +212,13 @@ pub mod tests {
}

#[allow(clippy::op_ref)]
fn test_single_base<Lookup: PallasLookupRC>(
fn test_single_base<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
base: FixedPoint<pallas::Affine, EccChip<TestFixedBases, Lookup>>,
base_val: pallas::Affine,
) -> Result<(), Error> {
fn constrain_equal_non_id<Lookup: PallasLookupRC>(
fn constrain_equal_non_id<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
base_val: pallas::Affine,
Expand Down
17 changes: 10 additions & 7 deletions halo2_gadgets/src/ecc/chip/mul_fixed/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,23 @@ pub mod tests {
FixedPointShort, NonIdentityPoint, Point, ScalarFixedShort,
},
utilities::{
lookup_range_check::{LookupRangeCheck, PallasLookupRC, PallasLookupRCConfig},
lookup_range_check::{
LookupRangeCheck, PallasLookupRangeCheck, PallasLookupRangeCheckConfig,
},
UtilitiesInstructions,
},
};

#[allow(clippy::op_ref)]
pub(crate) fn test_mul_fixed_short<Lookup: PallasLookupRC>(
pub(crate) fn test_mul_fixed_short<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
) -> Result<(), Error> {
// test_short
let base_val = Short.generator();
let test_short = FixedPointShort::from_inner(chip.clone(), Short);

fn load_magnitude_sign<Lookup: PallasLookupRC>(
fn load_magnitude_sign<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
magnitude: pallas::Base,
Expand All @@ -292,7 +294,7 @@ pub mod tests {
Ok((magnitude, sign))
}

fn constrain_equal_non_id<Lookup: PallasLookupRC>(
fn constrain_equal_non_id<Lookup: PallasLookupRangeCheck>(
chip: EccChip<TestFixedBases, Lookup>,
mut layouter: impl Layouter<pallas::Base>,
base_val: pallas::Affine,
Expand Down Expand Up @@ -428,7 +430,7 @@ pub mod tests {
}

impl Circuit<pallas::Base> for MyCircuit {
type Config = EccConfig<TestFixedBases, PallasLookupRCConfig>;
type Config = EccConfig<TestFixedBases, PallasLookupRangeCheckConfig>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
Expand Down Expand Up @@ -464,8 +466,9 @@ pub mod tests {
let constants = meta.fixed_column();
meta.enable_constant(constants);

let range_check = PallasLookupRCConfig::configure(meta, advices[9], lookup_table);
EccChip::<TestFixedBases, PallasLookupRCConfig>::configure(
let range_check =
PallasLookupRangeCheckConfig::configure(meta, advices[9], lookup_table);
EccChip::<TestFixedBases, PallasLookupRangeCheckConfig>::configure(
meta,
advices,
lagrange_coeffs,
Expand Down
14 changes: 7 additions & 7 deletions halo2_gadgets/src/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ pub(crate) mod tests {
},
sinsemilla::primitives::{self as sinsemilla, K},
tests::test_utils::test_against_stored_circuit,
utilities::lookup_range_check::{LookupRangeCheck, PallasLookupRCConfig},
utilities::lookup_range_check::{LookupRangeCheck, PallasLookupRangeCheckConfig},
};

use group::{ff::Field, Curve};
Expand Down Expand Up @@ -519,18 +519,18 @@ pub(crate) mod tests {
impl Circuit<pallas::Base> for MyCircuit {
#[allow(clippy::type_complexity)]
type Config = (
EccConfig<TestFixedBases, PallasLookupRCConfig>,
EccConfig<TestFixedBases, PallasLookupRangeCheckConfig>,
SinsemillaConfig<
TestHashDomain,
TestCommitDomain,
TestFixedBases,
PallasLookupRCConfig,
PallasLookupRangeCheckConfig,
>,
SinsemillaConfig<
TestHashDomain,
TestCommitDomain,
TestFixedBases,
PallasLookupRCConfig,
PallasLookupRangeCheckConfig,
>,
);
type FloorPlanner = SimpleFloorPlanner;
Expand Down Expand Up @@ -577,9 +577,9 @@ pub(crate) mod tests {
meta.lookup_table_column(),
);

let range_check = PallasLookupRCConfig::configure(meta, advices[9], table_idx);
let range_check = PallasLookupRangeCheckConfig::configure(meta, advices[9], table_idx);

let ecc_config = EccChip::<TestFixedBases, PallasLookupRCConfig>::configure(
let ecc_config = EccChip::<TestFixedBases, PallasLookupRangeCheckConfig>::configure(
meta,
advices,
lagrange_coeffs,
Expand Down Expand Up @@ -619,7 +619,7 @@ pub(crate) mod tests {
TestHashDomain,
TestCommitDomain,
TestFixedBases,
PallasLookupRCConfig,
PallasLookupRangeCheckConfig,
>::load(config.1.clone(), &mut layouter)?;

// This MerkleCRH example is purely for illustrative purposes.
Expand Down
Loading

0 comments on commit 1fe4680

Please sign in to comment.