Skip to content

Commit

Permalink
remove pub(crate) in ecc
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed May 13, 2024
1 parent 7e50d0b commit 58f8b3f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<C: CurveAffine, EccChip: EccInstructions<C>> ScalarFixed<C, EccChip> {
#[derive(Debug)]
pub struct ScalarFixedShort<C: CurveAffine, EccChip: EccInstructions<C>> {
chip: EccChip,
pub(crate) inner: EccChip::ScalarFixedShort,
inner: EccChip::ScalarFixedShort,
}

impl<C: CurveAffine, EccChip: EccInstructions<C>> ScalarFixedShort<C, EccChip> {
Expand Down Expand Up @@ -375,8 +375,8 @@ impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq>
/// A point on a specific elliptic curve.
#[derive(Copy, Clone, Debug)]
pub struct Point<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> {
pub(crate) chip: EccChip,
pub(crate) inner: EccChip::Point,
chip: EccChip,
inner: EccChip::Point,
}

impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> Point<C, EccChip> {
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 @@ -14,12 +14,12 @@ use pasta_curves::{arithmetic::CurveAffine, pallas};

use std::convert::TryInto;

pub(crate) mod add;
pub(crate) mod add_incomplete;
pub(super) mod add;
pub(super) mod add_incomplete;
pub mod constants;
pub(crate) mod mul;
pub(crate) mod mul_fixed;
pub(crate) mod witness_point;
pub(super) mod mul;
pub(super) mod mul_fixed;
pub(super) mod witness_point;

pub use constants::*;

Expand All @@ -34,11 +34,11 @@ pub struct EccPoint {
/// x-coordinate
///
/// Stored as an `Assigned<F>` to enable batching inversions.
pub(crate) x: AssignedCell<Assigned<pallas::Base>, pallas::Base>,
x: AssignedCell<Assigned<pallas::Base>, pallas::Base>,
/// y-coordinate
///
/// Stored as an `Assigned<F>` to enable batching inversions.
pub(crate) y: AssignedCell<Assigned<pallas::Base>, pallas::Base>,
y: AssignedCell<Assigned<pallas::Base>, pallas::Base>,
}

impl EccPoint {
Expand Down Expand Up @@ -153,12 +153,12 @@ pub struct EccConfig<
/// Fixed-base full-width scalar multiplication
mul_fixed_full: mul_fixed::full_width::Config<FixedPoints>,
/// Fixed-base signed short scalar multiplication
pub(crate) mul_fixed_short: mul_fixed::short::Config<FixedPoints>,
mul_fixed_short: mul_fixed::short::Config<FixedPoints>,
/// Fixed-base mul using a base field element as a scalar
mul_fixed_base_field: mul_fixed::base_field_elem::Config<FixedPoints, Lookup>,

/// Witness point
pub(crate) witness_point: witness_point::Config,
witness_point: witness_point::Config,

/// Lookup range check using 10-bit lookup table
pub lookup_config: Lookup,
Expand Down Expand Up @@ -345,7 +345,7 @@ pub struct EccScalarFixed {
type MagnitudeCell = AssignedCell<pallas::Base, pallas::Base>;
// TODO: Make V an enum Sign { Positive, Negative }
type SignCell = AssignedCell<pallas::Base, pallas::Base>;
pub(crate) type MagnitudeSign = (MagnitudeCell, SignCell);
type MagnitudeSign = (MagnitudeCell, SignCell);

/// A signed short scalar used for fixed-base scalar multiplication.
/// A short scalar must have magnitude in the range [0..2^64), with
Expand Down
5 changes: 3 additions & 2 deletions halo2_gadgets/src/ecc/chip/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct Config<Lookup: DefaultLookupRangeCheck> {
}

impl<Lookup: DefaultLookupRangeCheck> Config<Lookup> {
pub(crate) fn configure(
pub(super) fn configure(
meta: &mut ConstraintSystem<pallas::Base>,
add_config: add::Config,
lookup_config: Lookup,
Expand Down Expand Up @@ -460,6 +460,7 @@ pub mod tests {
ff::{Field, PrimeField},
Curve,
};
use halo2_proofs::circuit::Chip;
use halo2_proofs::{
circuit::{Layouter, Value},
plonk::Error,
Expand All @@ -483,7 +484,7 @@ pub mod tests {
p: &NonIdentityPoint<pallas::Affine, EccChip<TestFixedBases, Lookup>>,
p_val: pallas::Affine,
) -> Result<(), Error> {
let column = chip.config.advices[0];
let column = chip.config().advices[0];

fn constrain_equal_non_id<
EccChip: EccInstructions<pallas::Affine, Point = EccPoint> + Clone + Eq + std::fmt::Debug,
Expand Down
6 changes: 3 additions & 3 deletions halo2_gadgets/src/ecc/chip/mul_fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ pub struct Config<FixedPoints: super::FixedPoints<pallas::Affine>> {
fixed_z: Column<Fixed>,
// Decomposition of an `n-1`-bit scalar into `k`-bit windows:
// a = a_0 + 2^k(a_1) + 2^{2k}(a_2) + ... + 2^{(n-1)k}(a_{n-1})
pub(crate) window: Column<Advice>,
window: Column<Advice>,
// y-coordinate of accumulator (only used in the final row).
pub(crate) u: Column<Advice>,
u: Column<Advice>,
// Configuration for `add`
pub(crate) add_config: add::Config,
add_config: add::Config,
// Configuration for `add_incomplete`
add_incomplete_config: add_incomplete::Config,
_marker: PhantomData<FixedPoints>,
Expand Down
6 changes: 2 additions & 4 deletions halo2_gadgets/src/ecc/chip/mul_fixed/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use pasta_curves::pallas;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Config<Fixed: FixedPoints<pallas::Affine>> {
// Selector used for fixed-base scalar mul with short signed exponent.
pub(crate) q_mul_fixed_short: Selector,
pub(crate) super_config: super::Config<Fixed>,
q_mul_fixed_short: Selector,
super_config: super::Config<Fixed>,
}

impl<Fixed: FixedPoints<pallas::Affine>> Config<Fixed> {
Expand Down Expand Up @@ -401,8 +401,6 @@ pub mod tests {
Ok(())
}

// todo: fixit

#[test]
fn invalid_magnitude_sign() {
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions halo2_gadgets/src/ecc/chip/witness_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use halo2_proofs::{
};
use pasta_curves::{arithmetic::CurveAffine, pallas};

pub(crate) type Coordinates = (
type Coordinates = (
AssignedCell<Assigned<pallas::Base>, pallas::Base>,
AssignedCell<Assigned<pallas::Base>, pallas::Base>,
);

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Config {
pub(crate) q_point: Selector,
q_point: Selector,
q_point_non_id: Selector,
// x-coordinate
pub x: Column<Advice>,
Expand Down

0 comments on commit 58f8b3f

Please sign in to comment.