1+ use crate :: wrappers:: field:: { WasmPastaFp , WasmPastaFq } ;
2+ use mina_curves:: pasta:: {
3+ curves:: {
4+ pallas:: { G_GENERATOR_X as GeneratorPallasX , G_GENERATOR_Y as GeneratorPallasY } ,
5+ vesta:: { G_GENERATOR_X as GeneratorVestaX , G_GENERATOR_Y as GeneratorVestaY } ,
6+ } ,
7+ Pallas as AffinePallas , Vesta as AffineVesta ,
8+ } ;
9+ use napi_derive:: napi;
10+
11+ #[ napi( object) ]
12+ #[ derive( Clone , Debug ) ]
13+ pub struct WasmGPallas {
14+ pub x : WasmPastaFp ,
15+ pub y : WasmPastaFp ,
16+ pub infinity : bool ,
17+ }
18+
19+ #[ napi( object) ]
20+ #[ derive( Clone , Debug ) ]
21+ pub struct WasmGVesta {
22+ pub x : WasmPastaFq ,
23+ pub y : WasmPastaFq ,
24+ pub infinity : bool ,
25+ }
26+
27+ impl From < AffinePallas > for WasmGPallas {
28+ fn from ( point : AffinePallas ) -> Self {
29+ Self {
30+ x : point. x . into ( ) ,
31+ y : point. y . into ( ) ,
32+ infinity : point. infinity ,
33+ }
34+ }
35+ }
36+
37+ impl From < & AffinePallas > for WasmGPallas {
38+ fn from ( point : & AffinePallas ) -> Self {
39+ Self {
40+ x : point. x . into ( ) ,
41+ y : point. y . into ( ) ,
42+ infinity : point. infinity ,
43+ }
44+ }
45+ }
46+
47+ impl From < WasmGPallas > for AffinePallas {
48+ fn from ( point : WasmGPallas ) -> Self {
49+ AffinePallas {
50+ x : point. x . into ( ) ,
51+ y : point. y . into ( ) ,
52+ infinity : point. infinity ,
53+ }
54+ }
55+ }
56+
57+ impl From < & WasmGPallas > for AffinePallas {
58+ fn from ( point : & WasmGPallas ) -> Self {
59+ AffinePallas {
60+ x : point. x . into ( ) ,
61+ y : point. y . into ( ) ,
62+ infinity : point. infinity ,
63+ }
64+ }
65+ }
66+
67+ impl From < AffineVesta > for WasmGVesta {
68+ fn from ( point : AffineVesta ) -> Self {
69+ Self {
70+ x : point. x . into ( ) ,
71+ y : point. y . into ( ) ,
72+ infinity : point. infinity ,
73+ }
74+ }
75+ }
76+
77+ impl From < & AffineVesta > for WasmGVesta {
78+ fn from ( point : & AffineVesta ) -> Self {
79+ Self {
80+ x : point. x . into ( ) ,
81+ y : point. y . into ( ) ,
82+ infinity : point. infinity ,
83+ }
84+ }
85+ }
86+
87+ impl From < WasmGVesta > for AffineVesta {
88+ fn from ( point : WasmGVesta ) -> Self {
89+ AffineVesta {
90+ x : point. x . into ( ) ,
91+ y : point. y . into ( ) ,
92+ infinity : point. infinity ,
93+ }
94+ }
95+ }
96+
97+ impl From < & WasmGVesta > for AffineVesta {
98+ fn from ( point : & WasmGVesta ) -> Self {
99+ AffineVesta {
100+ x : point. x . into ( ) ,
101+ y : point. y . into ( ) ,
102+ infinity : point. infinity ,
103+ }
104+ }
105+ }
106+
107+ #[ napi]
108+ pub fn caml_pallas_affine_one ( ) -> WasmGPallas {
109+ WasmGPallas {
110+ x : WasmPastaFp :: from ( GeneratorPallasX ) ,
111+ y : WasmPastaFp :: from ( GeneratorPallasY ) ,
112+ infinity : false ,
113+ }
114+ }
115+
116+ #[ napi]
117+ pub fn caml_vesta_affine_one ( ) -> WasmGVesta {
118+ WasmGVesta {
119+ x : WasmPastaFq :: from ( GeneratorVestaX ) ,
120+ y : WasmPastaFq :: from ( GeneratorVestaY ) ,
121+ infinity : false ,
122+ }
123+ }
0 commit comments