22 ECPPoint() : identity(
true) {}
24 : identity(
false), x(x), y(y) {}
27 {
return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
29 {
return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
31 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 32 virtual ~ECPPoint() {}
50 ECP(
const ECP &ecp,
bool convertToMontgomeryRepresentation =
false);
51 ECP(
const Integer &modulus,
const FieldElement &a,
const FieldElement &b)
52 : m_fieldPtr(
new Field(modulus)), m_a(a.
IsNegative() ? modulus+a : a), m_b(b) {}
60 bool Equal(
const Point &P,
const Point &Q)
const;
62 const Point&
Inverse(
const Point &P)
const;
64 const Point&
Add(
const Point &P,
const Point &Q)
const;
65 const Point&
Double(
const Point &P)
const;
70 Point Multiply(
const Integer &k,
const Point &P)
const 72 Point CascadeMultiply(
const Integer &k1,
const Point &P,
const Integer &k2,
const Point &Q)
const 76 bool VerifyPoint(
const Point &P)
const;
78 unsigned int EncodedPointSize(
bool compressed =
false)
const 79 {
return 1 + (compressed?1:2)*GetField().MaxElementByteLength();}
82 bool DecodePoint(Point &P,
const byte *encodedPoint,
size_t len)
const;
83 void EncodePoint(byte *encodedPoint,
const Point &P,
bool compressed)
const;
89 Integer FieldSize()
const {
return GetField().GetModulus();}
90 const Field & GetField()
const {
return *m_fieldPtr;}
91 const FieldElement & GetA()
const {
return m_a;}
92 const FieldElement & GetB()
const {
return m_b;}
95 {
return GetField() == rhs.GetField() && m_a == rhs.m_a && m_b == rhs.m_b;}
97 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 103 FieldElement m_a, m_b;
119 bool NeedConversions()
const {
return true;}
121 {
return P.identity ? P :
ECP::Point(m_ec->GetField().ConvertIn(P.x), m_ec->GetField().ConvertIn(P.y));};
123 {
return P.identity ? P :
ECP::Point(m_ec->GetField().ConvertOut(P.x), m_ec->GetField().ConvertOut(P.y));}
129 void SetCurve(
const ECP &ec)
131 m_ec.reset(
new ECP(ec,
true));
134 const ECP & GetCurve()
const {
return *m_ecOriginal;}
136 #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.
bool InversionIsFast() const
Determine if inversion is fast.
Classes for automatic resource management.
bool IsNegative() const
Determines if the Integer is negative.
Ring of congruence classes modulo n.
virtual const Element & Double(const Element &a) const
Doubles an element in the group.
Interface for random number generators.
virtual const Element & Identity() const =0
Provides the Identity element.
Classes for performing mathematics over different fields.
virtual Element CascadeScalarMultiply(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const
TODO.
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
virtual Element ScalarMultiply(const Element &a, const Integer &e) const
Performs a scalar multiplication.
bool operator<(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
A pointer which can be copied and cloned.
Multiple precision integer with arithmetic operations.
virtual bool Equal(const Element &a, const Element &b) const =0
Compare two elements for equality.
virtual const Element & Inverse(const Element &a) const =0
Inverts the element in the group.
virtual void SimultaneousMultiply(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
Multiplies a base to multiple exponents in a group.
Classes for precomputation in a group.
virtual const Element & Add(const Element &a, const Element &b) const =0
Adds elements in the group.
Multiple precision integer with arithmetic operations.
Class file for performing modular arithmetic.
Crypto++ library namespace.