Skip to content

Commit 9de3ac9

Browse files
lowercase error massages + improve documentation
1 parent c29db22 commit 9de3ac9

File tree

1 file changed

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

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ impl fmt::Display for QM31Error {
2222
match self {
2323
QM31Error::UnreducedFelt(felt) => write!(
2424
f,
25-
"Number is not a packing of a QM31 in reduced form: {felt})"
25+
"number is not a packing of a QM31 in reduced form: {felt})"
2626
),
2727
QM31Error::FeltTooBig(felt) => write!(
2828
f,
29-
"Number used as QM31 since it's more than 144 bits long: {felt}"
29+
"number used as QM31 since it's more than 144 bits long: {felt}"
3030
),
31-
QM31Error::InvalidInversion => write!(f, "Attempt to invert a qm31 equal to zero"),
31+
QM31Error::InvalidInversion => write!(f, "attempt to invert a qm31 equal to zero"),
3232
}
3333
}
3434
}
3535

36-
/// Definition of a Quad M31 in its reduced form. The internal representation
37-
/// is composed by the coordinates of the QM31, following a little endian ordering.
36+
/// Definition of a Quad M31 in its reduced form.
37+
///
38+
/// The internal representation is composed of the coordinates of the QM31, following a little-endian ordering.
3839
#[repr(transparent)]
3940
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
4041
pub struct QM31([u64; 4]);
@@ -141,8 +142,9 @@ impl QM31 {
141142
Self::from_coordinates(result_coordinates)
142143
}
143144

144-
/// Computes the inverse in the M31 field using Fermat's little theorem, i.e., returns
145-
/// `v^(STWO_PRIME-2) modulo STWO_PRIME`, which is the inverse of v unless v % STWO_PRIME == 0.
145+
/// Computes the inverse in the M31 field using Fermat's little theorem.
146+
///
147+
/// Returns `v^(STWO_PRIME-2) modulo STWO_PRIME`, which is the inverse of v unless v % STWO_PRIME == 0.
146148
fn m31_inverse(v: u64) -> u64 {
147149
let t0 = (Self::sqn(v, 2) * v) % STWO_PRIME;
148150
let t1 = (Self::sqn(t0, 1) * t0) % STWO_PRIME;

0 commit comments

Comments
 (0)