@@ -85,7 +85,8 @@ static const secp256k1_fe secp256k1_const_beta = SECP256K1_FE_CONST(
85
85
# define secp256k1_fe_is_zero secp256k1_fe_impl_is_zero
86
86
# define secp256k1_fe_is_odd secp256k1_fe_impl_is_odd
87
87
# define secp256k1_fe_cmp_var secp256k1_fe_impl_cmp_var
88
- # define secp256k1_fe_set_b32 secp256k1_fe_impl_set_b32
88
+ # define secp256k1_fe_set_b32_mod secp256k1_fe_impl_set_b32_mod
89
+ # define secp256k1_fe_set_b32_limit secp256k1_fe_impl_set_b32_limit
89
90
# define secp256k1_fe_get_b32 secp256k1_fe_impl_get_b32
90
91
# define secp256k1_fe_negate secp256k1_fe_impl_negate
91
92
# define secp256k1_fe_mul_int secp256k1_fe_impl_mul_int
@@ -189,16 +190,20 @@ static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b);
189
190
*/
190
191
static int secp256k1_fe_cmp_var (const secp256k1_fe * a , const secp256k1_fe * b );
191
192
192
- /** Set a field element equal to a provided 32-byte big endian value.
193
+ /** Set a field element equal to a provided 32-byte big endian value, reducing it .
193
194
*
194
195
* On input, r does not need to be initalized. a must be a pointer to an initialized 32-byte array.
195
- * On output, r = a (mod p). It will have magnitude 1, and if (a < p), it will be normalized.
196
- * If not, it will only be weakly normalized. Returns whether (a < p).
196
+ * On output, r = a (mod p). It will have magnitude 1, and not be normalized.
197
+ */
198
+ static void secp256k1_fe_set_b32_mod (secp256k1_fe * r , const unsigned char * a );
199
+
200
+ /** Set a field element equal to a provided 32-byte big endian value, checking for overflow.
197
201
*
198
- * Note that this function is unusual in that the normalization of the output depends on the
199
- * run-time value of a.
202
+ * On input, r does not need to be initalized. a must be a pointer to an initialized 32-byte array.
203
+ * On output, r = a if (a < p), it will be normalized with magnitude 1, and 1 is returned.
204
+ * If a >= p, 0 is returned, and r will be made invalid (and must not be used without overwriting).
200
205
*/
201
- static int secp256k1_fe_set_b32 (secp256k1_fe * r , const unsigned char * a );
206
+ static int secp256k1_fe_set_b32_limit (secp256k1_fe * r , const unsigned char * a );
202
207
203
208
/** Convert a field element to 32-byte big endian byte array.
204
209
* On input, a must be a valid normalized field element, and r a pointer to a 32-byte array.
0 commit comments