Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
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)
 

Macro Definition Documentation

◆ ECMULT_CONST_TABLE_GET_GE

#define ECMULT_CONST_TABLE_GET_GE ( r,
pre,
n,
w )
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)
const mie::Vuint & r
Definition bn.cpp:28
#define ECMULT_TABLE_SIZE(w)
Definition ecmult.h:30

Definition at line 29 of file ecmult_const_impl.h.

29#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \
30 int m = 0; \
31 /* Extract the sign-bit for a constant time absolute-value. */ \
32 int mask = (n) >> (sizeof(n) * CHAR_BIT - 1); \
33 int abs_n = ((n) + mask) ^ mask; \
34 int idx_n = abs_n >> 1; \
35 secp256k1_fe neg_y; \
36 VERIFY_CHECK(((n) & 1) == 1); \
37 VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \
38 VERIFY_CHECK((n) <= ((1 << ((w)-1)) - 1)); \
39 VERIFY_SETUP(secp256k1_fe_clear(&(r)->x)); \
40 VERIFY_SETUP(secp256k1_fe_clear(&(r)->y)); \
41 /* Unconditionally set r->x = (pre)[m].x. r->y = (pre)[m].y. because it's either the correct one \
42 * or will get replaced in the later iterations, this is needed to make sure `r` is initialized. */ \
43 (r)->x = (pre)[m].x; \
44 (r)->y = (pre)[m].y; \
45 for (m = 1; m < ECMULT_TABLE_SIZE(w); m++) { \
46 /* This loop is used to avoid secret data in array indices. See
47 * the comment in ecmult_gen_impl.h for rationale. */ \
48 secp256k1_fe_cmov(&(r)->x, &(pre)[m].x, m == idx_n); \
49 secp256k1_fe_cmov(&(r)->y, &(pre)[m].y, m == idx_n); \
50 } \
51 (r)->infinity = 0; \
52 secp256k1_fe_negate(&neg_y, &(r)->y, 1); \