Skip to content

Commit 06ed0d5

Browse files
add docs on multiplication and inversion algorithms
1 parent 451d863 commit 06ed0d5

File tree

1 file changed

+9
-9
lines changed
  • crates/starknet-types-core/src/qm31

1 file changed

+9
-9
lines changed

crates/starknet-types-core/src/qm31/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ impl QM31 {
160160
/// Computes the multiplication of two [QM31] elements in reduced form.
161161
///
162162
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
163-
///
163+
///
164164
/// The algorithm can be deduced from the implementation of the QM31 multiplication from the Stwo prover:
165165
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/qm31.rs#L81).
166-
/// Which multiplies 2 complex extension fields of M31:
166+
/// Which multiplies 2 complex extension fields of M31:
167167
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/cm31.rs#L47).
168-
/// Whose real and imaginary components result from the M31 multiplication:
168+
/// Whose real and imaginary components result from the M31 multiplication:
169169
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/m31.rs#L105).
170-
///
170+
///
171171
/// The implementation of the QM31 multiplication is based on the following paper: [Link](https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf)
172172
/// Section 1.3, Ecuation 1.20.
173173
pub fn mul(&self, rhs: &QM31) -> QM31 {
@@ -233,17 +233,17 @@ impl QM31 {
233233
/// Computes the inverse of a [QM31] element in reduced form.
234234
///
235235
/// In reduced form, a QM31 is composed of 4 limbs, each represented a value from the Mersenne 31 field.
236-
///
236+
///
237237
/// The algorithm can be deduced from the implementation of the inverse of a QM31 from the Stwo prover:
238238
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/qm31.rs#L120).
239-
///
240-
/// Having the following inverse operation: `(a + bu)^-1 = (a - bu) / (a^2 - (2+i)b^2)`, the algorithm computes the denominator by computing
241-
/// `(a^2 - (2+i)b^2)` first and then inverting it. The denominator's value inverse is computed as the inverse of a complex extension
239+
///
240+
/// Having the following inverse operation: `(a + bu)^-1 = (a - bu) / (a^2 - (2+i)b^2)`, the algorithm computes the denominator by computing
241+
/// `(a^2 - (2+i)b^2)` first and then inverting it. The denominator's value inverse is computed as the inverse of a complex extension
242242
/// field of M31:
243243
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/cm31.rs#L68).
244244
/// Finally, the inverse of the QM31 is computed:
245245
/// [Link](https://github.com/starkware-libs/stwo/blob/d9176e6e22319370a8501f799829b920c0db2eac/crates/stwo/src/core/fields/qm31.rs#L127).
246-
///
246+
///
247247
/// The implementation of the QM31 inversion is based on the following papper: [Link](https://github.com/ingonyama-zk/papers/blob/main/Mersenne31_polynomial_arithmetic.pdf)
248248
/// Section 1.3, Ecuation 1.23.
249249
///

0 commit comments

Comments
 (0)