1 #ifndef CRYPTOPP_EC2N_H
2 #define CRYPTOPP_EC2N_H
9 NAMESPACE_BEGIN(CryptoPP)
14 EC2NPoint() : identity(
true) {}
16 : identity(
false), x(x), y(y) {}
18 bool operator==(
const EC2NPoint &t)
const
19 {
return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
21 {
return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
34 typedef Field::Element FieldElement;
38 EC2N(
const Field &field,
const Field::Element &a,
const Field::Element &b)
39 : m_field(field), m_a(a), m_b(b) {}
47 bool Equal(
const Point &P,
const Point &Q)
const;
48 const Point& Identity()
const;
49 const Point& Inverse(
const Point &P)
const;
50 bool InversionIsFast()
const {
return true;}
51 const Point& Add(
const Point &P,
const Point &Q)
const;
52 const Point& Double(
const Point &P)
const;
54 Point Multiply(
const Integer &k,
const Point &P)
const
55 {
return ScalarMultiply(P, k);}
56 Point CascadeMultiply(
const Integer &k1,
const Point &P,
const Integer &k2,
const Point &Q)
const
57 {
return CascadeScalarMultiply(P, k1, Q, k2);}
60 bool VerifyPoint(
const Point &P)
const;
62 unsigned int EncodedPointSize(
bool compressed =
false)
const
63 {
return 1 + (compressed?1:2)*m_field->MaxElementByteLength();}
66 bool DecodePoint(Point &P,
const byte *encodedPoint,
size_t len)
const;
67 void EncodePoint(byte *encodedPoint,
const Point &P,
bool compressed)
const;
74 const Field & GetField()
const {
return *m_field;}
75 const FieldElement & GetA()
const {
return m_a;}
76 const FieldElement & GetB()
const {
return m_b;}
78 bool operator==(
const EC2N &rhs)
const
79 {
return GetField() == rhs.GetField() && m_a == rhs.m_a && m_b == rhs.m_b;}
83 FieldElement m_a, m_b;
104 void SetCurve(
const EC2N &ec) {m_ec = ec;}
105 const EC2N & GetCurve()
const {
return m_ec;}
This file contains helper classes/functions for implementing public key algorithms.
interface for random number generators
Polynomial with Coefficients in GF(2)
multiple precision integer and basic arithmetics
Elliptic Curve over GF(2^n)
bool operator<(const ::PolynomialMod2 &a, const ::PolynomialMod2 &b)
compares degree
static Integer Power2(size_t e)
return the integer 2**e
GF(2^n) with Polynomial Basis.