Skip to content

Commit b19ec75

Browse files
Replace ECMULT_TABLE_GET_GE_STORAGE macro with a function.
1 parent a49f636 commit b19ec75

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/ecmult_impl.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,17 @@ SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_lambda(secp256k1_ge *
137137
}
138138
}
139139

140-
#define ECMULT_TABLE_GET_GE_STORAGE(r,pre,n,w) do { \
141-
VERIFY_CHECK(((n) & 1) == 1); \
142-
VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \
143-
VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \
144-
if ((n) > 0) { \
145-
secp256k1_ge_from_storage((r), &(pre)[((n)-1)/2]); \
146-
} else { \
147-
secp256k1_ge_from_storage((r), &(pre)[(-(n)-1)/2]); \
148-
secp256k1_fe_negate(&((r)->y), &((r)->y), 1); \
149-
} \
150-
} while(0)
140+
SECP256K1_INLINE static void secp256k1_ecmult_table_get_ge_storage(secp256k1_ge *r, const secp256k1_ge_storage *pre, int n, int w) {
141+
VERIFY_CHECK((n & 1) == 1);
142+
VERIFY_CHECK(n >= -((1 << (w-1)) - 1));
143+
VERIFY_CHECK(n <= ((1 << (w-1)) - 1));
144+
if (n > 0) {
145+
secp256k1_ge_from_storage(r, &pre[(n-1)/2]);
146+
} else {
147+
secp256k1_ge_from_storage(r, &pre[(-n-1)/2]);
148+
secp256k1_fe_negate(&(r->y), &(r->y), 1);
149+
}
150+
}
151151

152152
/** Convert a number to WNAF notation. The number becomes represented by sum(2^i * wnaf[i], i=0..bits),
153153
* with the following guarantees:
@@ -321,11 +321,11 @@ static void secp256k1_ecmult_strauss_wnaf(const struct secp256k1_strauss_state *
321321
}
322322
}
323323
if (i < bits_ng_1 && (n = wnaf_ng_1[i])) {
324-
ECMULT_TABLE_GET_GE_STORAGE(&tmpa, secp256k1_pre_g, n, WINDOW_G);
324+
secp256k1_ecmult_table_get_ge_storage(&tmpa, secp256k1_pre_g, n, WINDOW_G);
325325
secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z);
326326
}
327327
if (i < bits_ng_128 && (n = wnaf_ng_128[i])) {
328-
ECMULT_TABLE_GET_GE_STORAGE(&tmpa, secp256k1_pre_g_128, n, WINDOW_G);
328+
secp256k1_ecmult_table_get_ge_storage(&tmpa, secp256k1_pre_g_128, n, WINDOW_G);
329329
secp256k1_gej_add_zinv_var(r, r, &tmpa, &Z);
330330
}
331331
}

0 commit comments

Comments
 (0)