Fabcoin Core  0.16.2
P2P Digital Currency
Public Types | Public Member Functions | Private Attributes | List of all members
ECP Class Reference

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

#include <ecp.h>

Inheritance diagram for ECP:
[legend]
Collaboration diagram for ECP:
[legend]

Public Types

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

Public Member Functions

virtual ~ECP ()
 
 ECP ()
 Construct an ECP. More...
 
 ECP (const ECP &ecp, bool convertToMontgomeryRepresentation=false)
 Copy construct an ECP. More...
 
 ECP (const Integer &modulus, const FieldElement &a, const FieldElement &b)
 Construct an ECP. More...
 
 ECP (BufferedTransformation &bt)
 Construct an ECP from BER encoded parameters. More...
 
void DEREncode (BufferedTransformation &bt) const
 Encode the fields fieldID and curve of the sequence ECParameters. More...
 
bool Equal (const Point &P, const Point &Q) const
 Compare two elements for equality. More...
 
const PointIdentity () const
 Provides the Identity element. More...
 
const PointInverse (const Point &P) const
 Inverts the element in the group. More...
 
bool InversionIsFast () const
 Determine if inversion is fast. More...
 
const PointAdd (const Point &P, const Point &Q) const
 Adds elements in the group. More...
 
const PointDouble (const Point &P) const
 Doubles an element in the group. More...
 
Point ScalarMultiply (const Point &P, const Integer &k) const
 Performs a scalar multiplication. More...
 
Point CascadeScalarMultiply (const Point &P, const Integer &k1, const Point &Q, const Integer &k2) const
 TODO. More...
 
void SimultaneousMultiply (Point *results, const Point &base, const Integer *exponents, unsigned int exponentsCount) const
 Multiplies a base to multiple exponents in a group. More...
 
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. More...
 
unsigned int EncodedPointSize (bool compressed=false) const
 Determines encoded point size. More...
 
bool DecodePoint (Point &P, BufferedTransformation &bt, size_t len) const
 Decodes an elliptic curve point. More...
 
bool DecodePoint (Point &P, const byte *encodedPoint, size_t len) const
 Decodes an elliptic curve point. More...
 
void EncodePoint (byte *encodedPoint, const Point &P, bool compressed) const
 Encodes an elliptic curve point. More...
 
void EncodePoint (BufferedTransformation &bt, const Point &P, bool compressed) const
 Encodes an elliptic curve point. More...
 
Point BERDecodePoint (BufferedTransformation &bt) const
 BER Decodes an elliptic curve point. More...
 
void DEREncodePoint (BufferedTransformation &bt, const Point &P, bool compressed) const
 DER Encodes an elliptic curve point. More...
 
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 ~AbstractGroup ()
 
virtual const ElementSubtract (const Element &a, const Element &b) const
 Subtracts elements in the group. More...
 
virtual ElementAccumulate (Element &a, const Element &b) const
 TODO. More...
 
virtual ElementReduce (Element &a, const Element &b) const
 Reduces an element in the congruence class. More...
 
- Public Member Functions inherited from EncodedPoint< ECPPoint >
virtual ~EncodedPoint ()
 

Private Attributes

clonable_ptr< Fieldm_fieldPtr
 
FieldElement m_a
 
FieldElement m_b
 
Point m_R
 

Detailed Description

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

Definition at line 22 of file ecp.h.

Member Typedef Documentation

Definition at line 25 of file ecp.h.

Definition at line 26 of file ecp.h.

Definition at line 27 of file ecp.h.

Constructor & Destructor Documentation

virtual ECP::~ECP ( )
inlinevirtual

Definition at line 29 of file ecp.h.

ECP::ECP ( )
inline

Construct an ECP.

Definition at line 32 of file ecp.h.

NAMESPACE_END ECP::ECP ( const ECP ecp,
bool  convertToMontgomeryRepresentation = false 
)

Copy construct an ECP.

Parameters
ecpthe other ECP object
convertToMontgomeryRepresentationflag indicating if the curve should be converted to a MontgomeryRepresentation
See also
ModularArithmetic, MontgomeryRepresentation

Definition at line 29 of file ecp.cpp.

Here is the call graph for this function:

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 44 of file ecp.h.

ECP::ECP ( BufferedTransformation bt)

Construct an ECP from BER encoded parameters.

Parameters
btBufferedTransformation derived object

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

Definition at line 41 of file ecp.cpp.

Here is the call graph for this function:

Member Function Documentation

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 220 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 146 of file ecp.cpp.

Here is the call graph for this function:

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

Definition at line 68 of file ecp.h.

ECP::Point ECP::CascadeScalarMultiply ( const Point x,
const Integer e1,
const Point y,
const Integer e2 
) const
virtual

TODO.

Parameters
xfirst multiplicand
e1the first multiplier
ysecond multiplicand
e2the second multiplier
Returns
TODO

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 462 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 72 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 66 of file ecp.cpp.

Here is the call graph for this function:

void ECP::DEREncode ( BufferedTransformation bt) const

Encode the fields fieldID and curve of the sequence ECParameters.

Parameters
btBufferedTransformation derived object

Definition at line 57 of file ecp.cpp.

Here is the call graph for this function:

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 156 of file ecp.cpp.

Here is the call graph for this function:

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

Doubles an element in the group.

Parameters
athe element
Returns
the element doubled

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 237 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 74 of file ecp.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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 139 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 121 of file ecp.cpp.

Here is the call graph for this function:

bool ECP::Equal ( const Point a,
const Point b 
) const
virtual

Compare two elements for equality.

Parameters
afirst element
bsecond element
Returns
true if the elements are equal, false otherwise

Equal() tests the elements for equality using a==b

Implements AbstractGroup< ECPPoint >.

Definition at line 188 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Integer ECP::FieldSize ( ) const
inline

Definition at line 85 of file ecp.h.

Here is the call graph for this function:

Here is the caller graph for this function:

const FieldElement& ECP::GetA ( ) const
inline

Definition at line 87 of file ecp.h.

const FieldElement& ECP::GetB ( ) const
inline

Definition at line 88 of file ecp.h.

const Field& ECP::GetField ( ) const
inline

Definition at line 86 of file ecp.h.

Here is the caller graph for this function:

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

Provides the Identity element.

Returns
the Identity element

Implements AbstractGroup< ECPPoint >.

Definition at line 202 of file ecp.cpp.

Here is the caller graph for this function:

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 207 of file ecp.cpp.

Here is the call graph for this function:

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 59 of file ecp.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 66 of file ecp.h.

Here is the caller graph for this function:

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

Definition at line 90 of file ecp.h.

Here is the call graph for this function:

ECP::Point ECP::ScalarMultiply ( const Point a,
const Integer e 
) const
virtual

Performs a scalar multiplication.

Parameters
amultiplicand
emultiplier
Returns
the product

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 354 of file ecp.cpp.

Here is the call graph for this function:

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

Multiplies a base to multiple exponents in a group.

Parameters
resultsan array of Elements
basethe base to raise to the exponents
exponentsan array of exponents
exponentsCountthe number of exponents in the array

SimultaneousMultiply() multiplies the base to each exponent in the exponents array and stores the result at the respective position in the results array.

SimultaneousMultiply() must be implemented in a derived class.

Precondition
COUNTOF(results) == exponentsCount
COUNTOF(exponents) == exponentsCount

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 364 of file ecp.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 163 of file ecp.cpp.

Here is the call graph for this function:

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 179 of file ecp.cpp.

Here is the call graph for this function:

Member Data Documentation

FieldElement ECP::m_a
private

Definition at line 95 of file ecp.h.

FieldElement ECP::m_b
private

Definition at line 95 of file ecp.h.

clonable_ptr<Field> ECP::m_fieldPtr
private

Definition at line 94 of file ecp.h.

Point ECP::m_R
mutableprivate

Definition at line 96 of file ecp.h.


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