@@ -85,7 +85,8 @@ static const secp256k1_fe secp256k1_const_beta = SECP256K1_FE_CONST(
8585# define secp256k1_fe_is_zero secp256k1_fe_impl_is_zero
8686# define secp256k1_fe_is_odd secp256k1_fe_impl_is_odd
8787# 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
8990# define secp256k1_fe_get_b32 secp256k1_fe_impl_get_b32
9091# define secp256k1_fe_negate secp256k1_fe_impl_negate
9192# 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);
189190 */
190191static int secp256k1_fe_cmp_var (const secp256k1_fe * a , const secp256k1_fe * b );
191192
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 .
193194 *
194195 * 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.
197201 *
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 >= 0, 0 is returned, and r will be made invalid (and cannot be used without overwriting).
200205 */
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 );
202207
203208/** Convert a field element to 32-byte big endian byte array.
204209 * On input, a must be a valid normalized field element, and r a pointer to a 32-byte array.
0 commit comments