Skip to content

Commit

Permalink
Rename MyCircuit into MyMagnitudeSignCircuit on fixed_mul/short tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstanceBeguier committed Jul 7, 2024
1 parent 714fff0 commit 70af809
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions halo2_gadgets/src/ecc/chip/mul_fixed/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,24 +471,26 @@ pub mod tests {
}

#[derive(Default)]
struct MyCircuit<Lookup: PallasLookupRangeCheck> {
struct MyMagnitudeSignCircuit<Lookup: PallasLookupRangeCheck> {
magnitude: Value<pallas::Base>,
sign: Value<pallas::Base>,
// For test checking
magnitude_error: Value<pallas::Base>,
_lookup_marker: PhantomData<Lookup>,
}

impl<Lookup: PallasLookupRangeCheck> UtilitiesInstructions<pallas::Base> for MyCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> UtilitiesInstructions<pallas::Base>
for MyMagnitudeSignCircuit<Lookup>
{
type Var = AssignedCell<pallas::Base, pallas::Base>;
}

impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MyCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MyMagnitudeSignCircuit<Lookup> {
type Config = EccConfig<TestFixedBases, Lookup>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
MyCircuit {
MyMagnitudeSignCircuit {
magnitude: Value::unknown(),
sign: Value::unknown(),
magnitude_error: Value::unknown(),
Expand Down Expand Up @@ -582,41 +584,41 @@ pub mod tests {
}
}

impl<Lookup: PallasLookupRangeCheck> MyCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> MyMagnitudeSignCircuit<Lookup> {
fn test_invalid_magnitude_sign() {
// Magnitude larger than 64 bits should fail
{
let circuits: Vec<MyCircuit<Lookup>> = vec![
let circuits: Vec<MyMagnitudeSignCircuit<Lookup>> = vec![
// 2^64
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 64)),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 1)),
_lookup_marker: PhantomData,
},
// -2^64
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 64)),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 1)),
_lookup_marker: PhantomData,
},
// 2^66
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 66)),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 3)),
_lookup_marker: PhantomData,
},
// -2^66
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 66)),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 3)),
_lookup_marker: PhantomData,
},
// 2^254
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 127).square()),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(
Expand All @@ -625,7 +627,7 @@ pub mod tests {
_lookup_marker: PhantomData,
},
// -2^254
MyCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 127).square()),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(
Expand Down Expand Up @@ -680,7 +682,7 @@ pub mod tests {
// Sign that is not +/- 1 should fail
{
let magnitude_u64 = rand::random::<u64>();
let circuit: MyCircuit<Lookup> = MyCircuit {
let circuit: MyMagnitudeSignCircuit<Lookup> = MyMagnitudeSignCircuit {
magnitude: Value::known(pallas::Base::from(magnitude_u64)),
sign: Value::known(pallas::Base::zero()),
magnitude_error: Value::unknown(),
Expand Down Expand Up @@ -743,12 +745,12 @@ pub mod tests {
#[cfg(feature = "test-dev-graph")]
#[test]
fn invalid_magnitude_sign() {
MyCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
MyMagnitudeSignCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
}

#[test]
fn invalid_magnitude_sign_4_5_b() {
MyCircuit::<PallasLookupRangeCheck45BConfig>::test_invalid_magnitude_sign();
MyMagnitudeSignCircuit::<PallasLookupRangeCheck45BConfig>::test_invalid_magnitude_sign();
}

pub(crate) fn test_mul_sign<Lookup: PallasLookupRangeCheck>(
Expand Down

0 comments on commit 70af809

Please sign in to comment.