michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __ec2_h_ michael@0: #define __ec2_h_ michael@0: michael@0: #include "ecl-priv.h" michael@0: michael@0: /* Checks if point P(px, py) is at infinity. Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_is_inf_aff(const mp_int *px, const mp_int *py); michael@0: michael@0: /* Sets P(px, py) to be the point at infinity. Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_set_inf_aff(mp_int *px, mp_int *py); michael@0: michael@0: /* Computes R = P + Q where R is (rx, ry), P is (px, py) and Q is (qx, michael@0: * qy). Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_add_aff(const mp_int *px, const mp_int *py, michael@0: const mp_int *qx, const mp_int *qy, mp_int *rx, michael@0: mp_int *ry, const ECGroup *group); michael@0: michael@0: /* Computes R = P - Q. Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_sub_aff(const mp_int *px, const mp_int *py, michael@0: const mp_int *qx, const mp_int *qy, mp_int *rx, michael@0: mp_int *ry, const ECGroup *group); michael@0: michael@0: /* Computes R = 2P. Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_dbl_aff(const mp_int *px, const mp_int *py, mp_int *rx, michael@0: mp_int *ry, const ECGroup *group); michael@0: michael@0: /* Validates a point on a GF2m curve. */ michael@0: mp_err ec_GF2m_validate_point(const mp_int *px, const mp_int *py, const ECGroup *group); michael@0: michael@0: /* by default, this routine is unused and thus doesn't need to be compiled */ michael@0: #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF michael@0: /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters michael@0: * a, b and p are the elliptic curve coefficients and the irreducible that michael@0: * determines the field GF2m. Uses affine coordinates. */ michael@0: mp_err ec_GF2m_pt_mul_aff(const mp_int *n, const mp_int *px, michael@0: const mp_int *py, mp_int *rx, mp_int *ry, michael@0: const ECGroup *group); michael@0: #endif michael@0: michael@0: /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters michael@0: * a, b and p are the elliptic curve coefficients and the irreducible that michael@0: * determines the field GF2m. Uses Montgomery projective coordinates. */ michael@0: mp_err ec_GF2m_pt_mul_mont(const mp_int *n, const mp_int *px, michael@0: const mp_int *py, mp_int *rx, mp_int *ry, michael@0: const ECGroup *group); michael@0: michael@0: #ifdef ECL_ENABLE_GF2M_PROJ michael@0: /* Converts a point P(px, py) from affine coordinates to projective michael@0: * coordinates R(rx, ry, rz). */ michael@0: mp_err ec_GF2m_pt_aff2proj(const mp_int *px, const mp_int *py, mp_int *rx, michael@0: mp_int *ry, mp_int *rz, const ECGroup *group); michael@0: michael@0: /* Converts a point P(px, py, pz) from projective coordinates to affine michael@0: * coordinates R(rx, ry). */ michael@0: mp_err ec_GF2m_pt_proj2aff(const mp_int *px, const mp_int *py, michael@0: const mp_int *pz, mp_int *rx, mp_int *ry, michael@0: const ECGroup *group); michael@0: michael@0: /* Checks if point P(px, py, pz) is at infinity. Uses projective michael@0: * coordinates. */ michael@0: mp_err ec_GF2m_pt_is_inf_proj(const mp_int *px, const mp_int *py, michael@0: const mp_int *pz); michael@0: michael@0: /* Sets P(px, py, pz) to be the point at infinity. Uses projective michael@0: * coordinates. */ michael@0: mp_err ec_GF2m_pt_set_inf_proj(mp_int *px, mp_int *py, mp_int *pz); michael@0: michael@0: /* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is michael@0: * (qx, qy, qz). Uses projective coordinates. */ michael@0: mp_err ec_GF2m_pt_add_proj(const mp_int *px, const mp_int *py, michael@0: const mp_int *pz, const mp_int *qx, michael@0: const mp_int *qy, mp_int *rx, mp_int *ry, michael@0: mp_int *rz, const ECGroup *group); michael@0: michael@0: /* Computes R = 2P. Uses projective coordinates. */ michael@0: mp_err ec_GF2m_pt_dbl_proj(const mp_int *px, const mp_int *py, michael@0: const mp_int *pz, mp_int *rx, mp_int *ry, michael@0: mp_int *rz, const ECGroup *group); michael@0: michael@0: /* Computes R = nP where R is (rx, ry) and P is (px, py). The parameters michael@0: * a, b and p are the elliptic curve coefficients and the prime that michael@0: * determines the field GF2m. Uses projective coordinates. */ michael@0: mp_err ec_GF2m_pt_mul_proj(const mp_int *n, const mp_int *px, michael@0: const mp_int *py, mp_int *rx, mp_int *ry, michael@0: const ECGroup *group); michael@0: #endif michael@0: michael@0: #endif /* __ec2_h_ */