|
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, _order) |
| 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_is_infinity (struct weierstrass_curve *curve, const void *point) |
| Check if this is the point at infinity. More... | |
| int | weierstrass_multiply (struct weierstrass_curve *curve, const void *base, const void *scalar, void *result) |
| Multiply curve point by scalar. More... | |
| int | weierstrass_add_once (struct weierstrass_curve *curve, const void *addend, const void *augend, void *result) |
| Add curve points (as a one-off operation) 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 78 of file weierstrass.h.
| #define WEIERSTRASS_NUM_CACHED |
Number of cached big integers for each Weierstrass curve.
Definition at line 81 of file weierstrass.h.
| #define WEIERSTRASS_CURVE | ( | _name, | |
| _curve, | |||
| _len, | |||
| _prime, | |||
| _a, | |||
| _b, | |||
| _base, | |||
| _order | |||
| ) |
Define a Weierstrass curve.
Definition at line 137 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 70 of file weierstrass.h.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| int weierstrass_is_infinity | ( | struct weierstrass_curve * | curve, |
| const void * | point | ||
| ) |
Check if this is the point at infinity.
| point | Curve point |
| is_infinity | This is the point at infinity |
Definition at line 918 of file weierstrass.c.
References bigint_init, bigint_is_zero, bigint_ntoa, bigint_t(), DBGC, weierstrass_curve::len, len, weierstrass_curve::name, offset, size, weierstrass_curve::size, and WEIERSTRASS_AXES.
| 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 |
| scalar | Scalar multiple |
| result | Result point to fill in |
| rc | Return status code |
Definition at line 951 of file weierstrass.c.
References __attribute__, base, bigint_copy, bigint_init, bigint_ladder, bigint_ntoa, bigint_required_size, bigint_t(), DBGC, weierstrass_curve::len, len, memset(), weierstrass_curve::name, NULL, weierstrass_curve::one, rc, result, size, weierstrass_curve::size, weierstrass_add_ladder(), weierstrass_done, weierstrass_init, and weierstrass_t.
| int weierstrass_add_once | ( | struct weierstrass_curve * | curve, |
| const void * | addend, | ||
| const void * | augend, | ||
| void * | result | ||
| ) |
Add curve points (as a one-off operation)
| curve | Weierstrass curve |
| addend | Curve point to add |
| augend | Curve point to add |
| result | Curve point to hold result |
| rc | Return status code |
Definition at line 998 of file weierstrass.c.
References rc, result, size, weierstrass_curve::size, weierstrass_add, weierstrass_done, weierstrass_init, and weierstrass_t.
1.8.15