@@ -38,9 +38,7 @@ impl QM31Felt {
38
38
self . 0
39
39
}
40
40
41
- /// Create a [QM31Felt] from the raw internal representation. Reduces four u64 coordinates and packs them
42
- /// into a single Felt252. STWO_PRIME fits in 36 bits, hence each coordinate can be represented
43
- /// by 36 bits and a QM31 element can be stored in the first 144 bits of a Felt252.
41
+ /// Create a [QM31Felt] from the raw internal representation. Reduces four u64 coordinates so that the fit in 144 bits.
44
42
pub fn from_raw ( coordinates : [ u64 ; 4 ] ) -> QM31Felt {
45
43
Self ( [
46
44
coordinates[ 0 ] % STWO_PRIME ,
@@ -50,6 +48,7 @@ impl QM31Felt {
50
48
] )
51
49
}
52
50
51
+ /// Packs the [QM31Felt] coordinates into a Felt.
53
52
pub fn pack_into_felt ( & self ) -> Felt {
54
53
let coordinates = self . 0 ;
55
54
@@ -62,7 +61,7 @@ impl QM31Felt {
62
61
Felt :: from_bytes_le ( & result_bytes)
63
62
}
64
63
65
- /// Computes the addition of two QM31 elements in reduced form.
64
+ /// Computes the addition of two [QM31Felt] elements in reduced form.
66
65
pub fn add ( & self , rhs : & QM31Felt ) -> QM31Felt {
67
66
let coordinates1 = self . as_raw ( ) ;
68
67
let coordinates2 = rhs. as_raw ( ) ;
@@ -75,7 +74,7 @@ impl QM31Felt {
75
74
Self :: from_raw ( result_unreduced_coordinates)
76
75
}
77
76
78
- /// Computes the negative of a QM31 element in reduced form.
77
+ /// Computes the negative of a [QM31Felt] element in reduced form.
79
78
pub fn neg ( & self ) -> QM31Felt {
80
79
let coordinates = self . as_raw ( ) ;
81
80
Self :: from_raw ( [
@@ -86,7 +85,7 @@ impl QM31Felt {
86
85
] )
87
86
}
88
87
89
- /// Computes the subtraction of two QM31 elements in reduced form.
88
+ /// Computes the subtraction of two [QM31Felt] elements in reduced form.
90
89
pub fn sub ( & self , rhs : & QM31Felt ) -> QM31Felt {
91
90
let coordinates1 = self . as_raw ( ) ;
92
91
let coordinates2 = rhs. as_raw ( ) ;
@@ -99,7 +98,7 @@ impl QM31Felt {
99
98
Self :: from_raw ( result_unreduced_coordinates)
100
99
}
101
100
102
- /// Computes the multiplication of two QM31 elements in reduced form.
101
+ /// Computes the multiplication of two [QM31Felt] elements in reduced form.
103
102
pub fn mul ( & self , rhs : & QM31Felt ) -> QM31Felt {
104
103
let coordinates1_u64 = self . as_raw ( ) ;
105
104
let coordinates2_u64 = rhs. as_raw ( ) ;
@@ -154,7 +153,7 @@ impl QM31Felt {
154
153
u
155
154
}
156
155
157
- /// Computes the inverse of a QM31 element in reduced form.
156
+ /// Computes the inverse of a [QM31Felt] element in reduced form.
158
157
/// Returns an error if the operand is equal to zero.
159
158
pub fn inverse ( & self ) -> Result < QM31Felt , QM31Error > {
160
159
if * self == Self :: ZERO {
@@ -195,7 +194,7 @@ impl QM31Felt {
195
194
] ) )
196
195
}
197
196
198
- /// Computes the division of two QM31 elements in reduced form. Returns an error
197
+ /// Computes the division of two [QM31Felt] elements in reduced form. Returns an error
199
198
/// if the rhs value is equal to zero.
200
199
pub fn div ( & self , rhs : & QM31Felt ) -> Result < QM31Felt , QM31Error > {
201
200
let rhs_inv = rhs. inverse ( ) ?;
0 commit comments