Skip to content

Commit 7359fe8

Browse files
cleanup TwistedEdwardsPoint trait
1 parent 0d99466 commit 7359fe8

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

extensions/ecc/guest/src/edwards.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::ops::Mul;
22

3-
use openvm_algebra_guest::{Field, IntMod};
3+
use openvm_algebra_guest::Field;
44

55
pub trait TwistedEdwardsPoint: Sized {
66
/// The `a` coefficient in the twisted Edwards curve equation `ax^2 + y^2 = 1 + d x^2 y^2`.
@@ -9,9 +9,7 @@ pub trait TwistedEdwardsPoint: Sized {
99
const CURVE_D: Self::Coordinate;
1010
const IDENTITY: Self;
1111

12-
type Coordinate: IntMod + Field;
13-
const ZERO: Self::Coordinate = <Self::Coordinate as IntMod>::ZERO;
14-
const ONE: Self::Coordinate = <Self::Coordinate as IntMod>::ONE;
12+
type Coordinate: Field;
1513

1614
/// The concatenated `x, y` coordinates of the affine point, where
1715
/// coordinates are in little endian.
@@ -31,22 +29,11 @@ pub trait TwistedEdwardsPoint: Sized {
3129
fn add_impl(&self, p2: &Self) -> Self;
3230

3331
fn from_xy(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
34-
where
35-
for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate>,
36-
{
37-
if x == Self::ZERO && y == Self::ONE {
38-
Some(Self::IDENTITY)
39-
} else {
40-
Self::from_xy_nonidentity(x, y)
41-
}
42-
}
43-
44-
fn from_xy_nonidentity(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
4532
where
4633
for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate>,
4734
{
4835
let lhs = Self::CURVE_A * &x * &x + &y * &y;
49-
let rhs = Self::CURVE_D * &x * &x * &y * &y + &Self::ONE;
36+
let rhs = Self::CURVE_D * &x * &x * &y * &y + &Self::Coordinate::ONE;
5037
if lhs != rhs {
5138
return None;
5239
}

0 commit comments

Comments
 (0)