plonk_wasm/arkworks/
group_projective.rs1use core::ops::{Add, Deref, Neg, Sub};
2use mina_curves::pasta::{ProjectivePallas, ProjectiveVesta};
3use wasm_bindgen::prelude::*;
4
5#[wasm_bindgen]
7#[derive(Clone, Copy)]
8pub struct WasmPallasGProjective(ProjectivePallas);
9
10impl AsRef<WasmPallasGProjective> for WasmPallasGProjective {
11 fn as_ref(&self) -> &WasmPallasGProjective {
12 self
13 }
14}
15
16impl Deref for WasmPallasGProjective {
17 type Target = ProjectivePallas;
18
19 fn deref(&self) -> &Self::Target {
20 &self.0
21 }
22}
23
24impl From<ProjectivePallas> for WasmPallasGProjective {
27 fn from(x: ProjectivePallas) -> Self {
28 WasmPallasGProjective(x)
29 }
30}
31
32impl From<&ProjectivePallas> for WasmPallasGProjective {
33 fn from(x: &ProjectivePallas) -> Self {
34 WasmPallasGProjective(*x)
35 }
36}
37
38impl From<WasmPallasGProjective> for ProjectivePallas {
39 fn from(x: WasmPallasGProjective) -> Self {
40 x.0
41 }
42}
43
44impl From<&WasmPallasGProjective> for ProjectivePallas {
45 fn from(x: &WasmPallasGProjective) -> Self {
46 x.0
47 }
48}
49
50impl Add for WasmPallasGProjective {
51 type Output = Self;
52
53 fn add(self, other: Self) -> Self {
54 Self(self.0 + other.0)
55 }
56}
57
58impl Add for &WasmPallasGProjective {
59 type Output = WasmPallasGProjective;
60
61 fn add(self, other: Self) -> Self::Output {
62 WasmPallasGProjective(self.0 + other.0)
63 }
64}
65
66impl Sub for WasmPallasGProjective {
67 type Output = WasmPallasGProjective;
68
69 fn sub(self, other: Self) -> Self::Output {
70 WasmPallasGProjective(self.0 - other.0)
71 }
72}
73
74impl Sub for &WasmPallasGProjective {
75 type Output = WasmPallasGProjective;
76
77 fn sub(self, other: Self) -> Self::Output {
78 WasmPallasGProjective(self.0 - other.0)
79 }
80}
81
82impl Neg for WasmPallasGProjective {
83 type Output = WasmPallasGProjective;
84
85 fn neg(self) -> Self::Output {
86 WasmPallasGProjective(-self.0)
87 }
88}
89
90impl Neg for &WasmPallasGProjective {
91 type Output = WasmPallasGProjective;
92
93 fn neg(self) -> Self::Output {
94 WasmPallasGProjective(-self.0)
95 }
96}
97
98#[wasm_bindgen]
101#[derive(Clone, Copy)]
102pub struct WasmVestaGProjective(ProjectiveVesta);
103
104impl AsRef<WasmVestaGProjective> for WasmVestaGProjective {
105 fn as_ref(&self) -> &WasmVestaGProjective {
106 self
107 }
108}
109
110impl Deref for WasmVestaGProjective {
111 type Target = ProjectiveVesta;
112
113 fn deref(&self) -> &Self::Target {
114 &self.0
115 }
116}
117
118impl From<ProjectiveVesta> for WasmVestaGProjective {
123 fn from(x: ProjectiveVesta) -> Self {
124 WasmVestaGProjective(x)
125 }
126}
127
128impl From<&ProjectiveVesta> for WasmVestaGProjective {
129 fn from(x: &ProjectiveVesta) -> Self {
130 WasmVestaGProjective(*x)
131 }
132}
133
134impl From<WasmVestaGProjective> for ProjectiveVesta {
135 fn from(x: WasmVestaGProjective) -> Self {
136 x.0
137 }
138}
139
140impl From<&WasmVestaGProjective> for ProjectiveVesta {
141 fn from(x: &WasmVestaGProjective) -> Self {
142 x.0
143 }
144}
145
146impl Add for WasmVestaGProjective {
147 type Output = Self;
148
149 fn add(self, other: Self) -> Self {
150 Self(self.0 + other.0)
151 }
152}
153impl Add for &WasmVestaGProjective {
154 type Output = WasmVestaGProjective;
155
156 fn add(self, other: Self) -> Self::Output {
157 WasmVestaGProjective(self.0 + other.0)
158 }
159}
160
161impl Sub for WasmVestaGProjective {
162 type Output = WasmVestaGProjective;
163
164 fn sub(self, other: Self) -> Self::Output {
165 WasmVestaGProjective(self.0 - other.0)
166 }
167}
168
169impl Sub for &WasmVestaGProjective {
170 type Output = WasmVestaGProjective;
171
172 fn sub(self, other: Self) -> Self::Output {
173 WasmVestaGProjective(self.0 - other.0)
174 }
175}
176
177impl Neg for WasmVestaGProjective {
178 type Output = WasmVestaGProjective;
179
180 fn neg(self) -> Self::Output {
181 WasmVestaGProjective(-self.0)
182 }
183}
184
185impl Neg for &WasmVestaGProjective {
186 type Output = WasmVestaGProjective;
187
188 fn neg(self) -> Self::Output {
189 WasmVestaGProjective(-self.0)
190 }
191}