mirror of https://github.com/zcash/halo2.git
ecc::chip::mul_fixed: Reintroduce build_constants() closure for constants.
This commit is contained in:
parent
f0e9daf722
commit
31259d089c
|
@ -216,12 +216,17 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>> Config<FixedPoints> {
|
||||||
base: &F,
|
base: &F,
|
||||||
coords_check_toggle: Selector,
|
coords_check_toggle: Selector,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
let mut constants = None;
|
||||||
|
let build_constants = || {
|
||||||
let lagrange_coeffs = base.lagrange_coeffs();
|
let lagrange_coeffs = base.lagrange_coeffs();
|
||||||
assert_eq!(lagrange_coeffs.len(), NUM_WINDOWS);
|
assert_eq!(lagrange_coeffs.len(), NUM_WINDOWS);
|
||||||
|
|
||||||
let z = base.z();
|
let z = base.z();
|
||||||
assert_eq!(z.len(), NUM_WINDOWS);
|
assert_eq!(z.len(), NUM_WINDOWS);
|
||||||
|
|
||||||
|
(lagrange_coeffs, z)
|
||||||
|
};
|
||||||
|
|
||||||
// Assign fixed columns for given fixed base
|
// Assign fixed columns for given fixed base
|
||||||
for window in 0..NUM_WINDOWS {
|
for window in 0..NUM_WINDOWS {
|
||||||
coords_check_toggle.enable(region, window + offset)?;
|
coords_check_toggle.enable(region, window + offset)?;
|
||||||
|
@ -237,7 +242,13 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>> Config<FixedPoints> {
|
||||||
},
|
},
|
||||||
self.lagrange_coeffs[k],
|
self.lagrange_coeffs[k],
|
||||||
window + offset,
|
window + offset,
|
||||||
|| Ok(lagrange_coeffs[window][k]),
|
|| {
|
||||||
|
if constants.as_ref().is_none() {
|
||||||
|
constants = Some(build_constants());
|
||||||
|
}
|
||||||
|
let lagrange_coeffs = &constants.as_ref().unwrap().0;
|
||||||
|
Ok(lagrange_coeffs[window][k])
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +257,10 @@ impl<FixedPoints: super::FixedPoints<pallas::Affine>> Config<FixedPoints> {
|
||||||
|| format!("z-value for window: {:?}", window),
|
|| format!("z-value for window: {:?}", window),
|
||||||
self.fixed_z,
|
self.fixed_z,
|
||||||
window + offset,
|
window + offset,
|
||||||
|| Ok(pallas::Base::from_u64(z[window])),
|
|| {
|
||||||
|
let z = &constants.as_ref().unwrap().1;
|
||||||
|
Ok(pallas::Base::from_u64(z[window]))
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue