Bitcoin ABC  0.28.12
P2P Digital Currency
Macros | Functions | Variables
scalar_8x32_impl.h File Reference
#include "modinv32_impl.h"
Include dependency graph for scalar_8x32_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SECP256K1_N_0   ((uint32_t)0xD0364141UL)
 
#define SECP256K1_N_1   ((uint32_t)0xBFD25E8CUL)
 
#define SECP256K1_N_2   ((uint32_t)0xAF48A03BUL)
 
#define SECP256K1_N_3   ((uint32_t)0xBAAEDCE6UL)
 
#define SECP256K1_N_4   ((uint32_t)0xFFFFFFFEUL)
 
#define SECP256K1_N_5   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_6   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_7   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_C_0   (~SECP256K1_N_0 + 1)
 
#define SECP256K1_N_C_1   (~SECP256K1_N_1)
 
#define SECP256K1_N_C_2   (~SECP256K1_N_2)
 
#define SECP256K1_N_C_3   (~SECP256K1_N_3)
 
#define SECP256K1_N_C_4   (1)
 
#define SECP256K1_N_H_0   ((uint32_t)0x681B20A0UL)
 
#define SECP256K1_N_H_1   ((uint32_t)0xDFE92F46UL)
 
#define SECP256K1_N_H_2   ((uint32_t)0x57A4501DUL)
 
#define SECP256K1_N_H_3   ((uint32_t)0x5D576E73UL)
 
#define SECP256K1_N_H_4   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_H_5   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_H_6   ((uint32_t)0xFFFFFFFFUL)
 
#define SECP256K1_N_H_7   ((uint32_t)0x7FFFFFFFUL)
 
#define muladd(a, b)
 Add a*b to the number defined by (c0,c1,c2). More...
 
#define muladd_fast(a, b)
 Add a*b to the number defined by (c0,c1). More...
 
#define sumadd(a)
 Add a to the number defined by (c0,c1,c2). More...
 
#define sumadd_fast(a)
 Add a to the number defined by (c0,c1). More...
 
#define extract(n)
 Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. More...
 
#define extract_fast(n)
 Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits. More...
 

Functions

static SECP256K1_INLINE void secp256k1_scalar_clear (secp256k1_scalar *r)
 
static SECP256K1_INLINE void secp256k1_scalar_set_int (secp256k1_scalar *r, unsigned int v)
 
static SECP256K1_INLINE unsigned int secp256k1_scalar_get_bits (const secp256k1_scalar *a, unsigned int offset, unsigned int count)
 
static SECP256K1_INLINE unsigned int secp256k1_scalar_get_bits_var (const secp256k1_scalar *a, unsigned int offset, unsigned int count)
 
static SECP256K1_INLINE int secp256k1_scalar_check_overflow (const secp256k1_scalar *a)
 
static SECP256K1_INLINE int secp256k1_scalar_reduce (secp256k1_scalar *r, uint32_t overflow)
 
static int secp256k1_scalar_add (secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
 
static void secp256k1_scalar_cadd_bit (secp256k1_scalar *r, unsigned int bit, int flag)
 
static void secp256k1_scalar_set_b32 (secp256k1_scalar *r, const unsigned char *b32, int *overflow)
 
static void secp256k1_scalar_get_b32 (unsigned char *bin, const secp256k1_scalar *a)
 
static SECP256K1_INLINE int secp256k1_scalar_is_zero (const secp256k1_scalar *a)
 
static void secp256k1_scalar_negate (secp256k1_scalar *r, const secp256k1_scalar *a)
 
static SECP256K1_INLINE int secp256k1_scalar_is_one (const secp256k1_scalar *a)
 
static int secp256k1_scalar_is_high (const secp256k1_scalar *a)
 
static int secp256k1_scalar_cond_negate (secp256k1_scalar *r, int flag)
 
static void secp256k1_scalar_reduce_512 (secp256k1_scalar *r, const uint32_t *l)
 
static void secp256k1_scalar_mul_512 (uint32_t *l, const secp256k1_scalar *a, const secp256k1_scalar *b)
 
static void secp256k1_scalar_mul (secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
 
static int secp256k1_scalar_shr_int (secp256k1_scalar *r, int n)
 
static void secp256k1_scalar_split_128 (secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *k)
 
static SECP256K1_INLINE int secp256k1_scalar_eq (const secp256k1_scalar *a, const secp256k1_scalar *b)
 
static SECP256K1_INLINE void secp256k1_scalar_mul_shift_var (secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift)
 
static SECP256K1_INLINE void secp256k1_scalar_cmov (secp256k1_scalar *r, const secp256k1_scalar *a, int flag)
 
static void secp256k1_scalar_from_signed30 (secp256k1_scalar *r, const secp256k1_modinv32_signed30 *a)
 
static void secp256k1_scalar_to_signed30 (secp256k1_modinv32_signed30 *r, const secp256k1_scalar *a)
 
static void secp256k1_scalar_inverse (secp256k1_scalar *r, const secp256k1_scalar *x)
 
static void secp256k1_scalar_inverse_var (secp256k1_scalar *r, const secp256k1_scalar *x)
 
static SECP256K1_INLINE int secp256k1_scalar_is_even (const secp256k1_scalar *a)
 

Variables

static const secp256k1_modinv32_modinfo secp256k1_const_modinfo_scalar
 

Macro Definition Documentation

◆ extract

#define extract (   n)
Value:
{ \
(n) = c0; \
c0 = c1; \
c1 = c2; \
c2 = 0; \
}

Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits.

Definition at line 314 of file scalar_8x32_impl.h.

◆ extract_fast

#define extract_fast (   n)
Value:
{ \
(n) = c0; \
c0 = c1; \
c1 = 0; \
VERIFY_CHECK(c2 == 0); \
}

Extract the lowest 32 bits of (c0,c1,c2) into n, and left shift the number 32 bits.

c2 is required to be zero.

Definition at line 322 of file scalar_8x32_impl.h.

◆ muladd

#define muladd (   a,
 
)
Value:
{ \
uint32_t tl, th; \
{ \
uint64_t t = (uint64_t)a * b; \
th = t >> 32; /* at most 0xFFFFFFFE */ \
tl = t; \
} \
c0 += tl; /* overflow is handled on the next line */ \
th += (c0 < tl); /* at most 0xFFFFFFFF */ \
c1 += th; /* overflow is handled on the next line */ \
c2 += (c1 < th); /* never overflows by contract (verified in the next line) */ \
VERIFY_CHECK((c1 >= th) || (c2 != 0)); \
}

Add a*b to the number defined by (c0,c1,c2).

c2 must never overflow.

Definition at line 268 of file scalar_8x32_impl.h.

◆ muladd_fast

#define muladd_fast (   a,
 
)
Value:
{ \
uint32_t tl, th; \
{ \
uint64_t t = (uint64_t)a * b; \
th = t >> 32; /* at most 0xFFFFFFFE */ \
tl = t; \
} \
c0 += tl; /* overflow is handled on the next line */ \
th += (c0 < tl); /* at most 0xFFFFFFFF */ \
c1 += th; /* never overflows by contract (verified in the next line) */ \
VERIFY_CHECK(c1 >= th); \
}

Add a*b to the number defined by (c0,c1).

c1 must never overflow.

Definition at line 283 of file scalar_8x32_impl.h.

◆ SECP256K1_N_0

#define SECP256K1_N_0   ((uint32_t)0xD0364141UL)

Definition at line 13 of file scalar_8x32_impl.h.

◆ SECP256K1_N_1

#define SECP256K1_N_1   ((uint32_t)0xBFD25E8CUL)

Definition at line 14 of file scalar_8x32_impl.h.

◆ SECP256K1_N_2

#define SECP256K1_N_2   ((uint32_t)0xAF48A03BUL)

Definition at line 15 of file scalar_8x32_impl.h.

◆ SECP256K1_N_3

#define SECP256K1_N_3   ((uint32_t)0xBAAEDCE6UL)

Definition at line 16 of file scalar_8x32_impl.h.

◆ SECP256K1_N_4

#define SECP256K1_N_4   ((uint32_t)0xFFFFFFFEUL)

Definition at line 17 of file scalar_8x32_impl.h.

◆ SECP256K1_N_5

#define SECP256K1_N_5   ((uint32_t)0xFFFFFFFFUL)

Definition at line 18 of file scalar_8x32_impl.h.

◆ SECP256K1_N_6

#define SECP256K1_N_6   ((uint32_t)0xFFFFFFFFUL)

Definition at line 19 of file scalar_8x32_impl.h.

◆ SECP256K1_N_7

#define SECP256K1_N_7   ((uint32_t)0xFFFFFFFFUL)

Definition at line 20 of file scalar_8x32_impl.h.

◆ SECP256K1_N_C_0

#define SECP256K1_N_C_0   (~SECP256K1_N_0 + 1)

Definition at line 23 of file scalar_8x32_impl.h.

◆ SECP256K1_N_C_1

#define SECP256K1_N_C_1   (~SECP256K1_N_1)

Definition at line 24 of file scalar_8x32_impl.h.

◆ SECP256K1_N_C_2

#define SECP256K1_N_C_2   (~SECP256K1_N_2)

Definition at line 25 of file scalar_8x32_impl.h.

◆ SECP256K1_N_C_3

#define SECP256K1_N_C_3   (~SECP256K1_N_3)

Definition at line 26 of file scalar_8x32_impl.h.

◆ SECP256K1_N_C_4

#define SECP256K1_N_C_4   (1)

Definition at line 27 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_0

#define SECP256K1_N_H_0   ((uint32_t)0x681B20A0UL)

Definition at line 30 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_1

#define SECP256K1_N_H_1   ((uint32_t)0xDFE92F46UL)

Definition at line 31 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_2

#define SECP256K1_N_H_2   ((uint32_t)0x57A4501DUL)

Definition at line 32 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_3

#define SECP256K1_N_H_3   ((uint32_t)0x5D576E73UL)

Definition at line 33 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_4

#define SECP256K1_N_H_4   ((uint32_t)0xFFFFFFFFUL)

Definition at line 34 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_5

#define SECP256K1_N_H_5   ((uint32_t)0xFFFFFFFFUL)

Definition at line 35 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_6

#define SECP256K1_N_H_6   ((uint32_t)0xFFFFFFFFUL)

Definition at line 36 of file scalar_8x32_impl.h.

◆ SECP256K1_N_H_7

#define SECP256K1_N_H_7   ((uint32_t)0x7FFFFFFFUL)

Definition at line 37 of file scalar_8x32_impl.h.

◆ sumadd

#define sumadd (   a)
Value:
{ \
unsigned int over; \
c0 += (a); /* overflow is handled on the next line */ \
over = (c0 < (a)); \
c1 += over; /* overflow is handled on the next line */ \
c2 += (c1 < over); /* never overflows by contract */ \
}

Add a to the number defined by (c0,c1,c2).

c2 must never overflow.

Definition at line 297 of file scalar_8x32_impl.h.

◆ sumadd_fast

#define sumadd_fast (   a)
Value:
{ \
c0 += (a); /* overflow is handled on the next line */ \
c1 += (c0 < (a)); /* never overflows by contract (verified the next line) */ \
VERIFY_CHECK((c1 != 0) | (c0 >= (a))); \
VERIFY_CHECK(c2 == 0); \
}

Add a to the number defined by (c0,c1).

c1 must never overflow, c2 must be zero.

Definition at line 306 of file scalar_8x32_impl.h.

Function Documentation

◆ secp256k1_scalar_add()

static int secp256k1_scalar_add ( secp256k1_scalar r,
const secp256k1_scalar a,
const secp256k1_scalar b 
)
static

Definition at line 117 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_cadd_bit()

static void secp256k1_scalar_cadd_bit ( secp256k1_scalar r,
unsigned int  bit,
int  flag 
)
static

Definition at line 141 of file scalar_8x32_impl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secp256k1_scalar_check_overflow()

static SECP256K1_INLINE int secp256k1_scalar_check_overflow ( const secp256k1_scalar a)
static

Definition at line 77 of file scalar_8x32_impl.h.

Here is the caller graph for this function:

◆ secp256k1_scalar_clear()

static SECP256K1_INLINE void secp256k1_scalar_clear ( secp256k1_scalar r)
static

Definition at line 39 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_cmov()

static SECP256K1_INLINE void secp256k1_scalar_cmov ( secp256k1_scalar r,
const secp256k1_scalar a,
int  flag 
)
static

Definition at line 632 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_cond_negate()

static int secp256k1_scalar_cond_negate ( secp256k1_scalar r,
int  flag 
)
static

Definition at line 240 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_eq()

static SECP256K1_INLINE int secp256k1_scalar_eq ( const secp256k1_scalar a,
const secp256k1_scalar b 
)
static

Definition at line 607 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_from_signed30()

static void secp256k1_scalar_from_signed30 ( secp256k1_scalar r,
const secp256k1_modinv32_signed30 a 
)
static

Definition at line 647 of file scalar_8x32_impl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secp256k1_scalar_get_b32()

static void secp256k1_scalar_get_b32 ( unsigned char *  bin,
const secp256k1_scalar a 
)
static

Definition at line 183 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_get_bits()

static SECP256K1_INLINE unsigned int secp256k1_scalar_get_bits ( const secp256k1_scalar a,
unsigned int  offset,
unsigned int  count 
)
static

Definition at line 61 of file scalar_8x32_impl.h.

Here is the caller graph for this function:

◆ secp256k1_scalar_get_bits_var()

static SECP256K1_INLINE unsigned int secp256k1_scalar_get_bits_var ( const secp256k1_scalar a,
unsigned int  offset,
unsigned int  count 
)
static

Definition at line 66 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_inverse()

static void secp256k1_scalar_inverse ( secp256k1_scalar r,
const secp256k1_scalar x 
)
static

Definition at line 703 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_inverse_var()

static void secp256k1_scalar_inverse_var ( secp256k1_scalar r,
const secp256k1_scalar x 
)
static

Definition at line 717 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_is_even()

static SECP256K1_INLINE int secp256k1_scalar_is_even ( const secp256k1_scalar a)
static

Definition at line 731 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_is_high()

static int secp256k1_scalar_is_high ( const secp256k1_scalar a)
static

Definition at line 222 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_is_one()

static SECP256K1_INLINE int secp256k1_scalar_is_one ( const secp256k1_scalar a)
static

Definition at line 218 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_is_zero()

static SECP256K1_INLINE int secp256k1_scalar_is_zero ( const secp256k1_scalar a)
static

Definition at line 194 of file scalar_8x32_impl.h.

Here is the caller graph for this function:

◆ secp256k1_scalar_mul()

static void secp256k1_scalar_mul ( secp256k1_scalar r,
const secp256k1_scalar a,
const secp256k1_scalar b 
)
static

Definition at line 566 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_mul_512()

static void secp256k1_scalar_mul_512 ( uint32_t *  l,
const secp256k1_scalar a,
const secp256k1_scalar b 
)
static

Definition at line 471 of file scalar_8x32_impl.h.

Here is the caller graph for this function:

◆ secp256k1_scalar_mul_shift_var()

static SECP256K1_INLINE void secp256k1_scalar_mul_shift_var ( secp256k1_scalar r,
const secp256k1_scalar a,
const secp256k1_scalar b,
unsigned int  shift 
)
static

Definition at line 611 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_negate()

static void secp256k1_scalar_negate ( secp256k1_scalar r,
const secp256k1_scalar a 
)
static

Definition at line 198 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_reduce()

static SECP256K1_INLINE int secp256k1_scalar_reduce ( secp256k1_scalar r,
uint32_t  overflow 
)
static

Definition at line 95 of file scalar_8x32_impl.h.

Here is the caller graph for this function:

◆ secp256k1_scalar_reduce_512()

static void secp256k1_scalar_reduce_512 ( secp256k1_scalar r,
const uint32_t *  l 
)
static

Definition at line 329 of file scalar_8x32_impl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secp256k1_scalar_set_b32()

static void secp256k1_scalar_set_b32 ( secp256k1_scalar r,
const unsigned char *  b32,
int *  overflow 
)
static

Definition at line 167 of file scalar_8x32_impl.h.

Here is the call graph for this function:

◆ secp256k1_scalar_set_int()

static SECP256K1_INLINE void secp256k1_scalar_set_int ( secp256k1_scalar r,
unsigned int  v 
)
static

Definition at line 50 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_shr_int()

static int secp256k1_scalar_shr_int ( secp256k1_scalar r,
int  n 
)
static

Definition at line 572 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_split_128()

static void secp256k1_scalar_split_128 ( secp256k1_scalar r1,
secp256k1_scalar r2,
const secp256k1_scalar k 
)
static

Definition at line 588 of file scalar_8x32_impl.h.

◆ secp256k1_scalar_to_signed30()

static void secp256k1_scalar_to_signed30 ( secp256k1_modinv32_signed30 r,
const secp256k1_scalar a 
)
static

Definition at line 678 of file scalar_8x32_impl.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ secp256k1_const_modinfo_scalar

const secp256k1_modinv32_modinfo secp256k1_const_modinfo_scalar
static
Initial value:
= {
{{0x10364141L, 0x3F497A33L, 0x348A03BBL, 0x2BB739ABL, -0x146L, 0, 0, 0, 65536}},
0x2A774EC1L
}

Definition at line 698 of file scalar_8x32_impl.h.