Security Scol plugin
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
16NAMESPACE_BEGIN(CryptoPP)
17
18
20struct CRYPTOPP_DLL ECPPoint
21{
22 virtual ~ECPPoint() {}
23
26 ECPPoint() : identity(true) {}
27
30 ECPPoint(const Integer &x, const Integer &y)
31 : x(x), y(y), identity(false) {}
32
36 bool operator==(const ECPPoint &t) const
37 {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
38
42 bool operator< (const ECPPoint &t) const
43 {return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
44
45 Integer x, y;
46 bool identity;
47};
48
49CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<ECPPoint>;
50
53struct CRYPTOPP_DLL EC2NPoint
54{
55 virtual ~EC2NPoint() {}
56
59 EC2NPoint() : identity(true) {}
60
64 : x(x), y(y), identity(false) {}
65
69 bool operator==(const EC2NPoint &t) const
70 {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
71
75 bool operator< (const EC2NPoint &t) const
76 {return identity ? !t.identity : (!t.identity && (x<t.x || (x==t.x && y<t.y)));}
77
78 PolynomialMod2 x, y;
79 bool identity;
80};
81
82CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<EC2NPoint>;
83
89template <class Point>
91{
92public:
93 virtual ~EncodedPoint() {}
94
100 virtual bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const =0;
101
107 virtual bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const =0;
108
112 virtual bool VerifyPoint(const Point &P) const =0;
113
117 virtual unsigned int EncodedPointSize(bool compressed = false) const =0;
118
124 virtual void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const =0;
125
130 virtual void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
131
135 virtual Point BERDecodePoint(BufferedTransformation &bt) const =0;
136
141 virtual void DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
142};
143
144NAMESPACE_END
145
146#endif // CRYPTOPP_ECPOINT_H
Classes for performing mathematics over different fields.
Abstract group.
Definition algebra.h:27
Interface for buffered transformations.
Definition cryptlib.h:1652
Abstract class for encoding and decoding ellicptic curve points.
Definition ecpoint.h:91
virtual bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const =0
Decodes an elliptic curve point.
virtual unsigned int EncodedPointSize(bool compressed=false) const =0
Determines encoded point size.
virtual bool VerifyPoint(const Point &P) const =0
Verifies points on elliptic curve.
virtual void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const =0
Encodes an elliptic curve point.
virtual void DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0
DER Encodes an elliptic curve point.
virtual bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const =0
Decodes an elliptic curve point.
virtual void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0
Encodes an elliptic curve point.
virtual Point BERDecodePoint(BufferedTransformation &bt) const =0
BER Decodes an elliptic curve point.
Multiple precision integer with arithmetic operations.
Definition integer.h:50
Polynomial with Coefficients in GF(2)
Definition gf2n.h:27
Abstract base classes that provide a uniform interface to this library.
Classes and functions for schemes over GF(2^n)
Multiple precision integer with arithmetic operations.
Elliptical Curve Point over GF(2^n)
Definition ecpoint.h:54
EC2NPoint()
Construct an EC2NPoint.
Definition ecpoint.h:59
bool operator==(const EC2NPoint &t) const
Tests points for equality.
Definition ecpoint.h:69
EC2NPoint(const PolynomialMod2 &x, const PolynomialMod2 &y)
Construct an EC2NPoint from coordinates.
Definition ecpoint.h:63
Elliptical Curve Point over GF(p), where p is prime.
Definition ecpoint.h:21
bool operator==(const ECPPoint &t) const
Tests points for equality.
Definition ecpoint.h:36
ECPPoint()
Construct an ECPPoint.
Definition ecpoint.h:26
ECPPoint(const Integer &x, const Integer &y)
Construct an ECPPoint from coordinates.
Definition ecpoint.h:30