1use crate::{pasta_fp::WasmPastaFp, pasta_fq::WasmPastaFq};
2use 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};
9use wasm_bindgen::prelude::*;
10
11#[wasm_bindgen]
16#[derive(Clone, Copy, Debug)]
17pub struct WasmGPallas {
18 pub x: WasmPastaFp,
19 pub y: WasmPastaFp,
20 pub infinity: bool,
21}
22
23#[wasm_bindgen]
24impl WasmGPallas {
25 #[wasm_bindgen]
26 pub fn wasm_clone(&self) -> Self {
27 *self
28 }
29}
30
31#[wasm_bindgen]
32#[derive(Clone, Copy, Debug)]
33pub struct WasmGVesta {
34 pub x: WasmPastaFq,
35 pub y: WasmPastaFq,
36 pub infinity: bool,
37}
38
39#[wasm_bindgen]
40impl WasmGVesta {
41 #[wasm_bindgen]
42 pub fn wasm_clone(&self) -> Self {
43 *self
44 }
45}
46
47impl From<AffineVesta> for WasmGVesta {
50 fn from(point: AffineVesta) -> Self {
51 WasmGVesta {
52 x: point.x.into(),
53 y: point.y.into(),
54 infinity: point.infinity,
55 }
56 }
57}
58
59impl From<&AffineVesta> for WasmGVesta {
60 fn from(point: &AffineVesta) -> Self {
61 WasmGVesta {
62 x: point.x.into(),
63 y: point.y.into(),
64 infinity: point.infinity,
65 }
66 }
67}
68
69impl From<WasmGVesta> for AffineVesta {
70 fn from(point: WasmGVesta) -> Self {
71 AffineVesta {
72 x: point.x.into(),
73 y: point.y.into(),
74 infinity: point.infinity,
75 }
76 }
77}
78
79impl From<&WasmGVesta> for AffineVesta {
80 fn from(point: &WasmGVesta) -> Self {
81 AffineVesta {
82 x: point.x.into(),
83 y: point.y.into(),
84 infinity: point.infinity,
85 }
86 }
87}
88
89impl From<AffinePallas> for WasmGPallas {
92 fn from(point: AffinePallas) -> Self {
93 WasmGPallas {
94 x: point.x.into(),
95 y: point.y.into(),
96 infinity: point.infinity,
97 }
98 }
99}
100
101impl From<&AffinePallas> for WasmGPallas {
102 fn from(point: &AffinePallas) -> Self {
103 WasmGPallas {
104 x: point.x.into(),
105 y: point.y.into(),
106 infinity: point.infinity,
107 }
108 }
109}
110
111impl From<WasmGPallas> for AffinePallas {
112 fn from(point: WasmGPallas) -> Self {
113 AffinePallas {
114 x: point.x.into(),
115 y: point.y.into(),
116 infinity: point.infinity,
117 }
118 }
119}
120
121impl From<&WasmGPallas> for AffinePallas {
122 fn from(point: &WasmGPallas) -> Self {
123 AffinePallas {
124 x: point.x.into(),
125 y: point.y.into(),
126 infinity: point.infinity,
127 }
128 }
129}
130
131#[wasm_bindgen]
132pub fn caml_pallas_affine_one() -> WasmGPallas {
133 WasmGPallas {
134 x: WasmPastaFp::from(GeneratorPallasX),
135 y: WasmPastaFp::from(GeneratorPallasY),
136 infinity: false,
137 }
138}
139
140#[wasm_bindgen]
141pub fn caml_vesta_affine_one() -> WasmGVesta {
142 WasmGVesta {
143 x: WasmPastaFq::from(GeneratorVestaX),
144 y: WasmPastaFq::from(GeneratorVestaY),
145 infinity: false,
146 }
147}