Crypto++ 8.2 Free C++ class library of cryptographic schemes

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

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

Inheritance diagram for ECP:

## 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. 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
| DER Encode. More...
bool | Equal (const Point &P, const Point &Q) const
| Compare two points. 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 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...

## Detailed Description

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

Definition at line 26 of file ecp.h.

## Constructor & Destructor Documentation

## ◆ ECP() [1/3]

ECP::ECP | ( | const ECP & | ecp,
|  | bool | convertToMontgomeryRepresentation
| ) |  |

Construct an ECP.

Parameters

  ecp | the other ECP object
  convertToMontgomeryRepresentation | flag 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 545 of file ecp.cpp.

## ◆ ECP() [2/3]

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

Construct an ECP.

Parameters

  modulus | the prime modulus
  a | Field::Element
  b | Field::Element

Definition at line 52 of file ecp.h.

## ◆ ECP() [3/3]

ECP::ECP | ( | BufferedTransformation & | bt | ) |

Construct an ECP from BER encoded parameters.

Parameters

  bt | BufferedTransformation derived object

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

Definition at line 557 of file ecp.cpp.

## Member Function Documentation

## ◆ DEREncode()

void ECP::DEREncode | ( | BufferedTransformation & | bt | ) | const

DER Encode.

Parameters

  bt | BufferedTransformation derived object

DEREncode encode the fields fieldID and curve of the sequence ECParameters

Definition at line 573 of file ecp.cpp.

## ◆ Equal()

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

Compare two points.

Parameters

  P | the first point
  Q | the second point

Returns
  true if equal, false otherwise

Implements AbstractGroup< ECPPoint >.

Definition at line 704 of file ecp.cpp.

## ◆ Identity()

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

Provides the Identity element.

Returns
  the Identity element

Implements AbstractGroup< ECPPoint >.

Definition at line 718 of file ecp.cpp.

## ◆ Inverse()

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

Inverts the element in the group.

Parameters

  a | first element

Returns
  the inverse of the element

Implements AbstractGroup< ECPPoint >.

Definition at line 730 of file ecp.cpp.

## ◆ InversionIsFast()

bool ECP::InversionIsFast | ( |  | ) | const
| inline virtual

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.

## ◆ Add()

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

Adds elements in the group.

Parameters

  a | first element
  b | second element

Returns
  the sum of `a` and `b`

Implements AbstractGroup< ECPPoint >.

Definition at line 743 of file ecp.cpp.

## ◆ Double()

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

Doubles an element in the group.

Parameters

  a | the element

Returns
  the element doubled

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 749 of file ecp.cpp.

## ◆ ScalarMultiply()

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

Performs a scalar multiplication.

Parameters

  a | multiplicand
  e | multiplier

Returns
  the product

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 847 of file ecp.cpp.

## ◆ CascadeScalarMultiply()

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

TODO.

Parameters

  x | first multiplicand
  e1 | the first multiplier
  y | second multiplicand
  e2 | the second multiplier

Returns
  TODO

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 955 of file ecp.cpp.

## ◆ SimultaneousMultiply()

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

  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.

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

Reimplemented from AbstractGroup< ECPPoint >.

Definition at line 857 of file ecp.cpp.

## ◆ VerifyPoint()

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

Verifies points on elliptic curve.

Parameters

  P | point to verify

Returns
  true if the point is valid, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 695 of file ecp.cpp.

## ◆ EncodedPointSize()

unsigned int ECP::EncodedPointSize | ( | bool | compressed = `false` | ) | const
| inline virtual

Determines encoded point size.

Parameters

  compressed | flag 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.

## ◆ DecodePoint() [1/2]

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

Decodes an elliptic curve point.

Parameters

  P | point which is decoded
  bt | source BufferedTransformation
  len | number of bytes to read from the BufferedTransformation

Returns
  true if a point was decoded, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 588 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

  P | point which is decoded
  encodedPoint | byte array with the encoded point
  len | the size of the array

Returns
  true if a point was decoded, false otherwise

Implements EncodedPoint< ECPPoint >.

Definition at line 582 of file ecp.cpp.

## ◆ EncodePoint() [1/2]

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

Encodes an elliptic curve point.

Parameters

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

## ◆ EncodePoint() [2/2]

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

Encodes an elliptic curve point.

Parameters

  bt | target BufferedTransformation
  P | point which is encoded
  compressed | flag indicating if the point is compressed

Implements EncodedPoint< ECPPoint >.

Definition at line 637 of file ecp.cpp.

## ◆ BERDecodePoint()

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

BER Decodes an elliptic curve point.

Parameters

  bt | source BufferedTransformation

Returns
  the decoded elliptic curve point

Implements EncodedPoint< ECPPoint >.

Definition at line 662 of file ecp.cpp.

## ◆ DEREncodePoint()

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

DER Encodes an elliptic curve point.

Parameters

  bt | target BufferedTransformation
  P | point which is encoded
  compressed | flag indicating if the point is compressed

Implements EncodedPoint< ECPPoint >.

Definition at line 672 of file ecp.cpp.

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

- ecp.h
- ecp.cpp