ecmult: Use size_t for array indices in _odd_multiplies_table
What changed, and why it matters
This commit changes two variable types from signed integers (int) to unsigned size types (size_t) inside a low-level elliptic-curve multiplication helper. It is a code-quality/correctness cleanup with no observable security effect: the values are always non-negative and small, and the change does not fix a bug that could be triggered by an attacker.
No security action required. Treat as a normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/ecmult_impl.h, secp256k1_ecmult_odd_multiples_table’s parameter n and loop index i are changed from int to size_t. This matches the convention of using size_t for array indexing/counting and avoids implicit signed/unsigned comparisons, but the function is only called with small, fixed, positive counts (e.g., ECMULT_TABLE_SIZE). There is no overflow, underflow, or out-of-bounds access being fixed, and no change to logic or bounds checks.
Changed components
src/ecmult_impl.hsecp256k1_ecmult_odd_multiples_tableInspect captured patch +2 / −2
diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h
index 4046cd4..1a05244 100644
--- a/src/ecmult_impl.h
+++ b/src/ecmult_impl.h
@@ -70,10 +70,10 @@
* Lastly the zr[0] value, which isn't used above, is set so that:
* - a.z = z(pre_a[0]) / zr[0]
*/
-static void secp256k1_ecmult_odd_multiples_table(int n, secp256k1_ge *pre_a, secp256k1_fe *zr, secp256k1_fe *z, const secp256k1_gej *a) {
+static void secp256k1_ecmult_odd_multiples_table(size_t n, secp256k1_ge *pre_a, secp256k1_fe *zr, secp256k1_fe *z, const secp256k1_gej *a) {
secp256k1_gej d, ai;
secp256k1_ge d_ge;
- int i;
+ size_t i;
VERIFY_CHECK(!secp256k1_gej_is_infinity(a));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.