31 #ifndef _SCC_CRYPTO_ECC_H
32 #define _SCC_CRYPTO_ECC_H
38 namespace scc::crypto {
59 struct EccGfpPointBase;
80 std::shared_ptr<EccGfpBase> m_ctx;
199 friend class EcdsaSignature;
201 std::shared_ptr<EccGfpPointBase> m_ctx;
248 void set(
const void*,
int);
249 void set(
const std::vector<char>& v)
251 set(v.data(), v.size());
263 void set(
const std::vector<char>& v,
EccGfp& curve)
265 set(v.data(), v.size(), curve);
285 void get(std::vector<char>&)
const;
306 return valid(*
this, curve);
static bool infinite(const EccGfpPoint &)
Test the point for infinity.
EccGfpPoint(const EccGfp &curve)
Construct a point on the elliptic curve.
bool equal(const EccGfpPoint &) const
Test for equality with a second point.
void reset()
Reset the point to invalid.
void get(scc::crypto::Bignum &, scc::crypto::Bignum &) const
Get the coordinates.
void set(const void *, int)
Set the point from a data string.
EccGfpPoint()
Construct an invalid point.
void get(std::vector< char > &) const
Get the coordinates to a data string.
static bool valid(const EccGfpPoint &, const EccGfp &)
Verify the point on a curve.
void set(const scc::crypto::Bignum &x, const scc::crypto::Bignum &y, EccGfp &curve)
Set point to a new curve.
void set()
Set point to infinity.
void reset(const EccGfp &)
Reset the point to fall on the elliptic curve.
void set(const void *loc, int len, EccGfp &curve)
Set the point from a data string on a new curve.
static bool infinite(const EccGfpPoint &, const EccGfp &)
Test the point for infinity on a curve.
void set(const scc::crypto::Bignum &, const scc::crypto::Bignum &)
Set point.
static bool valid(const EccGfpPoint &)
Verify the point.
Elliptic curve cryptography over Galois prime field GF(p) curve.
static void sign_ecdsa(const void *, int, const EccGfp &, const scc::crypto::Bignum &, scc::crypto::Bignum &, scc::crypto::Bignum &, scc::crypto::Bignum &)
Sign a message using ECDSA.
static void dh_shared_secret(const scc::crypto::Bignum &, const EccGfpPoint &, scc::crypto::Bignum &)
Calculate a shared secret using the Diffie-Hellman scheme.
static bool verify_ecdsa(const void *, int, const EccGfpPoint &, const scc::crypto::Bignum &, const scc::crypto::Bignum &)
Verify a message using the ECDSA.
void generate_key_pair(Bignum &priv_key, EccGfpPoint &pub_key)
Generate a private and public key pair for this curve.
int bit_width() const
Elliptic curve ordinal bit width.
static bool validate_key_pair(const Bignum &, const EccGfpPoint &)
Validate a key pair.
void generate_public_key(const Bignum &, EccGfpPoint &)
Generate a public key from the private key.
void reset(Type type)
Reset the curve to a new standard type.
void private_key(Bignum &)
Generate a private key.
static bool valid(const EccGfp &)
Verify the curve.
void public_key(const Bignum &, EccGfpPoint &)
Generate a public key corresponding to a private key.
@ std_p256sm2
standard curve secp256sm2
@ std_p224r1
standard curve secp224r1 (112 bit security level)
@ std_p192r1
standard curve secp192r1 (96 bit security level)
@ std_p256r1
standard curve secp256r1 (128 bit security level)
@ std_p521r1
standard curve secp521r1 (256 bit security level)
@ std_p384r1
standard curve secp384r1 (192 bit security level)