mirror of https://github.com/zcash/halo2.git
Introduce ecc::BaseFitsInScalarInstructions trait.
This commit is contained in:
parent
cbf3d6a7f6
commit
5ebfe91eee
|
@ -138,6 +138,18 @@ pub trait EccInstructions<C: CurveAffine>:
|
|||
) -> Result<Self::Point, Error>;
|
||||
}
|
||||
|
||||
/// Instructions that can be implemented for a curve whose base field fits into
|
||||
/// its scalar field.
|
||||
pub trait BaseFitsInScalarInstructions<C: CurveAffine>: EccInstructions<C> {
|
||||
/// Converts a base field element that exists as a variable in the circuit
|
||||
/// into a scalar to be used in variable-base scalar multiplication.
|
||||
fn scalar_var_from_base(
|
||||
&self,
|
||||
layouter: &mut impl Layouter<C::Base>,
|
||||
base: &Self::Var,
|
||||
) -> Result<Self::ScalarVar, Error>;
|
||||
}
|
||||
|
||||
/// Defines the fixed points for a given instantiation of the ECC chip.
|
||||
pub trait FixedPoints<C: CurveAffine>: Debug + Eq + Clone {
|
||||
/// Fixed points that can be used with full-width scalar multiplication.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Chip implementations for the ECC gadgets.
|
||||
|
||||
use super::{EccInstructions, FixedPoints};
|
||||
use super::{BaseFitsInScalarInstructions, EccInstructions, FixedPoints};
|
||||
use crate::{
|
||||
primitives::sinsemilla,
|
||||
utilities::{lookup_range_check::LookupRangeCheckConfig, UtilitiesInstructions},
|
||||
|
@ -533,3 +533,22 @@ where
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Fixed: FixedPoints<pallas::Affine>> BaseFitsInScalarInstructions<pallas::Affine>
|
||||
for EccChip<Fixed>
|
||||
where
|
||||
<Fixed as FixedPoints<pallas::Affine>>::Base:
|
||||
FixedPoint<pallas::Affine, ScalarKind = BaseFieldElem>,
|
||||
<Fixed as FixedPoints<pallas::Affine>>::FullScalar:
|
||||
FixedPoint<pallas::Affine, ScalarKind = FullScalar>,
|
||||
<Fixed as FixedPoints<pallas::Affine>>::ShortScalar:
|
||||
FixedPoint<pallas::Affine, ScalarKind = ShortScalar>,
|
||||
{
|
||||
fn scalar_var_from_base(
|
||||
&self,
|
||||
_layouter: &mut impl Layouter<pallas::Base>,
|
||||
base: &Self::Var,
|
||||
) -> Result<Self::ScalarVar, Error> {
|
||||
Ok(base.clone())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue