mirror of https://github.com/zcash/orchard.git
mul_fixed_*::tests: Constrain zero outputs in mul_fixed tests.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
parent
9fd4d7df27
commit
d550e156d9
|
@ -544,6 +544,7 @@ mod tests {
|
|||
super::chip::mul_fixed::full_width::tests::test_mul_fixed(
|
||||
chip.clone(),
|
||||
layouter.namespace(|| "full-width fixed-base scalar mul"),
|
||||
&zero,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
@ -552,6 +553,7 @@ mod tests {
|
|||
super::chip::mul_fixed::short::tests::test_mul_fixed_short(
|
||||
chip.clone(),
|
||||
layouter.namespace(|| "signed short fixed-base scalar mul"),
|
||||
&zero,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
@ -560,6 +562,7 @@ mod tests {
|
|||
super::chip::mul_fixed::base_field_elem::tests::test_mul_fixed_base_field(
|
||||
chip,
|
||||
layouter.namespace(|| "fixed-base scalar mul with base field element"),
|
||||
&zero,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ pub mod tests {
|
|||
use crate::circuit::gadget::{
|
||||
ecc::{
|
||||
chip::{EccChip, OrchardFixedBasesFull},
|
||||
FixedPoint,
|
||||
FixedPoint, Point,
|
||||
},
|
||||
utilities::{CellValue, UtilitiesInstructions},
|
||||
};
|
||||
|
@ -257,6 +257,7 @@ pub mod tests {
|
|||
pub fn test_mul_fixed_base_field(
|
||||
chip: EccChip,
|
||||
mut layouter: impl Layouter<pallas::Base>,
|
||||
zero: &Point<pallas::Affine, EccChip>,
|
||||
) -> Result<(), Error> {
|
||||
impl UtilitiesInstructions<pallas::Base> for EccChip {
|
||||
type Var = CellValue<pallas::Base>;
|
||||
|
@ -269,6 +270,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "commit_ivk_r"),
|
||||
commit_ivk_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// note_commit_r
|
||||
|
@ -278,6 +280,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "note_commit_r"),
|
||||
note_commit_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// nullifier_k
|
||||
|
@ -287,6 +290,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "nullifier_k"),
|
||||
nullifier_k,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// value_commit_r
|
||||
|
@ -296,12 +300,18 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "value_commit_r"),
|
||||
value_commit_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// spend_auth_g
|
||||
let spend_auth_g = OrchardFixedBasesFull::SpendAuthG;
|
||||
let spend_auth_g = FixedPoint::from_inner(chip.clone(), spend_auth_g);
|
||||
test_single_base(chip, layouter.namespace(|| "spend_auth_g"), spend_auth_g)?;
|
||||
test_single_base(
|
||||
chip,
|
||||
layouter.namespace(|| "spend_auth_g"),
|
||||
spend_auth_g,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -311,6 +321,7 @@ pub mod tests {
|
|||
chip: EccChip,
|
||||
mut layouter: impl Layouter<pallas::Base>,
|
||||
base: FixedPoint<pallas::Affine, EccChip>,
|
||||
zero: &Point<pallas::Affine, EccChip>,
|
||||
) -> Result<(), Error> {
|
||||
let column = chip.config().advices[0];
|
||||
|
||||
|
@ -356,7 +367,9 @@ pub mod tests {
|
|||
column,
|
||||
Some(scalar_fixed),
|
||||
)?;
|
||||
base.mul_base_field_elem(layouter.namespace(|| "mul by zero"), scalar_fixed)?;
|
||||
let result =
|
||||
base.mul_base_field_elem(layouter.namespace(|| "mul by zero"), scalar_fixed)?;
|
||||
result.constrain_equal(layouter.namespace(|| "[0]B = 𝒪"), &zero)?;
|
||||
}
|
||||
|
||||
// [-1]B is the largest base field element
|
||||
|
|
|
@ -62,13 +62,14 @@ pub mod tests {
|
|||
|
||||
use crate::circuit::gadget::ecc::{
|
||||
chip::{EccChip, OrchardFixedBasesFull},
|
||||
FixedPoint, ScalarFixed,
|
||||
FixedPoint, Point, ScalarFixed,
|
||||
};
|
||||
use crate::constants;
|
||||
|
||||
pub fn test_mul_fixed(
|
||||
chip: EccChip,
|
||||
mut layouter: impl Layouter<pallas::Base>,
|
||||
zero: &Point<pallas::Affine, EccChip>,
|
||||
) -> Result<(), Error> {
|
||||
// commit_ivk_r
|
||||
let commit_ivk_r = OrchardFixedBasesFull::CommitIvkR;
|
||||
|
@ -77,6 +78,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "commit_ivk_r"),
|
||||
commit_ivk_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// note_commit_r
|
||||
|
@ -86,6 +88,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "note_commit_r"),
|
||||
note_commit_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// nullifier_k
|
||||
|
@ -95,6 +98,7 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "nullifier_k"),
|
||||
nullifier_k,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// value_commit_r
|
||||
|
@ -104,12 +108,18 @@ pub mod tests {
|
|||
chip.clone(),
|
||||
layouter.namespace(|| "value_commit_r"),
|
||||
value_commit_r,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
// spend_auth_g
|
||||
let spend_auth_g = OrchardFixedBasesFull::SpendAuthG;
|
||||
let spend_auth_g = FixedPoint::from_inner(chip.clone(), spend_auth_g);
|
||||
test_single_base(chip, layouter.namespace(|| "spend_auth_g"), spend_auth_g)?;
|
||||
test_single_base(
|
||||
chip,
|
||||
layouter.namespace(|| "spend_auth_g"),
|
||||
spend_auth_g,
|
||||
&zero,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -119,6 +129,7 @@ pub mod tests {
|
|||
chip: EccChip,
|
||||
mut layouter: impl Layouter<pallas::Base>,
|
||||
base: FixedPoint<pallas::Affine, EccChip>,
|
||||
zero: &Point<pallas::Affine, EccChip>,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
pallas::Scalar: PrimeFieldBits,
|
||||
|
@ -166,7 +177,8 @@ pub mod tests {
|
|||
layouter.namespace(|| "ScalarFixed"),
|
||||
Some(scalar_fixed),
|
||||
)?;
|
||||
base.mul(layouter.namespace(|| "mul by zero"), &scalar_fixed)?;
|
||||
let result = base.mul(layouter.namespace(|| "mul by zero"), &scalar_fixed)?;
|
||||
result.constrain_equal(layouter.namespace(|| "[0]B = 𝒪"), &zero)?;
|
||||
}
|
||||
|
||||
// [-1]B is the largest scalar field element.
|
||||
|
|
|
@ -157,13 +157,14 @@ pub mod tests {
|
|||
use halo2::{circuit::Layouter, plonk::Error};
|
||||
use pasta_curves::{arithmetic::FieldExt, pallas};
|
||||
|
||||
use crate::circuit::gadget::ecc::{chip::EccChip, FixedPointShort, ScalarFixedShort};
|
||||
use crate::circuit::gadget::ecc::{chip::EccChip, FixedPointShort, Point, ScalarFixedShort};
|
||||
use crate::constants::load::ValueCommitV;
|
||||
|
||||
#[allow(clippy::op_ref)]
|
||||
pub fn test_mul_fixed_short(
|
||||
chip: EccChip,
|
||||
mut layouter: impl Layouter<pallas::Base>,
|
||||
zero: &Point<pallas::Affine, EccChip>,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
pallas::Scalar: PrimeFieldBits,
|
||||
|
@ -181,7 +182,8 @@ pub mod tests {
|
|||
layouter.namespace(|| "ScalarFixedShort"),
|
||||
Some(scalar_fixed),
|
||||
)?;
|
||||
value_commit_v.mul(layouter.namespace(|| "mul"), &scalar_fixed)?;
|
||||
let result = value_commit_v.mul(layouter.namespace(|| "mul by zero"), &scalar_fixed)?;
|
||||
result.constrain_equal(layouter.namespace(|| "[0]B = 𝒪"), &zero)?;
|
||||
}
|
||||
|
||||
// Random [a]B
|
||||
|
|
Loading…
Reference in New Issue