Botan: Botan::CurveGFp Class Reference

Botan 1.10.17

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 BigInt & | get_a () const
const BigInt & | get_a_r () const
const BigInt & | get_b () const
const BigInt & | get_b_r () const
const BigInt & | get_p () const
word | get_p_dash () const
size_t | get_p_words () const
const BigInt & | get_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) {}

## ◆ 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

  p | prime number of the field
  a | first coefficient
  b | second 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 }
Botan::BigInt::sig_words
size_t sig_words() const
Definition: bigint.h:290
Botan::inverse_mod
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:314
Botan::BigInt::Power2
Definition: bigint.h:38

## 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.

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

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.

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

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.

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

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.

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

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.

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

64 { return p; }

## ◆ 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.

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

69 { return r2; }

## ◆ operator==()

bool Botan::CurveGFp::operator== | ( | const CurveGFp & | other | ) | const
| inline

Equality operator

Parameters

  other | curve 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 }

## ◆ swap()

void Botan::CurveGFp::swap | ( | CurveGFp & | other | ) |
| inline

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

Parameters

  other | curve 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 }
std::swap
void swap(Botan::MemoryRegion< T > &x, Botan::MemoryRegion< T > &y)
Definition: secmem.h:438

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

- src/math/ec_gfp/curve_gfp.h