1
1
use core:: ops:: Mul ;
2
2
3
- use openvm_algebra_guest:: { Field , IntMod } ;
3
+ use openvm_algebra_guest:: Field ;
4
4
5
5
pub trait TwistedEdwardsPoint : Sized {
6
6
/// 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 {
9
9
const CURVE_D : Self :: Coordinate ;
10
10
const IDENTITY : Self ;
11
11
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 ;
15
13
16
14
/// The concatenated `x, y` coordinates of the affine point, where
17
15
/// coordinates are in little endian.
@@ -31,22 +29,11 @@ pub trait TwistedEdwardsPoint: Sized {
31
29
fn add_impl ( & self , p2 : & Self ) -> Self ;
32
30
33
31
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 >
45
32
where
46
33
for < ' a > & ' a Self :: Coordinate : Mul < & ' a Self :: Coordinate , Output = Self :: Coordinate > ,
47
34
{
48
35
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 ;
50
37
if lhs != rhs {
51
38
return None ;
52
39
}
0 commit comments