Botan 1.10.17
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

◆ CurveGFp() [1/2]

Botan::CurveGFp::CurveGFp ( )
inline

Create an uninitialized CurveGFp

Definition at line 27 of file curve_gfp.h.

27: p_words(0), p_dash(0) {}

Referenced by Botan::EC_Group::EC_Group(), operator==(), and swap().

◆ CurveGFp() [2/2]

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.

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 }
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314

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

Member Function Documentation

◆ get_a()

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

Definition at line 53 of file curve_gfp.h.

53{ return a; }

◆ get_a_r()

const BigInt & Botan::CurveGFp::get_a_r ( ) const
inline
Returns
a * r mod p

Definition at line 74 of file curve_gfp.h.

74{ return a_r; }

◆ get_b()

const BigInt & Botan::CurveGFp::get_b ( ) const
inline
Returns
curve coefficient b

Definition at line 58 of file curve_gfp.h.

58{ return b; }

◆ get_b_r()

const BigInt & Botan::CurveGFp::get_b_r ( ) const
inline
Returns
b * r mod p

Definition at line 79 of file curve_gfp.h.

79{ return b_r; }

◆ get_p()

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.

64{ return p; }

Referenced by Botan::EC2OSP().

◆ get_p_dash()

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; }

◆ get_p_words()

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; }

◆ get_r2()

const BigInt & Botan::CurveGFp::get_r2 ( ) const
inline
Returns
Montgomery parameter r^2 % p

Definition at line 69 of file curve_gfp.h.

69{ return r2; }

◆ operator==()

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 }

References CurveGFp().

◆ swap()

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.

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:438

References CurveGFp(), and std::swap().

Referenced by std::swap< Botan::CurveGFp >().


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