Skip to content

Commit 5bb03c2

Browse files
committed
Replace SECP256K1_ECMULT_TABLE_VERIFY macro by a function
1 parent 4429a8c commit 5bb03c2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ecmult_impl.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,16 @@ static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_ge *pre_a, sec
114114
secp256k1_fe_mul(z, &ai.z, &d.z);
115115
}
116116

117-
#define SECP256K1_ECMULT_TABLE_VERIFY(n,w) \
118-
(void)w; \
119-
VERIFY_CHECK(((n) & 1) == 1); \
120-
VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \
117+
SECP256K1_INLINE static void secp256k1_ecmult_table_verify(int n, int w) {
118+
(void)n;
119+
(void)w;
120+
VERIFY_CHECK(((n) & 1) == 1);
121+
VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1));
121122
VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1));
123+
}
122124

123125
SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge(secp256k1_ge *r, const secp256k1_ge *pre, int n, int w) {
124-
SECP256K1_ECMULT_TABLE_VERIFY(n,w)
126+
secp256k1_ecmult_table_verify(n,w);
125127
if (n > 0) {
126128
*r = pre[(n-1)/2];
127129
} else {
@@ -131,7 +133,7 @@ SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge(secp256k1_ge *r, cons
131133
}
132134

133135
SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_lambda(secp256k1_ge *r, const secp256k1_ge *pre, const secp256k1_fe *x, int n, int w) {
134-
SECP256K1_ECMULT_TABLE_VERIFY(n,w)
136+
secp256k1_ecmult_table_verify(n,w);
135137
if (n > 0) {
136138
secp256k1_ge_set_xy(r, &x[(n-1)/2], &pre[(n-1)/2].y);
137139
} else {
@@ -141,7 +143,7 @@ SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_lambda(secp256k1_ge *
141143
}
142144

143145
SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_storage(secp256k1_ge *r, const secp256k1_ge_storage *pre, int n, int w) {
144-
SECP256K1_ECMULT_TABLE_VERIFY(n,w)
146+
secp256k1_ecmult_table_verify(n,w);
145147
if (n > 0) {
146148
secp256k1_ge_from_storage(r, &pre[(n-1)/2]);
147149
} else {

0 commit comments

Comments
 (0)