You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Computes the addition of two [QM31] elements in reduced form.
109
+
///
110
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
111
+
///
112
+
/// The algorithm was taken from the following papper: https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf
113
+
/// Section 1.1.2.
109
114
pubfnadd(&self,rhs:&QM31) -> QM31{
110
115
let coordinates1 = self.inner();
111
116
let coordinates2 = rhs.inner();
@@ -119,6 +124,11 @@ impl QM31 {
119
124
}
120
125
121
126
/// Computes the negative of a [QM31] element in reduced form.
127
+
///
128
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
129
+
///
130
+
/// The algorithm was taken from the following papper: https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf
131
+
/// Section 1.1.2.
122
132
pubfnneg(&self) -> QM31{
123
133
let coordinates = self.inner();
124
134
Self::from_coordinates([
@@ -130,6 +140,11 @@ impl QM31 {
130
140
}
131
141
132
142
/// Computes the subtraction of two [QM31] elements in reduced form.
143
+
///
144
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
145
+
///
146
+
/// The algorithm was taken from the following papper: https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf
147
+
/// Section 1.1.2.
133
148
pubfnsub(&self,rhs:&QM31) -> QM31{
134
149
let coordinates1 = self.inner();
135
150
let coordinates2 = rhs.inner();
@@ -143,6 +158,8 @@ impl QM31 {
143
158
}
144
159
145
160
/// Computes the multiplication of two [QM31] elements in reduced form.
161
+
///
162
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
146
163
pubfnmul(&self,rhs:&QM31) -> QM31{
147
164
let coordinates1_u64 = self.inner();
148
165
let coordinates2_u64 = rhs.inner();
@@ -190,6 +207,11 @@ impl QM31 {
190
207
}
191
208
192
209
/// Computes `v^(2^n) modulo STWO_PRIME`.
210
+
///
211
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
212
+
///
213
+
/// The algorithm was taken from the following papper: https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf
214
+
/// Section 1.1.3.
193
215
fnsqn(v:u64,n:usize) -> u64{
194
216
letmut u = v;
195
217
for _ in0..n {
@@ -200,6 +222,8 @@ impl QM31 {
200
222
201
223
/// Computes the inverse of a [QM31] element in reduced form.
202
224
///
225
+
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
226
+
///
203
227
/// Returns an error if the operand is equal to zero.
0 commit comments