21 ECPPoint() : identity(
true) {}
23 : identity(
false), x(x), y(y) {}
25 bool operator==(
const ECPPoint &t)
const 26 {
return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
28 {
return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
30 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 31 virtual ~ECPPoint() {}
49 ECP(
const ECP &ecp,
bool convertToMontgomeryRepresentation =
false);
50 ECP(
const Integer &modulus,
const FieldElement &a,
const FieldElement &b)
51 : m_fieldPtr(
new Field(modulus)), m_a(a.IsNegative() ? modulus+a : a), m_b(b) {}
59 bool Equal(
const Point &P,
const Point &Q)
const;
60 const Point& Identity()
const;
61 const Point& Inverse(
const Point &P)
const;
62 bool InversionIsFast()
const {
return true;}
63 const Point& Add(
const Point &P,
const Point &Q)
const;
64 const Point& Double(
const Point &P)
const;
65 Point ScalarMultiply(
const Point &P,
const Integer &k)
const;
66 Point CascadeScalarMultiply(
const Point &P,
const Integer &k1,
const Point &Q,
const Integer &k2)
const;
67 void SimultaneousMultiply(Point *results,
const Point &base,
const Integer *exponents,
unsigned int exponentsCount)
const;
69 Point Multiply(
const Integer &k,
const Point &P)
const 70 {
return ScalarMultiply(P, k);}
71 Point CascadeMultiply(
const Integer &k1,
const Point &P,
const Integer &k2,
const Point &Q)
const 72 {
return CascadeScalarMultiply(P, k1, Q, k2);}
75 bool VerifyPoint(
const Point &P)
const;
77 unsigned int EncodedPointSize(
bool compressed =
false)
const 78 {
return 1 + (compressed?1:2)*GetField().MaxElementByteLength();}
81 bool DecodePoint(Point &P,
const byte *encodedPoint,
size_t len)
const;
82 void EncodePoint(byte *encodedPoint,
const Point &P,
bool compressed)
const;
88 Integer FieldSize()
const {
return GetField().GetModulus();}
89 const Field & GetField()
const {
return *m_fieldPtr;}
90 const FieldElement & GetA()
const {
return m_a;}
91 const FieldElement & GetB()
const {
return m_b;}
93 bool operator==(
const ECP &rhs)
const 94 {
return GetField() == rhs.GetField() && m_a == rhs.m_a && m_b == rhs.m_b;}
96 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 102 FieldElement m_a, m_b;
118 bool NeedConversions()
const {
return true;}
120 {
return P.identity ? P :
ECP::Point(m_ec->GetField().ConvertIn(P.x), m_ec->GetField().ConvertIn(P.y));};
122 {
return P.identity ? P :
ECP::Point(m_ec->GetField().ConvertOut(P.x), m_ec->GetField().ConvertOut(P.y));}
128 void SetCurve(
const ECP &ec)
130 m_ec.reset(
new ECP(ec,
true));
133 const ECP & GetCurve()
const {
return *m_ecOriginal;}
135 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
This file contains helper classes/functions for implementing public key algorithms.
Elliptic Curve over GF(p), where p is prime.
Abstract base classes that provide a uniform interface to this library.
Classes for automatic resource management.
Ring of congruence classes modulo n.
Interface for random number generators.
A pointer which can be copied and cloned.
Multiple precision integer with arithmetic operations.
bool operator<(const ::PolynomialMod2 &a, const ::PolynomialMod2 &b)
compares degree
Classes for precomputation in a group.
Class file for performing modular arithmetic.
Crypto++ library namespace.