8 #ifndef CRYPTOPP_EC2N_H 9 #define CRYPTOPP_EC2N_H 24 EC2NPoint() : identity(
true) {}
26 : identity(
false), x(x), y(y) {}
29 {
return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
31 {
return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
33 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 34 virtual ~EC2NPoint() {}
48 typedef Field::Element FieldElement;
52 EC2N(
const Field &field,
const Field::Element &a,
const Field::Element &b)
53 : m_field(field), m_a(a), m_b(b) {}
61 bool Equal(
const Point &P,
const Point &Q)
const;
63 const Point&
Inverse(
const Point &P)
const;
65 const Point&
Add(
const Point &P,
const Point &Q)
const;
66 const Point&
Double(
const Point &P)
const;
68 Point Multiply(
const Integer &k,
const Point &P)
const 70 Point CascadeMultiply(
const Integer &k1,
const Point &P,
const Integer &k2,
const Point &Q)
const 74 bool VerifyPoint(
const Point &P)
const;
76 unsigned int EncodedPointSize(
bool compressed =
false)
const 77 {
return 1 + (compressed?1:2)*m_field->MaxElementByteLength();}
80 bool DecodePoint(Point &P,
const byte *encodedPoint,
size_t len)
const;
81 void EncodePoint(byte *encodedPoint,
const Point &P,
bool compressed)
const;
88 const Field & GetField()
const {
return *m_field;}
89 const FieldElement & GetA()
const {
return m_a;}
90 const FieldElement & GetB()
const {
return m_b;}
93 {
return GetField() == rhs.GetField() && m_a == rhs.m_a && m_b == rhs.m_b;}
95 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 101 FieldElement m_a, m_b;
122 void SetCurve(
const EC2N &ec) {m_ec = ec;}
123 const EC2N & GetCurve()
const {
return m_ec;}
125 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
This file contains helper classes/functions for implementing public key algorithms.
Abstract base classes that provide a uniform interface to this library.
Classes for automatic resource management.
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.
bool InversionIsFast() const
Determine if inversion is fast.
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.
Polynomial with Coefficients in GF(2)
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.
static Integer Power2(size_t e)
Exponentiates to a power of 2.
Multiple precision integer with arithmetic operations.
Elliptic Curve over GF(2^n)
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.
Classes for precomputation in a group.
GF(2^n) with Polynomial Basis.
virtual const Element & Add(const Element &a, const Element &b) const =0
Adds elements in the group.
Multiple precision integer with arithmetic operations.
Crypto++ library namespace.