File tree 4 files changed +15
-11
lines changed
4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ static const secp256k1_fe secp256k1_const_beta = SECP256K1_FE_CONST(
83
83
# define secp256k1_fe_set_int secp256k1_fe_impl_set_int
84
84
# define secp256k1_fe_clear secp256k1_fe_impl_clear
85
85
# define secp256k1_fe_is_zero secp256k1_fe_impl_is_zero
86
+ # define secp256k1_fe_is_odd secp256k1_fe_impl_is_odd
86
87
#endif /* !defined(VERIFY) */
87
88
88
89
/** Normalize a field element.
@@ -142,7 +143,11 @@ static void secp256k1_fe_clear(secp256k1_fe *a);
142
143
*/
143
144
static int secp256k1_fe_is_zero (const secp256k1_fe * a );
144
145
145
- /** Check the "oddness" of a field element. Requires the input to be normalized. */
146
+ /** Determine whether a (mod p) is odd.
147
+ *
148
+ * On input, a must be a valid normalized field element.
149
+ * Returns (int(a) mod p) & 1.
150
+ */
146
151
static int secp256k1_fe_is_odd (const secp256k1_fe * a );
147
152
148
153
/** Compare two field elements. Requires magnitude-1 inputs. */
Original file line number Diff line number Diff line change @@ -274,11 +274,7 @@ SECP256K1_INLINE static int secp256k1_fe_impl_is_zero(const secp256k1_fe *a) {
274
274
return (t [0 ] | t [1 ] | t [2 ] | t [3 ] | t [4 ] | t [5 ] | t [6 ] | t [7 ] | t [8 ] | t [9 ]) == 0 ;
275
275
}
276
276
277
- SECP256K1_INLINE static int secp256k1_fe_is_odd (const secp256k1_fe * a ) {
278
- #ifdef VERIFY
279
- VERIFY_CHECK (a -> normalized );
280
- secp256k1_fe_verify (a );
281
- #endif
277
+ SECP256K1_INLINE static int secp256k1_fe_impl_is_odd (const secp256k1_fe * a ) {
282
278
return a -> n [0 ] & 1 ;
283
279
}
284
280
Original file line number Diff line number Diff line change @@ -220,11 +220,7 @@ SECP256K1_INLINE static int secp256k1_fe_impl_is_zero(const secp256k1_fe *a) {
220
220
return (t [0 ] | t [1 ] | t [2 ] | t [3 ] | t [4 ]) == 0 ;
221
221
}
222
222
223
- SECP256K1_INLINE static int secp256k1_fe_is_odd (const secp256k1_fe * a ) {
224
- #ifdef VERIFY
225
- VERIFY_CHECK (a -> normalized );
226
- secp256k1_fe_verify (a );
227
- #endif
223
+ SECP256K1_INLINE static int secp256k1_fe_impl_is_odd (const secp256k1_fe * a ) {
228
224
return a -> n [0 ] & 1 ;
229
225
}
230
226
Original file line number Diff line number Diff line change @@ -209,6 +209,13 @@ SECP256K1_INLINE static int secp256k1_fe_is_zero(const secp256k1_fe *a) {
209
209
VERIFY_CHECK (a -> normalized );
210
210
return secp256k1_fe_impl_is_zero (a );
211
211
}
212
+
213
+ static int secp256k1_fe_impl_is_odd (const secp256k1_fe * a );
214
+ SECP256K1_INLINE static int secp256k1_fe_is_odd (const secp256k1_fe * a ) {
215
+ secp256k1_fe_verify (a );
216
+ VERIFY_CHECK (a -> normalized );
217
+ return secp256k1_fe_impl_is_odd (a );
218
+ }
212
219
#endif /* defined(VERIFY) */
213
220
214
221
#endif /* SECP256K1_FIELD_IMPL_H */
You can’t perform that action at this time.
0 commit comments