gadget::ecc.rs: Bound EccInstructions on UtilitiesInstructions.

This commit is contained in:
therealyingtong 2021-07-10 09:09:26 +08:00
parent 7b497c53a3
commit 32f28ed4b0
3 changed files with 10 additions and 10 deletions

View File

@ -9,12 +9,12 @@ use halo2::{
plonk::Error,
};
use crate::circuit::gadget::utilities::CellValue;
use crate::circuit::gadget::utilities::UtilitiesInstructions;
pub mod chip;
/// The set of circuit instructions required to use the ECC gadgets.
pub trait EccInstructions<C: CurveAffine>: Chip<C::Base> {
pub trait EccInstructions<C: CurveAffine>: Chip<C::Base> + UtilitiesInstructions<C::Base> {
/// Variable representing an element of the elliptic curve's base field, that
/// is used as a scalar in variable-base scalar mul.
///
@ -137,7 +137,7 @@ pub trait EccInstructions<C: CurveAffine>: Chip<C::Base> {
fn mul_fixed_base_field_elem(
&self,
layouter: &mut impl Layouter<C::Base>,
base_field_elem: CellValue<C::Base>,
base_field_elem: Self::Var,
base: &Self::FixedPoints,
) -> Result<Self::Point, Error>;
}
@ -369,7 +369,7 @@ where
pub fn mul_base_field_elem(
&self,
mut layouter: impl Layouter<C::Base>,
by: CellValue<C::Base>,
by: EccChip::Var,
) -> Result<Point<C, EccChip>, Error> {
self.chip
.mul_fixed_base_field_elem(&mut layouter, by, &self.inner)

View File

@ -2,7 +2,7 @@ use super::EccInstructions;
use crate::{
circuit::gadget::utilities::{
copy, decompose_running_sum::RunningSumConfig, lookup_range_check::LookupRangeCheckConfig,
CellValue, Var,
CellValue, UtilitiesInstructions, Var,
},
constants::{self, OrchardFixedBasesFull, ValueCommitV},
primitives::sinsemilla,
@ -159,6 +159,10 @@ impl Chip<pallas::Base> for EccChip {
}
}
impl UtilitiesInstructions<pallas::Base> for EccChip {
type Var = CellValue<pallas::Base>;
}
impl EccChip {
pub fn construct(config: <Self as Chip<pallas::Base>>::Config) -> Self {
Self { config }

View File

@ -426,7 +426,7 @@ pub mod tests {
chip::{EccChip, OrchardFixedBasesFull},
FixedPoint, Point,
},
utilities::{CellValue, UtilitiesInstructions},
utilities::UtilitiesInstructions,
};
use crate::constants;
@ -434,10 +434,6 @@ pub mod tests {
chip: EccChip,
mut layouter: impl Layouter<pallas::Base>,
) -> Result<(), Error> {
impl UtilitiesInstructions<pallas::Base> for EccChip {
type Var = CellValue<pallas::Base>;
}
// commit_ivk_r
let commit_ivk_r = OrchardFixedBasesFull::CommitIvkR;
test_single_base(