Security Scol plugin
Public Types | Public Member Functions | List of all members
ECP Class Reference

Elliptic Curve over GF(p), where p is prime. More...

#include <ecp.h>

Inheritance diagram for ECP:
AbstractGroup< ECPPoint > EncodedPoint< ECPPoint >

Public Types

typedef ModularArithmetic Field
 
typedef Integer FieldElement
 
typedef ECPPoint Point
 
- Public Types inherited from AbstractGroup< ECPPoint >
typedef ECPPoint Element
 

Public Member Functions

 ECP ()
 Construct an ECP.
 
 ECP (const ECP &ecp, bool convertToMontgomeryRepresentation)
 Construct an ECP.
 
 ECP (const Integer &modulus, const FieldElement &a, const FieldElement &b)
 Construct an ECP.
 
 ECP (BufferedTransformation &bt)
 Construct an ECP from BER encoded parameters.
 
void DEREncode (BufferedTransformation &bt) const
 DER Encode.
 
bool Equal (const Point &P, const Point &Q) const
 Compare two points.
 
const PointIdentity () const
 Provides the Identity element.
 
const PointInverse (const Point &P) const
 Inverts the element in the group.
 
bool InversionIsFast () const
 Determine if inversion is fast.
 
const PointAdd (const Point &P, const Point &Q) const
 Adds elements in the group.
 
const PointDouble (const Point &P) const
 
Point ScalarMultiply (const Point &P, const Integer &k) const
 
Point CascadeScalarMultiply (const Point &P, const Integer &k1, const Point &Q, const Integer &k2) const
 
void SimultaneousMultiply (Point *results, const Point &base, const Integer *exponents, unsigned int exponentsCount) const
 
Point Multiply (const Integer &k, const Point &P) const
 
Point CascadeMultiply (const Integer &k1, const Point &P, const Integer &k2, const Point &Q) const
 
bool ValidateParameters (RandomNumberGenerator &rng, unsigned int level=3) const
 
bool VerifyPoint (const Point &P) const
 Verifies points on elliptic curve.
 
unsigned int EncodedPointSize (bool compressed=false) const
 Determines encoded point size.
 
bool DecodePoint (Point &P, BufferedTransformation &bt, size_t len) const
 Decodes an elliptic curve point.
 
bool DecodePoint (Point &P, const byte *encodedPoint, size_t len) const
 Decodes an elliptic curve point.
 
void EncodePoint (byte *encodedPoint, const Point &P, bool compressed) const
 Encodes an elliptic curve point.
 
void EncodePoint (BufferedTransformation &bt, const Point &P, bool compressed) const
 Encodes an elliptic curve point.
 
Point BERDecodePoint (BufferedTransformation &bt) const
 BER Decodes an elliptic curve point.
 
void DEREncodePoint (BufferedTransformation &bt, const Point &P, bool compressed) const
 DER Encodes an elliptic curve point.
 
Integer FieldSize () const
 
const FieldGetField () const
 
const FieldElementGetA () const
 
const FieldElementGetB () const
 
bool operator== (const ECP &rhs) const
 
- Public Member Functions inherited from AbstractGroup< ECPPoint >
virtual const ElementDouble (const Element &a) const
 Doubles an element in the group.
 
virtual const ElementSubtract (const Element &a, const Element &b) const
 Subtracts elements in the group.
 
virtual ElementAccumulate (Element &a, const Element &b) const
 TODO.
 
virtual ElementReduce (Element &a, const Element &b) const
 Reduces an element in the congruence class.
 
virtual Element ScalarMultiply (const Element &a, const Integer &e) const
 Performs a scalar multiplication.
 
virtual Element CascadeScalarMultiply (const Element &x, const Integer &e1, const Element &y, const Integer &e2) const
 TODO.
 
virtual void SimultaneousMultiply (Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
 Multiplies a base to multiple exponents in a group.
 

Detailed Description

Elliptic Curve over GF(p), where p is prime.

Definition at line 26 of file ecp.h.

Member Typedef Documentation

◆ Field

Definition at line 29 of file ecp.h.

◆ FieldElement

Definition at line 30 of file ecp.h.

◆ Point

Definition at line 31 of file ecp.h.

Constructor & Destructor Documentation

◆ ~ECP()

virtual ECP::~ECP ( )
inlinevirtual

Definition at line 33 of file ecp.h.

◆ ECP() [1/4]

ECP::ECP ( )
inline

Construct an ECP.

Definition at line 36 of file ecp.h.

◆ ECP() [2/4]

ANONYMOUS_NAMESPACE_END ECP::ECP ( const ECP ecp,
bool  convertToMontgomeryRepresentation 
)

Construct an ECP.

Parameters
ecpthe other ECP object
convertToMontgomeryRepresentationflag indicating if the curve should be converted to a MontgomeryRepresentation.

Prior to Crypto++ 8.3 the default value for convertToMontgomeryRepresentation was false. it was changed due to two audit tools finding, "Signature-compatible with a copy constructor".

See also
ModularArithmetic, MontgomeryRepresentation

Definition at line 62 of file ecp.cpp.

◆ ECP() [3/4]

ECP::ECP ( const Integer modulus,
const FieldElement a,
const FieldElement b 
)
inline

Construct an ECP.

Parameters
modulusthe prime modulus
aField::Element
bField::Element

Definition at line 52 of file ecp.h.

◆ ECP() [4/4]

ECP::ECP ( BufferedTransformation bt)

Construct an ECP from BER encoded parameters.

Parameters
btBufferedTransformation derived object

This constructor will decode and extract the fields fieldID and curve of the sequence ECParameters

Definition at line 74 of file ecp.cpp.

Member Function Documentation

◆ Add()

const ECP::Point & ECP::Add ( const Point a,
const Point b 
) const
virtual

Adds elements in the group.

Parameters
afirst element
bsecond element
Returns
the sum of a and b

Implements AbstractGroup< ECPPoint >.

Definition at line 260 of file ecp.cpp.

◆ BERDecodePoint()

ECP::Point ECP::BERDecodePoint ( BufferedTransformation bt) const
virtual

BER Decodes an elliptic curve point.

Parameters
btsource BufferedTransformation
Returns
the decoded elliptic curve point

Implements EncodedPoint< ECPPoint >.

Definition at line 179 of file ecp.cpp.

◆ CascadeMultiply()

Point ECP::CascadeMultiply ( const Integer k1,
const Point P,
const Integer k2,
const Point Q 
) const
inline

Definition at line 84 of file ecp.h.

◆ CascadeScalarMultiply()

ECP::Point ECP::CascadeScalarMultiply ( const Point P,
const Integer k1,
const Point Q,
const Integer k2 
) const

Definition at line 492 of file ecp.cpp.

◆ DecodePoint() [1/2]

bool ECP::DecodePoint ( ECP::Point P,
BufferedTransformation bt,
size_t  len 
) const
virtual

Decodes an elliptic curve point.

Parameters
Ppoint which is decoded
btsource BufferedTransformation
lennumber of bytes to read from the BufferedTransformation
Returns
true if a point was decoded, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 105 of file ecp.cpp.

◆ DecodePoint() [2/2]

bool ECP::DecodePoint ( ECP::Point P,
const byte encodedPoint,
size_t  len 
) const
virtual

Decodes an elliptic curve point.

Parameters
Ppoint which is decoded
encodedPointbyte array with the encoded point
lenthe size of the array
Returns
true if a point was decoded, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 99 of file ecp.cpp.

◆ DEREncode()

void ECP::DEREncode ( BufferedTransformation bt) const

DER Encode.

Parameters
btBufferedTransformation derived object

DEREncode encode the fields fieldID and curve of the sequence ECParameters

Definition at line 90 of file ecp.cpp.

◆ DEREncodePoint()

void ECP::DEREncodePoint ( BufferedTransformation bt,
const Point P,
bool  compressed 
) const
virtual

DER Encodes an elliptic curve point.

Parameters
bttarget BufferedTransformation
Ppoint which is encoded
compressedflag indicating if the point is compressed

Implements EncodedPoint< ECPPoint >.

Definition at line 189 of file ecp.cpp.

◆ Double()

const ECP::Point & ECP::Double ( const Point P) const

Definition at line 277 of file ecp.cpp.

◆ EncodedPointSize()

unsigned int ECP::EncodedPointSize ( bool  compressed = false) const
inlinevirtual

Determines encoded point size.

Parameters
compressedflag indicating if the point is compressed
Returns
the minimum number of bytes required to encode the point

Implements EncodedPoint< ECPPoint >.

Definition at line 90 of file ecp.h.

◆ EncodePoint() [1/2]

void ECP::EncodePoint ( BufferedTransformation bt,
const Point P,
bool  compressed 
) const
virtual

Encodes an elliptic curve point.

Parameters
bttarget BufferedTransformation
Ppoint which is encoded
compressedflag indicating if the point is compressed

Implements EncodedPoint< ECPPoint >.

Definition at line 154 of file ecp.cpp.

◆ EncodePoint() [2/2]

void ECP::EncodePoint ( byte encodedPoint,
const Point P,
bool  compressed 
) const
virtual

Encodes an elliptic curve point.

Parameters
Ppoint which is decoded
encodedPointbyte array for the encoded point
compressedflag indicating if the point is compressed

encodedPoint must be at least EncodedPointSize() in length

Implements EncodedPoint< ECPPoint >.

Definition at line 172 of file ecp.cpp.

◆ Equal()

bool ECP::Equal ( const Point P,
const Point Q 
) const
virtual

Compare two points.

Parameters
Pthe first point
Qthe second point
Returns
true if equal, false otherwise

Implements AbstractGroup< ECPPoint >.

Definition at line 221 of file ecp.cpp.

◆ FieldSize()

Integer ECP::FieldSize ( ) const
inline

Definition at line 101 of file ecp.h.

◆ GetA()

const FieldElement & ECP::GetA ( ) const
inline

Definition at line 103 of file ecp.h.

◆ GetB()

const FieldElement & ECP::GetB ( ) const
inline

Definition at line 104 of file ecp.h.

◆ GetField()

const Field & ECP::GetField ( ) const
inline

Definition at line 102 of file ecp.h.

◆ Identity()

const ECP::Point & ECP::Identity ( ) const
virtual

Provides the Identity element.

Returns
the Identity element

Implements AbstractGroup< ECPPoint >.

Definition at line 235 of file ecp.cpp.

◆ Inverse()

const ECP::Point & ECP::Inverse ( const Point a) const
virtual

Inverts the element in the group.

Parameters
afirst element
Returns
the inverse of the element

Implements AbstractGroup< ECPPoint >.

Definition at line 247 of file ecp.cpp.

◆ InversionIsFast()

bool ECP::InversionIsFast ( ) const
inlinevirtual

Determine if inversion is fast.

Returns
true if inversion is fast, false otherwise

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 75 of file ecp.h.

◆ Multiply()

Point ECP::Multiply ( const Integer k,
const Point P 
) const
inline

Definition at line 82 of file ecp.h.

◆ operator==()

bool ECP::operator== ( const ECP rhs) const
inline

Definition at line 106 of file ecp.h.

◆ ScalarMultiply()

ECP::Point ECP::ScalarMultiply ( const Point P,
const Integer k 
) const

Definition at line 384 of file ecp.cpp.

◆ SimultaneousMultiply()

void ECP::SimultaneousMultiply ( ECP::Point results,
const Point base,
const Integer exponents,
unsigned int  exponentsCount 
) const

Definition at line 394 of file ecp.cpp.

◆ ValidateParameters()

bool ECP::ValidateParameters ( RandomNumberGenerator rng,
unsigned int  level = 3 
) const

Definition at line 196 of file ecp.cpp.

◆ VerifyPoint()

bool ECP::VerifyPoint ( const Point P) const
virtual

Verifies points on elliptic curve.

Parameters
Ppoint to verify
Returns
true if the point is valid, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 212 of file ecp.cpp.


The documentation for this class was generated from the following files: