![]() |
Bitcoin ABC 0.32.7
P2P Digital Currency
|
#include <string.h>#include <stdint.h>#include "util.h"#include "group.h"#include "scalar.h"#include "ecmult.h"#include "precomputed_ecmult.h"Go to the source code of this file.
Classes | |
| struct | secp256k1_strauss_point_state |
| struct | secp256k1_strauss_state |
| struct | secp256k1_pippenger_point_state |
| struct | secp256k1_pippenger_state |
Macros | |
| #define | WINDOW_A 5 |
| #define | WNAF_BITS 128 |
| Larger values for ECMULT_WINDOW_SIZE result in possibly better performance at the cost of an exponentially larger precomputed table. More... | |
| #define | WNAF_SIZE_BITS(bits, w) (((bits) + (w) - 1) / (w)) |
| #define | WNAF_SIZE(w) WNAF_SIZE_BITS(WNAF_BITS, w) |
| #define | PIPPENGER_SCRATCH_OBJECTS 6 |
| #define | STRAUSS_SCRATCH_OBJECTS 7 |
| #define | PIPPENGER_MAX_BUCKET_WINDOW 12 |
| #define | ECMULT_PIPPENGER_THRESHOLD 88 |
| #define | ECMULT_MAX_POINTS_PER_BATCH 5000000 |
| #define | ECMULT_TABLE_GET_GE(r, pre, n, w) |
| The following two macro retrieves a particular odd multiple from a table of precomputed multiples. More... | |
| #define | ECMULT_TABLE_GET_GE_STORAGE(r, pre, n, w) |
Typedefs | |
| typedef int(* | secp256k1_ecmult_multi_func) (const secp256k1_callback *error_callback, secp256k1_scratch *, secp256k1_gej *, const secp256k1_scalar *, secp256k1_ecmult_multi_callback cb, void *, size_t) |
Functions | |
| static void | secp256k1_ecmult_odd_multiples_table (int n, secp256k1_gej *prej, secp256k1_fe *zr, const secp256k1_gej *a) |
| Fill a table 'prej' with precomputed odd multiples of a. More... | |
| static int | secp256k1_ecmult_wnaf (int *wnaf, int len, const secp256k1_scalar *a, int w) |
| Convert a number to WNAF notation. More... | |
| static void | secp256k1_ecmult_strauss_wnaf (const struct secp256k1_strauss_state *state, secp256k1_gej *r, size_t num, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) |
| static void | secp256k1_ecmult (secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng) |
| static size_t | secp256k1_strauss_scratch_size (size_t n_points) |
| static int | secp256k1_ecmult_strauss_batch (const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points, size_t cb_offset) |
| static int | secp256k1_ecmult_strauss_batch_single (const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) |
| static size_t | secp256k1_strauss_max_points (const secp256k1_callback *error_callback, secp256k1_scratch *scratch) |
| static int | secp256k1_wnaf_fixed (int *wnaf, const secp256k1_scalar *s, int w) |
| Convert a number to WNAF notation. More... | |
| static int | secp256k1_ecmult_pippenger_wnaf (secp256k1_gej *buckets, int bucket_window, struct secp256k1_pippenger_state *state, secp256k1_gej *r, const secp256k1_scalar *sc, const secp256k1_ge *pt, size_t num) |
| static int | secp256k1_pippenger_bucket_window (size_t n) |
| Returns optimal bucket_window (number of bits of a scalar represented by a set of buckets) for a given number of points. More... | |
| static size_t | secp256k1_pippenger_bucket_window_inv (int bucket_window) |
| Returns the maximum optimal number of points for a bucket_window. More... | |
| static SECP256K1_INLINE void | secp256k1_ecmult_endo_split (secp256k1_scalar *s1, secp256k1_scalar *s2, secp256k1_ge *p1, secp256k1_ge *p2) |
| static size_t | secp256k1_pippenger_scratch_size (size_t n_points, int bucket_window) |
| Returns the scratch size required for a given number of points (excluding base point G) without considering alignment. More... | |
| static int | secp256k1_ecmult_pippenger_batch (const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points, size_t cb_offset) |
| static int | secp256k1_ecmult_pippenger_batch_single (const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) |
| static size_t | secp256k1_pippenger_max_points (const secp256k1_callback *error_callback, secp256k1_scratch *scratch) |
| Returns the maximum number of points in addition to G that can be used with a given scratch space. More... | |
| static int | secp256k1_ecmult_multi_simple_var (secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points) |
| static int | secp256k1_ecmult_multi_batch_size_helper (size_t *n_batches, size_t *n_batch_points, size_t max_n_batch_points, size_t n) |
| static int | secp256k1_ecmult_multi_var (const secp256k1_callback *error_callback, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n) |
| #define ECMULT_MAX_POINTS_PER_BATCH 5000000 |
Definition at line 57 of file ecmult_impl.h.
| #define ECMULT_PIPPENGER_THRESHOLD 88 |
Definition at line 55 of file ecmult_impl.h.
| #define ECMULT_TABLE_GET_GE | ( | r, | |
| pre, | |||
| n, | |||
| w | |||
| ) |
The following two macro retrieves a particular odd multiple from a table of precomputed multiples.
Definition at line 101 of file ecmult_impl.h.
| #define ECMULT_TABLE_GET_GE_STORAGE | ( | r, | |
| pre, | |||
| n, | |||
| w | |||
| ) |
Definition at line 113 of file ecmult_impl.h.
| #define PIPPENGER_MAX_BUCKET_WINDOW 12 |
Definition at line 52 of file ecmult_impl.h.
| #define PIPPENGER_SCRATCH_OBJECTS 6 |
Definition at line 49 of file ecmult_impl.h.
| #define STRAUSS_SCRATCH_OBJECTS 7 |
Definition at line 50 of file ecmult_impl.h.
| #define WINDOW_A 5 |
Definition at line 32 of file ecmult_impl.h.
| #define WNAF_BITS 128 |
Larger values for ECMULT_WINDOW_SIZE result in possibly better performance at the cost of an exponentially larger precomputed table.
The exact table size is (1 << (WINDOW_G - 2)) * sizeof(secp256k1_ge_storage) bytes, where sizeof(secp256k1_ge_storage) is typically 64 bytes but can be larger due to platform-specific padding and alignment. Two tables of this size are used (due to the endomorphism optimization).
Definition at line 44 of file ecmult_impl.h.
| #define WNAF_SIZE | ( | w | ) | WNAF_SIZE_BITS(WNAF_BITS, w) |
Definition at line 46 of file ecmult_impl.h.
| #define WNAF_SIZE_BITS | ( | bits, | |
| w | |||
| ) | (((bits) + (w) - 1) / (w)) |
Definition at line 45 of file ecmult_impl.h.
| typedef int(* secp256k1_ecmult_multi_func) (const secp256k1_callback *error_callback, secp256k1_scratch *, secp256k1_gej *, const secp256k1_scalar *, secp256k1_ecmult_multi_callback cb, void *, size_t) |
Definition at line 794 of file ecmult_impl.h.
|
static |
Definition at line 316 of file ecmult_impl.h.
|
static |
Definition at line 602 of file ecmult_impl.h.
|
static |
|
static |
Definition at line 749 of file ecmult_impl.h.
|
static |
|
static |
Fill a table 'prej' with precomputed odd multiples of a.
Prej will contain the values [1*a,3*a,...,(2*n-1)*a], so it space for n values. zr[0] will contain prej[0].z / a.z. The other zr[i] values = prej[i].z / prej[i-1].z. Prej's Z values are undefined, except for the last value.
Definition at line 64 of file ecmult_impl.h.
|
static |
Definition at line 627 of file ecmult_impl.h.
|
static |
Definition at line 704 of file ecmult_impl.h.
|
static |
Definition at line 473 of file ecmult_impl.h.
|
static |
Definition at line 337 of file ecmult_impl.h.
|
static |
Definition at line 379 of file ecmult_impl.h.
|
static |
Definition at line 201 of file ecmult_impl.h.
|
static |
Convert a number to WNAF notation.
The number becomes represented by sum(2^i * wnaf[i], i=0..bits), with the following guarantees:
Definition at line 132 of file ecmult_impl.h.
|
static |
Returns optimal bucket_window (number of bits of a scalar represented by a set of buckets) for a given number of points.
Definition at line 554 of file ecmult_impl.h.
|
static |
Returns the maximum optimal number of points for a bucket_window.
Definition at line 583 of file ecmult_impl.h.
|
static |
Returns the maximum number of points in addition to G that can be used with a given scratch space.
The function ensures that fewer points may also be used.
Definition at line 713 of file ecmult_impl.h.
|
static |
Returns the scratch size required for a given number of points (excluding base point G) without considering alignment.
Definition at line 621 of file ecmult_impl.h.
|
static |
Definition at line 383 of file ecmult_impl.h.
|
static |
|
static |
Convert a number to WNAF notation.
The number becomes represented by sum(2^{wi} * wnaf[i], i=0..WNAF_SIZE(w)+1) - return_val. It has the following guarantees:
Definition at line 394 of file ecmult_impl.h.