Bitcoin ABC 0.30.7
P2P Digital Currency
Macros | Functions
ecmult_const_impl.h File Reference
#include "scalar.h"
#include "group.h"
#include "ecmult_const.h"
#include "ecmult_impl.h"
Include dependency graph for ecmult_const_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ECMULT_CONST_TABLE_GET_GE(r, pre, n, w)
 

Functions

static int secp256k1_wnaf_const (int *wnaf, const secp256k1_scalar *scalar, int w, int size)
 Convert a number to WNAF notation. More...
 
static void secp256k1_ecmult_const (secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar, int size)
 

Macro Definition Documentation

◆ ECMULT_CONST_TABLE_GET_GE

#define ECMULT_CONST_TABLE_GET_GE (   r,
  pre,
  n,
 
)
Value:
do { \
int m = 0; \
/* Extract the sign-bit for a constant time absolute-value. */ \
int mask = (n) >> (sizeof(n) * CHAR_BIT - 1); \
int abs_n = ((n) + mask) ^ mask; \
int idx_n = abs_n >> 1; \
secp256k1_fe neg_y; \
VERIFY_CHECK(((n) & 1) == 1); \
VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \
VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \
VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \
VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \
/* Unconditionally set r->x = (pre)[m].x. r->y = (pre)[m].y. because it's either the correct one \
* or will get replaced in the later iterations, this is needed to make sure `r` is initialized. */ \
(r)->x = (pre)[m].x; \
(r)->y = (pre)[m].y; \
for (m = 1; m < ECMULT_TABLE_SIZE(w); m++) { \
/* This loop is used to avoid secret data in array indices. See
* the comment in ecmult_gen_impl.h for rationale. */ \
secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \
secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \
} \
(r)->infinity = 0; \
secp256k1_fe_negate(&neg_y, &(r)->y, 1); \
secp256k1_fe_cmov(&(r)->y, &neg_y, (n) != abs_n); \
} while(0)
#define ECMULT_TABLE_SIZE(w)
The number of entries a table with precomputed multiples needs to have.
Definition: ecmult_impl.h:67
static void secp256k1_fe_clear(secp256k1_fe *a)
Sets a field element equal to zero, initializing all fields.

Definition at line 16 of file ecmult_const_impl.h.

Function Documentation

◆ secp256k1_ecmult_const()

static void secp256k1_ecmult_const ( secp256k1_gej r,
const secp256k1_ge a,
const secp256k1_scalar scalar,
int  size 
)
static

Definition at line 135 of file ecmult_const_impl.h.

◆ secp256k1_wnaf_const()

static int secp256k1_wnaf_const ( int *  wnaf,
const secp256k1_scalar scalar,
int  w,
int  size 
)
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:

  • each wnaf[i] an odd integer between -(1 << w) and (1 << w)
  • each wnaf[i] is nonzero
  • the number of words set is always WNAF_SIZE(w) + 1

Adapted from The Width-w NAF Method Provides Small Memory and Fast Elliptic Scalar Multiplications Secure against Side Channel Attacks, Okeya and Tagaki. M. Joye (Ed.) CT-RSA 2003, LNCS 2612, pp. 328-443, 2003. Springer-Verlag Berlin Heidelberg 2003

Numbers reference steps of Algorithm SPA-resistant Width-w NAF with Odd Scalar on pp. 335

Definition at line 55 of file ecmult_const_impl.h.

Here is the caller graph for this function: