Skip to content

Commit 355a38f

Browse files
committed
Add pippenger_wnaf ecmult_multi
1 parent bc65aa7 commit 355a38f

6 files changed

+612
-76
lines changed

src/bench_ecmult.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void bench_ecmult(void* arg) {
6363
size_t iter;
6464

6565
for (iter = 0; iter < iters; ++iter) {
66-
secp256k1_ecmult_multi(&data->ctx->ecmult_ctx, data->scratch, &data->output[iter], data->includes_g ? &data->scalars[data->offset1] : NULL, bench_callback, arg, count - includes_g);
66+
secp256k1_ecmult_multi_var(&data->ctx->ecmult_ctx, data->scratch, &data->output[iter], data->includes_g ? &data->scalars[data->offset1] : NULL, bench_callback, arg, count - includes_g);
6767
data->offset1 = (data->offset1 + count) % POINTS;
6868
data->offset2 = (data->offset2 + count - 1) % POINTS;
6969
}

src/ecmult.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej
3232

3333
typedef int (secp256k1_ecmult_multi_callback)(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *data);
3434

35-
/** Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai. */
36-
static int secp256k1_ecmult_multi(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n);
35+
/**
36+
* Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai.
37+
* Returns: 1 on success (including when inp_g_sc is NULL and n is 0)
38+
* 0 if there is not enough scratch space for a single point or
39+
* callback returns 0
40+
*/
41+
static int secp256k1_ecmult_multi_var(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n);
3742

3843
#endif /* SECP256K1_ECMULT_H */

src/ecmult_const_impl.h

-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212
#include "ecmult_const.h"
1313
#include "ecmult_impl.h"
1414

15-
#ifdef USE_ENDOMORPHISM
16-
#define WNAF_BITS 128
17-
#else
18-
#define WNAF_BITS 256
19-
#endif
20-
#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w))
21-
2215
/* This is like `ECMULT_TABLE_GET_GE` but is constant time */
2316
#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \
2417
int m; \

0 commit comments

Comments
 (0)