8 #ifndef CRYPTOPP_EC2N_H 9 #define CRYPTOPP_EC2N_H 23 EC2NPoint() : identity(
true) {}
25 : identity(
false), x(x), y(y) {}
27 bool operator==(
const EC2NPoint &t)
const 28 {
return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
30 {
return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
32 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 33 virtual ~EC2NPoint() {}
47 typedef Field::Element FieldElement;
51 EC2N(
const Field &field,
const Field::Element &a,
const Field::Element &b)
52 : m_field(field), m_a(a), m_b(b) {}
60 bool Equal(
const Point &P,
const Point &Q)
const;
61 const Point& Identity()
const;
62 const Point& Inverse(
const Point &P)
const;
63 bool InversionIsFast()
const {
return true;}
64 const Point& Add(
const Point &P,
const Point &Q)
const;
65 const Point& Double(
const Point &P)
const;
67 Point Multiply(
const Integer &k,
const Point &P)
const 68 {
return ScalarMultiply(P, k);}
69 Point CascadeMultiply(
const Integer &k1,
const Point &P,
const Integer &k2,
const Point &Q)
const 70 {
return CascadeScalarMultiply(P, k1, Q, k2);}
73 bool VerifyPoint(
const Point &P)
const;
75 unsigned int EncodedPointSize(
bool compressed =
false)
const 76 {
return 1 + (compressed?1:2)*m_field->MaxElementByteLength();}
79 bool DecodePoint(Point &P,
const byte *encodedPoint,
size_t len)
const;
80 void EncodePoint(byte *encodedPoint,
const Point &P,
bool compressed)
const;
87 const Field & GetField()
const {
return *m_field;}
88 const FieldElement & GetA()
const {
return m_a;}
89 const FieldElement & GetB()
const {
return m_b;}
91 bool operator==(
const EC2N &rhs)
const 92 {
return GetField() == rhs.GetField() && m_a == rhs.m_a && m_b == rhs.m_b;}
94 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 100 FieldElement m_a, m_b;
121 void SetCurve(
const EC2N &ec) {m_ec = ec;}
122 const EC2N & GetCurve()
const {
return m_ec;}
124 #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.
Interface for random number generators.
Polynomial with Coefficients in GF(2)
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)
bool operator<(const ::PolynomialMod2 &a, const ::PolynomialMod2 &b)
compares degree
Classes for precomputation in a group.
GF(2^n) with Polynomial Basis.
Crypto++ library namespace.