From 353c1bf0d744ba9b456ff51d80200de1191baebb Mon Sep 17 00:00:00 2001 From: llamasoft Date: Tue, 26 Jul 2016 11:53:29 -0500 Subject: [PATCH] Fix secp256k1_ge_set_table_gej_var parameter order Rearranged secp256k1_ge_set_table_gej_var parameters so length comes last (it modifies both *a and *zr). --- src/ecmult_impl.h | 2 +- src/group.h | 2 +- src/group_impl.h | 2 +- src/tests.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h index e6e5f47..f5e6513 100644 --- a/src/ecmult_impl.h +++ b/src/ecmult_impl.h @@ -101,7 +101,7 @@ static void secp256k1_ecmult_odd_multiples_table_storage_var(int n, secp256k1_ge /* Compute the odd multiples in Jacobian form. */ secp256k1_ecmult_odd_multiples_table(n, prej, zr, a); /* Convert them in batch to affine coordinates. */ - secp256k1_ge_set_table_gej_var(n, prea, prej, zr); + secp256k1_ge_set_table_gej_var(prea, prej, zr, n); /* Convert them to compact storage form. */ for (i = 0; i < n; i++) { secp256k1_ge_to_storage(&pre[i], &prea[i]); diff --git a/src/group.h b/src/group.h index 02a7eba..4957b24 100644 --- a/src/group.h +++ b/src/group.h @@ -70,7 +70,7 @@ static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a /** Set a batch of group elements equal to the inputs given in jacobian * coordinates (with known z-ratios). zr must contain the known z-ratios such * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. */ -static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr); +static void secp256k1_ge_set_table_gej_var(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr, size_t len); /** Bring a batch inputs given in jacobian coordinates (with known z-ratios) to * the same global z "denominator". zr must contain the known z-ratios such diff --git a/src/group_impl.h b/src/group_impl.h index d2c07a9..18f2b37 100644 --- a/src/group_impl.h +++ b/src/group_impl.h @@ -102,7 +102,7 @@ static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a free(azi); } -static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr) { +static void secp256k1_ge_set_table_gej_var(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr, size_t len) { size_t i = len - 1; secp256k1_fe zi; diff --git a/src/tests.c b/src/tests.c index 7d99bb9..9ae7d30 100644 --- a/src/tests.c +++ b/src/tests.c @@ -2050,7 +2050,7 @@ void test_ge(void) { secp256k1_fe_mul(&zr[i + 1], &zinv[i], &gej[i + 1].z); } } - secp256k1_ge_set_table_gej_var(4 * runs + 1, ge_set_table, gej, zr); + secp256k1_ge_set_table_gej_var(ge_set_table, gej, zr, 4 * runs + 1); secp256k1_ge_set_all_gej_var(ge_set_all, gej, 4 * runs + 1, &ctx->error_callback); for (i = 0; i < 4 * runs + 1; i++) { secp256k1_fe s;