iPXE
|
Weierstrass elliptic curves. More...
Go to the source code of this file.
Data Structures | |
struct | weierstrass_curve |
A Weierstrass elliptic curve. More... | |
Macros | |
#define | WEIERSTRASS_AXES 2 |
Number of axes in Weierstrass curve point representation. More... | |
#define | WEIERSTRASS_MAX_MULTIPLE_LOG2 5 /* maximum reached is mod 20N */ |
Maximum multiple of field prime encountered during calculations. More... | |
#define | weierstrass_size(len) |
Determine number of elements in scalar values for a Weierstrass curve. More... | |
#define | weierstrass_t(size) |
Define a Weierstrass projective co-ordinate type. More... | |
#define | WEIERSTRASS_NUM_MONT 3 |
Number of cached in Montgomery form for each Weierstrass curve. More... | |
#define | WEIERSTRASS_NUM_CACHED |
Number of cached big integers for each Weierstrass curve. More... | |
#define | WEIERSTRASS_CURVE(_name, _curve, _len, _prime, _a, _b, _base) |
Define a Weierstrass curve. More... | |
Enumerations | |
enum | weierstrass_multiple { WEIERSTRASS_N = 0, WEIERSTRASS_2N, WEIERSTRASS_4N, WEIERSTRASS_NUM_MULTIPLES } |
Indexes for stored multiples of the field prime. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
int | weierstrass_multiply (struct weierstrass_curve *curve, const void *base, const void *scalar, void *result) |
Multiply curve point by scalar. More... | |
Weierstrass elliptic curves.
Definition in file weierstrass.h.
#define WEIERSTRASS_AXES 2 |
Number of axes in Weierstrass curve point representation.
Definition at line 16 of file weierstrass.h.
#define WEIERSTRASS_MAX_MULTIPLE_LOG2 5 /* maximum reached is mod 20N */ |
Maximum multiple of field prime encountered during calculations.
Calculations are performed using values modulo a small multiple of the field prime, rather than modulo the field prime itself. This allows explicit reductions after additions, subtractions, and relaxed Montgomery multiplications to be omitted entirely, provided that we keep careful track of the field prime multiple for each intermediate value.
Relaxed Montgomery multiplication will produce a result in the range t < (1+m/k)N, where m is this maximum multiple of the field prime, and k is the constant in R > kN representing the leading zero padding in the big integer representation of the field prime. We choose to set k=m so that multiplications will always produce a result in the range t < 2N.
This is expressed as the base-two logarithm of the multiple (rounded up), to simplify compile-time calculations.
Definition at line 38 of file weierstrass.h.
#define weierstrass_size | ( | len | ) |
Determine number of elements in scalar values for a Weierstrass curve.
len | Length of field prime, in bytes |
size | Number of elements |
Definition at line 46 of file weierstrass.h.
#define weierstrass_t | ( | size | ) |
Define a Weierstrass projective co-ordinate type.
size | Number of elements in scalar values |
weierstrass_t | Projective co-ordinate type |
Definition at line 57 of file weierstrass.h.
#define WEIERSTRASS_NUM_MONT 3 |
Number of cached in Montgomery form for each Weierstrass curve.
Definition at line 77 of file weierstrass.h.
#define WEIERSTRASS_NUM_CACHED |
Number of cached big integers for each Weierstrass curve.
Definition at line 80 of file weierstrass.h.
#define WEIERSTRASS_CURVE | ( | _name, | |
_curve, | |||
_len, | |||
_prime, | |||
_a, | |||
_b, | |||
_base | |||
) |
Define a Weierstrass curve.
Definition at line 131 of file weierstrass.h.
enum weierstrass_multiple |
Indexes for stored multiples of the field prime.
Enumerator | |
---|---|
WEIERSTRASS_N | |
WEIERSTRASS_2N | |
WEIERSTRASS_4N | |
WEIERSTRASS_NUM_MULTIPLES |
Definition at line 69 of file weierstrass.h.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
int weierstrass_multiply | ( | struct weierstrass_curve * | curve, |
const void * | base, | ||
const void * | scalar, | ||
void * | result | ||
) |
Multiply curve point by scalar.
curve | Weierstrass curve |
base | Base point (or NULL to use generator) |
scalar | Scalar multiple |
result | Result point to fill in |
rc | Return status code |
Definition at line 770 of file weierstrass.c.
References __attribute__, weierstrass_curve::base, base, bigint_copy, bigint_done, bigint_grow, bigint_init, bigint_ladder, bigint_mod_exp_ladder(), bigint_montgomery, bigint_montgomery_relaxed, bigint_multiply, bigint_ntoa, bigint_required_size, bigint_t(), DBGC, weierstrass_curve::fermat, len, weierstrass_curve::len, memset(), weierstrass_curve::name, NULL, offset, weierstrass_curve::one, weierstrass_curve::prime, rc, result, size, weierstrass_curve::size, weierstrass_curve::square, WEIERSTRASS_2N, weierstrass_add_ladder(), WEIERSTRASS_AXES, weierstrass_init(), weierstrass_t, and weierstrass_verify.