Fabcoin Core
0.16.2
P2P Digital Currency
|
Elliptic Curve over GF(p), where p is prime. More...
#include <ecp.h>
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 Point & | Identity () const |
Provides the Identity element. More... | |
const Point & | Inverse (const Point &P) const |
Inverts the element in the group. More... | |
bool | InversionIsFast () const |
Determine if inversion is fast. More... | |
const Point & | Add (const Point &P, const Point &Q) const |
Adds elements in the group. More... | |
const Point & | Double (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 Field & | GetField () const |
const FieldElement & | GetA () const |
const FieldElement & | GetB () const |
bool | operator== (const ECP &rhs) const |
Public Member Functions inherited from AbstractGroup< ECPPoint > | |
virtual | ~AbstractGroup () |
virtual const Element & | Subtract (const Element &a, const Element &b) const |
Subtracts elements in the group. More... | |
virtual Element & | Accumulate (Element &a, const Element &b) const |
TODO. More... | |
virtual Element & | Reduce (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< Field > | m_fieldPtr |
FieldElement | m_a |
FieldElement | m_b |
Point | m_R |
typedef ModularArithmetic ECP::Field |
typedef Integer ECP::FieldElement |
typedef ECPPoint ECP::Point |
NAMESPACE_END ECP::ECP | ( | const ECP & | ecp, |
bool | convertToMontgomeryRepresentation = false |
||
) |
Copy construct an ECP.
ecp | the other ECP object |
convertToMontgomeryRepresentation | flag indicating if the curve should be converted to a MontgomeryRepresentation |
Definition at line 29 of file ecp.cpp.
|
inline |
Construct an ECP.
modulus | the prime modulus |
a | Field::Element |
b | Field::Element |
ECP::ECP | ( | BufferedTransformation & | bt | ) |
Construct an ECP from BER encoded parameters.
bt | BufferedTransformation 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.
|
virtual |
Adds elements in the group.
a | first element |
b | second element |
a
and b
Implements AbstractGroup< ECPPoint >.
Definition at line 220 of file ecp.cpp.
|
virtual |
BER Decodes an elliptic curve point.
bt | source BufferedTransformation |
Implements EncodedPoint< ECPPoint >.
Definition at line 146 of file ecp.cpp.
|
virtual |
TODO.
x | first multiplicand |
e1 | the first multiplier |
y | second multiplicand |
e2 | the second multiplier |
Reimplemented from AbstractGroup< ECPPoint >.
Definition at line 462 of file ecp.cpp.
|
virtual |
Decodes an elliptic curve point.
P | point which is decoded |
bt | source BufferedTransformation |
len | number of bytes to read from the BufferedTransformation |
Implements EncodedPoint< ECPPoint >.
Definition at line 72 of file ecp.cpp.
|
virtual |
Decodes an elliptic curve point.
P | point which is decoded |
encodedPoint | byte array with the encoded point |
len | the size of the array |
Implements EncodedPoint< ECPPoint >.
Definition at line 66 of file ecp.cpp.
void ECP::DEREncode | ( | BufferedTransformation & | bt | ) | const |
Encode the fields fieldID and curve of the sequence ECParameters.
bt | BufferedTransformation derived object |
Definition at line 57 of file ecp.cpp.
|
virtual |
DER Encodes an elliptic curve point.
bt | target BufferedTransformation |
P | point which is encoded |
compressed | flag indicating if the point is compressed |
Implements EncodedPoint< ECPPoint >.
Definition at line 156 of file ecp.cpp.
|
virtual |
Doubles an element in the group.
a | the element |
Reimplemented from AbstractGroup< ECPPoint >.
Definition at line 237 of file ecp.cpp.
|
inlinevirtual |
Determines encoded point size.
compressed | flag indicating if the point is compressed |
Implements EncodedPoint< ECPPoint >.
Definition at line 74 of file ecp.h.
Encodes an elliptic curve point.
P | point which is decoded |
encodedPoint | byte array for the encoded point |
compressed | flag 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.
|
virtual |
Encodes an elliptic curve point.
bt | target BufferedTransformation |
P | point which is encoded |
compressed | flag indicating if the point is compressed |
Implements EncodedPoint< ECPPoint >.
Definition at line 121 of file ecp.cpp.
Compare two elements for equality.
a | first element |
b | second element |
Equal() tests the elements for equality using a==b
Implements AbstractGroup< ECPPoint >.
Definition at line 188 of file ecp.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Provides the Identity element.
Implements AbstractGroup< ECPPoint >.
Definition at line 202 of file ecp.cpp.
|
virtual |
Inverts the element in the group.
a | first element |
Implements AbstractGroup< ECPPoint >.
Definition at line 207 of file ecp.cpp.
|
inlinevirtual |
Determine if inversion is fast.
Reimplemented from AbstractGroup< ECPPoint >.
Definition at line 59 of file ecp.h.
|
inline |
|
virtual |
Performs a scalar multiplication.
a | multiplicand |
e | multiplier |
Reimplemented from AbstractGroup< ECPPoint >.
Definition at line 354 of file ecp.cpp.
|
virtual |
Multiplies a base to multiple exponents in a group.
results | an array of Elements |
base | the base to raise to the exponents |
exponents | an array of exponents |
exponentsCount | the 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.
COUNTOF(results) == exponentsCount
COUNTOF(exponents) == exponentsCount
Reimplemented from AbstractGroup< ECPPoint >.
Definition at line 364 of file ecp.cpp.
bool ECP::ValidateParameters | ( | RandomNumberGenerator & | rng, |
unsigned int | level = 3 |
||
) | const |
|
virtual |
Verifies points on elliptic curve.
P | point to verify |
Implements EncodedPoint< ECPPoint >.
Definition at line 179 of file ecp.cpp.
|
private |
|
private |
|
private |