mirror of https://github.com/zcash/orchard.git
mul_fixed::short: Refactor short::Config.
This commit does not result in circuit changes.
This commit is contained in:
parent
165c9b6941
commit
687e220c36
|
@ -147,7 +147,7 @@ pub struct EccConfig {
|
|||
/// Fixed-base full-width scalar multiplication
|
||||
mul_fixed_full: mul_fixed::full_width::Config,
|
||||
/// Fixed-base signed short scalar multiplication
|
||||
pub q_mul_fixed_short: Selector,
|
||||
mul_fixed_short: mul_fixed::short::Config,
|
||||
/// Canonicity checks on base field element used as scalar in fixed-base mul
|
||||
pub q_mul_fixed_base_field: Selector,
|
||||
|
||||
|
@ -238,6 +238,9 @@ impl EccChip {
|
|||
// Create gate that is only used in full-width fixed-base scalar mul.
|
||||
let mul_fixed_full = mul_fixed::full_width::Config::configure(meta, mul_fixed);
|
||||
|
||||
// Create gate that is only used in short fixed-base scalar mul.
|
||||
let mul_fixed_short = mul_fixed::short::Config::configure(meta, mul_fixed);
|
||||
|
||||
let config = EccConfig {
|
||||
advices,
|
||||
add_incomplete,
|
||||
|
@ -245,18 +248,12 @@ impl EccChip {
|
|||
mul,
|
||||
mul_fixed,
|
||||
mul_fixed_full,
|
||||
q_mul_fixed_short: meta.selector(),
|
||||
mul_fixed_short,
|
||||
q_mul_fixed_base_field: meta.selector(),
|
||||
witness_point,
|
||||
lookup_config: range_check,
|
||||
};
|
||||
|
||||
// Create gate that is only used in short fixed-base scalar mul.
|
||||
{
|
||||
let short_config: mul_fixed::short::Config = (&config).into();
|
||||
short_config.create_gate(meta);
|
||||
}
|
||||
|
||||
// Create gate that is only used in fixed-base mul using a base field element.
|
||||
{
|
||||
let base_field_config: mul_fixed::base_field_elem::Config = (&config).into();
|
||||
|
@ -437,7 +434,7 @@ impl EccInstructions<pallas::Affine> for EccChip {
|
|||
magnitude_sign: (CellValue<pallas::Base>, CellValue<pallas::Base>),
|
||||
base: &Self::FixedPointsShort,
|
||||
) -> Result<(Self::Point, Self::ScalarFixedShort), Error> {
|
||||
let config: mul_fixed::short::Config = self.config().into();
|
||||
let config: mul_fixed::short::Config = self.config().mul_fixed_short;
|
||||
config.assign(
|
||||
layouter.namespace(|| format!("short fixed-base mul of {:?}", base)),
|
||||
magnitude_sign,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{array, convert::TryInto};
|
||||
|
||||
use super::super::{EccConfig, EccPoint, EccScalarFixedShort};
|
||||
use super::super::{EccPoint, EccScalarFixedShort};
|
||||
use crate::{
|
||||
circuit::gadget::utilities::{bool_check, copy, CellValue, Var},
|
||||
constants::{ValueCommitV, L_VALUE, NUM_WINDOWS_SHORT},
|
||||
|
@ -13,24 +13,29 @@ use halo2::{
|
|||
};
|
||||
use pasta_curves::pallas;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug, Copy, Eq, PartialEq)]
|
||||
pub struct Config {
|
||||
// Selector used for fixed-base scalar mul with short signed exponent.
|
||||
q_mul_fixed_short: Selector,
|
||||
super_config: super::Config,
|
||||
}
|
||||
|
||||
impl From<&EccConfig> for Config {
|
||||
fn from(config: &EccConfig) -> Self {
|
||||
Self {
|
||||
q_mul_fixed_short: config.q_mul_fixed_short,
|
||||
super_config: config.mul_fixed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub(crate) fn create_gate(&self, meta: &mut ConstraintSystem<pallas::Base>) {
|
||||
pub(crate) fn configure(
|
||||
meta: &mut ConstraintSystem<pallas::Base>,
|
||||
super_config: super::Config,
|
||||
) -> Self {
|
||||
let config = Self {
|
||||
q_mul_fixed_short: meta.selector(),
|
||||
super_config,
|
||||
};
|
||||
|
||||
config.create_gate(meta);
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
fn create_gate(&self, meta: &mut ConstraintSystem<pallas::Base>) {
|
||||
meta.create_gate("Short fixed-base mul gate", |meta| {
|
||||
let q_mul_fixed_short = meta.query_selector(self.q_mul_fixed_short);
|
||||
let y_p = meta.query_advice(self.super_config.y_p, Rotation::cur());
|
||||
|
@ -444,7 +449,7 @@ pub mod tests {
|
|||
) -> Result<(), Error> {
|
||||
let column = config.advices[0];
|
||||
|
||||
let short_config: super::Config = (&config).into();
|
||||
let short_config = config.mul_fixed_short;
|
||||
let magnitude_sign = {
|
||||
let magnitude = self.load_private(
|
||||
layouter.namespace(|| "load magnitude"),
|
||||
|
|
Loading…
Reference in New Issue