Elliptic curve (EC) arithmetic over . More...
#include "c4e_ec.h"
#include "c4e_gf2n.h"
Go to the source code of this file.
Functions | |
void | c4e_ecgf2n_cpy (C4E_CONST C4eEcPoint *C4E_RESTRICT src, C4eEcPoint *C4E_RESTRICT dst) |
Copies an elliptic curve point. | |
void | c4e_ecgf2n_neg (C4E_CONST C4eEcPoint *C4E_RESTRICT pt, C4eEcPoint *C4E_RESTRICT pt3) |
Negative point on an elliptic curve over the binary field . | |
C4eSysStatus | c4e_ecgf2n_add (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4E_CONST C4eEcPoint *C4E_RESTRICT pt1, C4E_CONST C4eEcPoint *C4E_RESTRICT pt2, C4eArchDigit tmp[C4E_RESTRICT], C4eEcPoint *C4E_RESTRICT pt3) |
Addition of two points on an elliptic curve over the binary field . | |
C4eSysStatus | c4e_ecgf2n_dbl (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4E_CONST C4eEcPoint *C4E_RESTRICT pt, C4eArchDigit tmp[C4E_RESTRICT], C4eEcPoint *C4E_RESTRICT pt3) |
Point doubling on an elliptic curve over the binary field . | |
C4eSysStatus | c4e_ecgf2n_mul (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4E_CONST C4eElement *C4E_RESTRICT k, C4E_CONST C4eEcPoint *C4E_RESTRICT pt, C4eArchDigit tmp[C4E_RESTRICT], C4eEcPoint *C4E_RESTRICT kp) |
Point multiplication kP on an elliptic curve over the binary field . | |
C4eSysBool | c4e_ecgf2n_sign (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4E_CONST C4eEcPoint *C4E_RESTRICT pt, C4eArchDigit tmp[C4E_RESTRICT]) |
Returns the "sign" of coordinate for an elliptic curve point over binary field , according to IEEE Std 1363, annex A.9.6. | |
C4eSysStatus | c4e_ecgf2n_gety (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4eSysBool sign, C4eArchDigit tmp[C4E_RESTRICT], C4eEcPoint *C4E_RESTRICT pt) |
Calculates the y-coordinate associated with a x-coordinate for an elliptic curve over binary field , according to IEEE Std 1363, annex A.12.9 and X9.62, section 4.2.2. | |
C4eSysStatus | c4e_ecgf2n_validate (C4E_CONST C4eEcDomain *C4E_RESTRICT dom, C4E_CONST C4eEcPoint *C4E_RESTRICT pt, C4eArchDigit tmp[C4E_RESTRICT]) |
Validates the coordinate values of an elliptic curve point are in range (fast) and optional verifies the point really is located on the elliptic curve over . |
Elliptic curve (EC) arithmetic over .
Definition in file c4e_ecgf2n.h.
void c4e_ecgf2n_cpy | ( | C4E_CONST C4eEcPoint *C4E_RESTRICT | src, | |
C4eEcPoint *C4E_RESTRICT | dst | |||
) |
Copies an elliptic curve point.
[out] | dst | Pointer to destination point, which must have dst->x.digits and dst->y.digits set. |
[in] | src | Pointer to source point. |
void c4e_ecgf2n_neg | ( | C4E_CONST C4eEcPoint *C4E_RESTRICT | pt, | |
C4eEcPoint *C4E_RESTRICT | pt3 | |||
) |
Negative point on an elliptic curve over the binary field .
The algorithm calculates (according to IEEE Std 1363, annex A.10.2): .
[in] | pt | Pointer to EC point . |
[out] | pt3 | Resulting EC point , normalized. |
C4eSysStatus c4e_ecgf2n_add | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt1, | |||
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt2, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eEcPoint *C4E_RESTRICT | pt3 | |||
) |
Addition of two points on an elliptic curve over the binary field .
The algorithm calculates (according to IEEE Std 1363, annex A.10.2): , with .
pt1
== pt2
.pt3->x.digits
and pt3->y.digits
must point to pre- allocated memory space for at least dom->m.val.size
digits. tmp
must point to pre-allocated memory space for at least (4U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. dom->m.val
and normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e().[in] | dom | Pointer to domain parameters. |
[in] | pt1 | Pointer to first EC point. |
[in] | pt2 | Pointer to second EC point. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[out] | pt3 | Result of adding the EC points pt1 and pt2 , with all coordinate values normalized. The member pt->attr may indicate an error. |
C4E_STATUS_OK | if the calculation was successful | |
other | if the calculation has failed |
C4eSysStatus c4e_ecgf2n_dbl | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eEcPoint *C4E_RESTRICT | pt3 | |||
) |
Point doubling on an elliptic curve over the binary field .
The algorithm calculates (according to IEEE Std 1363, annex A.10.2): , with .
pt3->x.digits
and pt3->y.digits
must point to pre- allocated memory space for at least dom->m.val.size
digits. tmp
must point to pre-allocated memory space for at least (4U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. dom->m.val
and normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e().[in] | dom | Pointer to domain parameters. |
[in] | pt | Pointer to EC point. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[out] | pt3 | Result of doubling the EC point, with all coordinate values normalized. The member pt3->attr may indicate an error. |
C4E_STATUS_OK | if the calculation was successful | |
other | if the calculation has failed |
C4eSysStatus c4e_ecgf2n_mul | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eElement *C4E_RESTRICT | k, | |||
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eEcPoint *C4E_RESTRICT | kp | |||
) |
Point multiplication kP on an elliptic curve over the binary field .
The calculation is performed by repeated multiply-add operations on a EC point. This is based on the binary representation of scalar k:
Multiplying this representation with curve point results in:
kp->x.digits
and kp->y.digits
must point to pre- allocated memory space for at least dom->m.val.size
digits. tmp
must point to pre-allocated memory space for at least (6U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. dom->m.val
and normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e().[in] | dom | Pointer to domain parameters. |
[in] | k | Number of point additions (big number). |
[in] | pt | Pointer to EC point. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[out] | kp | Result of EC point multiplication, with all coordinate values normalized. The member kp->attr may indicate an error. |
C4E_STATUS_OK | if the calculation was successful | |
other | if the calculation has failed |
C4eSysBool c4e_ecgf2n_sign | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt, | |||
C4eArchDigit | tmp[C4E_RESTRICT] | |||
) |
Returns the "sign" of coordinate for an elliptic curve point over binary field , according to IEEE Std 1363, annex A.9.6.
tmp
must point to pre-allocated memory space for at least (4U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. dom->m.val
and normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e(). [in] | dom | Pointer to domain parameters. |
[in] | pt | Pointer to EC point. |
tmp | Array of temporary space elements (see preconditions for details on size). |
C4E_TRUE
(bit = 1) or C4E_FALSE
(bit = 0). If pt->x
is zero then it return C4E_FALSE
.C4eSysStatus c4e_ecgf2n_gety | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4eSysBool | sign, | |||
C4eArchDigit | tmp[C4E_RESTRICT], | |||
C4eEcPoint *C4E_RESTRICT | pt | |||
) |
Calculates the y-coordinate associated with a x-coordinate for an elliptic curve over binary field , according to IEEE Std 1363, annex A.12.9 and X9.62, section 4.2.2.
tmp
must point to pre-allocated memory space for at least (5U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. pt->x
must be reduced to modulus dom->m.val
and normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e().[in] | dom | Pointer to domain parameters. |
[in] | sign | Sign of the y-coordinate (because there may be two), as defined by IEEE Std 1363, annex A.9.6. If pt->x is zero then sign is ignored. |
tmp | Array of temporary space elements (see preconditions for details on size). | |
[in,out] | pt | Pointer to EC point, with pt->x the input and pt->y output. |
C4E_STATUS_OK | if y-coordinate is valid (no error) | |
C4E_STATUS_ERNG | random generator failure | |
C4E_STATUS_EDOM | no solution in |
C4eSysStatus c4e_ecgf2n_validate | ( | C4E_CONST C4eEcDomain *C4E_RESTRICT | dom, | |
C4E_CONST C4eEcPoint *C4E_RESTRICT | pt, | |||
C4eArchDigit | tmp[C4E_RESTRICT] | |||
) |
Validates the coordinate values of an elliptic curve point are in range (fast) and optional verifies the point really is located on the elliptic curve over .
In the first step (very fast) this function verifies if the coordinate values of point pt
are elements of ground field and so are in range.
In a second step (optional, enabled when tmp
is unequal to NULL
) it validates the point pt
as field of element of elliptic curve E, as specified in dom
. In this case it verifies equation for elliptic curve point pt
.
pt->x
or pt->y
) is allowed to be zero.tmp
is unequal to NULL
(extended test) then it must point to pre-allocated memory space for at least (2U * C4E_GF2N_INV_SPACE(dom->m.val.size
)) digits. pt
must be normalized, e.g. by using functions c4e_elem_norm() or c4e_elem_os2e(). [in] | dom | Pointer to domain parameters. |
[in] | pt | Pointer to EC point to validate. |
tmp | Array of temporary space elements (see preconditions for details on size). If tmp is NULL then only a basic (but very fast) test of coordinate values pt->x and pt->y is performed. |