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;
50 bool InversionIsFast()
const {
return true;}
55 {
return ScalarMultiply(P, k);}
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;}