Fabcoin Core  0.16.2
P2P Digital Currency
ecpoint.h
Go to the documentation of this file.
1 // ecpoint.h - written and placed in the public domain by Jeffrey Walton
2 // Data structures moved from ecp.h and ec2n.h. Added EncodedPoint interface
3 
7 
8 #ifndef CRYPTOPP_ECPOINT_H
9 #define CRYPTOPP_ECPOINT_H
10 
11 #include "cryptlib.h"
12 #include "integer.h"
13 #include "algebra.h"
14 #include "gf2n.h"
15 
17 
22 {
23  virtual ~ECPPoint() {}
24 
27  ECPPoint() : identity(true) {}
28 
31  ECPPoint(const Integer &x, const Integer &y)
32  : x(x), y(y), identity(false) {}
33 
37  bool operator==(const ECPPoint &t) const
38  {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
39 
43  bool operator< (const ECPPoint &t) const
44  {return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
45 
47  bool identity;
48 };
49 
51 
56 {
57  virtual ~EC2NPoint() {}
58 
61  EC2NPoint() : identity(true) {}
62 
66  : x(x), y(y), identity(false) {}
67 
71  bool operator==(const EC2NPoint &t) const
72  {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
73 
77  bool operator< (const EC2NPoint &t) const
78  {return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
79 
81  bool identity;
82 };
83 
85 
92 template <class Point>
94 {
95 public:
96  virtual ~EncodedPoint() {}
97 
103  virtual bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const =0;
104 
110  virtual bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const =0;
111 
115  virtual bool VerifyPoint(const Point &P) const =0;
116 
120  virtual unsigned int EncodedPointSize(bool compressed = false) const =0;
121 
127  virtual void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const =0;
128 
133  virtual void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
134 
138  virtual Point BERDecodePoint(BufferedTransformation &bt) const =0;
139 
144  virtual void DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
145 };
146 
148 
149 #endif // CRYPTOPP_ECPOINT_H
uint8_t byte
Definition: Common.h:57
Elliptical Curve Point over GF(p), where p is prime.
Definition: ecpoint.h:21
PolynomialMod2 x
Definition: ecpoint.h:80
bool operator==(const EC2NPoint &t) const
Tests points for equality.
Definition: ecpoint.h:71
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Definition: config.h:720
Abstract base classes that provide a uniform interface to this library.
virtual ~ECPPoint()
Definition: ecpoint.h:23
bool identity
Definition: ecpoint.h:81
Classes for performing mathematics over different fields.
Interface for buffered transformations.
Definition: cryptlib.h:1352
bool operator==(const ECPPoint &t) const
Tests points for equality.
Definition: ecpoint.h:37
Polynomial with Coefficients in GF(2)
Definition: gf2n.h:21
#define x(i)
ECPPoint(const Integer &x, const Integer &y)
Construct an ECPPoint from coordinates.
Definition: ecpoint.h:31
PolynomialMod2 y
Definition: ecpoint.h:80
Multiple precision integer with arithmetic operations.
Definition: integer.h:43
Classes and functions for schemes over GF(2^n)
ECPPoint()
Construct an ECPPoint.
Definition: ecpoint.h:27
Abstract class for encoding and decoding ellicptic curve points.
Definition: ecpoint.h:93
bool identity
Definition: ecpoint.h:47
#define P
Multiple precision integer with arithmetic operations.
#define NAMESPACE_END
Definition: config.h:201
EC2NPoint()
Construct an EC2NPoint.
Definition: ecpoint.h:61
Elliptical Curve Point over GF(2^n)
Definition: ecpoint.h:55
#define CRYPTOPP_DLL
Definition: config.h:704
virtual ~EC2NPoint()
Definition: ecpoint.h:57
EC2NPoint(const PolynomialMod2 &x, const PolynomialMod2 &y)
Construct an EC2NPoint from coordinates.
Definition: ecpoint.h:65
virtual ~EncodedPoint()
Definition: ecpoint.h:96
Integer x
Definition: ecpoint.h:46
Integer y
Definition: ecpoint.h:46
bool operator<(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
Definition: asn.h:562