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