Botan  1.10.9
Public Member Functions | List of all members
Botan::CurveGFp Class Reference

#include <curve_gfp.h>

Public Member Functions

 CurveGFp ()
 
 CurveGFp (const BigInt &p, const BigInt &a, const BigInt &b)
 
const BigIntget_a () const
 
const BigIntget_a_r () const
 
const BigIntget_b () const
 
const BigIntget_b_r () const
 
const BigIntget_p () const
 
word get_p_dash () const
 
size_t get_p_words () const
 
const BigIntget_r2 () const
 
bool operator== (const CurveGFp &other) const
 
void swap (CurveGFp &other)
 

Detailed Description

This class represents an elliptic curve over GF(p)

Definition at line 20 of file curve_gfp.h.

Constructor & Destructor Documentation

Botan::CurveGFp::CurveGFp ( )
inline

Create an uninitialized CurveGFp

Definition at line 27 of file curve_gfp.h.

27 : p_words(0), p_dash(0) {}
Botan::CurveGFp::CurveGFp ( const BigInt p,
const BigInt a,
const BigInt b 
)
inline

Construct the elliptic curve E: y^2 = x^3 + ax + b over GF(p)

Parameters
pprime number of the field
afirst coefficient
bsecond coefficient

Definition at line 35 of file curve_gfp.h.

References Botan::inverse_mod(), Botan::BigInt::Power2, and r.

35  :
36  p(p), a(a), b(b), p_words(p.sig_words())
37  {
38  BigInt r(BigInt::Power2, p_words * BOTAN_MP_WORD_BITS);
39 
40  p_dash = (((r * inverse_mod(r, p)) - 1) / p).word_at(0);
41 
42  r2 = (r * r) % p;
43  a_r = (a * r) % p;
44  b_r = (b * r) % p;
45  }
size_t sig_words() const
Definition: bigint.h:290
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:202
BigInt r
Definition: numthry.cpp:26

Member Function Documentation

const BigInt& Botan::CurveGFp::get_a ( ) const
inline
Returns
curve coefficient a

Definition at line 53 of file curve_gfp.h.

Referenced by Botan::EC_Group::DER_encode().

53 { return a; }
const BigInt& Botan::CurveGFp::get_a_r ( ) const
inline
Returns
a * r mod p

Definition at line 74 of file curve_gfp.h.

Referenced by Botan::PointGFp::on_the_curve().

74 { return a_r; }
const BigInt& Botan::CurveGFp::get_b ( ) const
inline
Returns
curve coefficient b

Definition at line 58 of file curve_gfp.h.

Referenced by Botan::EC_Group::DER_encode().

58 { return b; }
const BigInt& Botan::CurveGFp::get_b_r ( ) const
inline
Returns
b * r mod p

Definition at line 79 of file curve_gfp.h.

Referenced by Botan::PointGFp::on_the_curve().

79 { return b_r; }
const BigInt& Botan::CurveGFp::get_p ( ) const
inline

Get prime modulus of the field of the curve

Returns
prime modulus of the field of the curve

Definition at line 64 of file curve_gfp.h.

Referenced by Botan::ECDH_KA_Operation::agree(), Botan::EC_Group::DER_encode(), Botan::EC2OSP(), Botan::PointGFp::get_affine_x(), and Botan::PointGFp::get_affine_y().

64 { return p; }
word Botan::CurveGFp::get_p_dash ( ) const
inline
Returns
Montgomery parameter p-dash

Definition at line 84 of file curve_gfp.h.

84 { return p_dash; }
size_t Botan::CurveGFp::get_p_words ( ) const
inline
Returns
p.sig_words()

Definition at line 89 of file curve_gfp.h.

89 { return p_words; }
const BigInt& Botan::CurveGFp::get_r2 ( ) const
inline
Returns
Montgomery parameter r^2 % p

Definition at line 69 of file curve_gfp.h.

Referenced by Botan::PointGFp::get_affine_x(), Botan::PointGFp::get_affine_y(), and Botan::PointGFp::PointGFp().

69 { return r2; }
bool Botan::CurveGFp::operator== ( const CurveGFp other) const
inline

Equality operator

Parameters
othercurve to compare with
Returns
true iff this is the same curve as other

Definition at line 116 of file curve_gfp.h.

117  {
118  /*
119  Relies on choice of R, but that is fixed by constructor based
120  on size of p
121  */
122  return (p == other.p && a_r == other.a_r && b_r == other.b_r);
123  }
void Botan::CurveGFp::swap ( CurveGFp other)
inline

swaps the states of *this and other, does not throw

Parameters
othercurve to swap values with

Definition at line 95 of file curve_gfp.h.

References std::swap().

Referenced by Botan::PointGFp::swap().

96  {
97  std::swap(p, other.p);
98 
99  std::swap(a, other.a);
100  std::swap(b, other.b);
101 
102  std::swap(a_r, other.a_r);
103  std::swap(b_r, other.b_r);
104 
105  std::swap(p_words, other.p_words);
106 
107  std::swap(r2, other.r2);
108  std::swap(p_dash, other.p_dash);
109  }
void swap(Botan::MemoryRegion< T > &x, Botan::MemoryRegion< T > &y)
Definition: secmem.h:425

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