mirror of https://github.com/zcash/halo2.git
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:
parent
97c27e3d5a
commit
751277cdb2
|
@ -1,6 +1,5 @@
|
||||||
//! Gadgets for elliptic curve operations.
|
//! Gadgets for elliptic curve operations.
|
||||||
|
|
||||||
use std::convert::{TryFrom, TryInto};
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use halo2::{
|
use halo2::{
|
||||||
|
@ -38,7 +37,7 @@ pub trait EccInstructions<C: CurveAffine>: Chip<C::Base> + UtilitiesInstructions
|
||||||
/// Variable representing an elliptic curve point.
|
/// Variable representing an elliptic curve point.
|
||||||
type Point: From<Self::NonIdentityPoint> + IsIdentity + Clone + Debug;
|
type Point: From<Self::NonIdentityPoint> + IsIdentity + Clone + Debug;
|
||||||
/// Variable representing a non-identity elliptic curve point.
|
/// 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
|
/// Variable representing the affine short Weierstrass x-coordinate of an
|
||||||
/// elliptic curve point.
|
/// elliptic curve point.
|
||||||
type X: Clone + Debug;
|
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.
|
/// An elliptic curve point over the given curve.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Point<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> {
|
pub struct Point<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use super::{EccInstructions, IsIdentity};
|
use super::{EccInstructions, IsIdentity};
|
||||||
use crate::{
|
use crate::{
|
||||||
circuit::gadget::utilities::{
|
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
|
/// Configuration for the ECC chip
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|
Loading…
Reference in New Issue