Remove `EccInstructions::NonIdentityPoint: TryFrom<Self::Point>` bound

After the previous commit, this is no longer used anywhere. Additionally
it was not enforcing the conversion in the circuit, which could lead to
circuit implementation mistakes.
This commit is contained in:
Jack Grigg 2021-09-28 16:37:52 +01:00 committed by Sean Bowe
parent 97c27e3d5a
commit 751277cdb2
2 changed files with 1 additions and 36 deletions

View File

@ -1,6 +1,5 @@
//! Gadgets for elliptic curve operations.
use std::convert::{TryFrom, TryInto};
use std::fmt::Debug;
use halo2::{
@ -38,7 +37,7 @@ pub trait EccInstructions<C: CurveAffine>: Chip<C::Base> + UtilitiesInstructions
/// Variable representing an elliptic curve point.
type Point: From<Self::NonIdentityPoint> + IsIdentity + Clone + Debug;
/// Variable representing a non-identity elliptic curve point.
type NonIdentityPoint: TryFrom<Self::Point> + Clone + Debug;
type NonIdentityPoint: Clone + Debug;
/// Variable representing the affine short Weierstrass x-coordinate of an
/// elliptic curve point.
type X: Clone + Debug;
@ -283,24 +282,6 @@ impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq>
}
}
impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> TryFrom<Point<C, EccChip>>
for NonIdentityPoint<C, EccChip>
{
type Error = Error;
fn try_from(point: Point<C, EccChip>) -> Result<Self, Self::Error> {
point
.inner
.clone()
.try_into()
.map(|inner| Self {
chip: point.chip,
inner,
})
.map_err(|_| Error::SynthesisError)
}
}
/// An elliptic curve point over the given curve.
#[derive(Copy, Clone, Debug)]
pub struct Point<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> {

View File

@ -1,5 +1,3 @@
use std::convert::TryFrom;
use super::{EccInstructions, IsIdentity};
use crate::{
circuit::gadget::utilities::{
@ -129,20 +127,6 @@ impl From<NonIdentityEccPoint> for EccPoint {
}
}
impl TryFrom<EccPoint> for NonIdentityEccPoint {
type Error = Error;
fn try_from(point: EccPoint) -> Result<Self, Self::Error> {
if point.is_identity() == Some(true) {
return Err(Error::SynthesisError);
}
Ok(NonIdentityEccPoint {
x: point.x,
y: point.y,
})
}
}
/// Configuration for the ECC chip
#[derive(Clone, Debug, Eq, PartialEq)]
#[allow(non_snake_case)]