Botan 1.10.17

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

`#include <def_powm.h>`

Inheritance diagram for Botan::Fixed_Window_Exponentiator:

## Public Member Functions
Modular_Exponentiator * | copy () const
BigInt | execute () const
| Fixed_Window_Exponentiator (const BigInt &, Power_Mod::Usage_Hints)
void | set_base (const BigInt &)
void | set_exponent (const BigInt &)

## Detailed Description

Fixed Window Exponentiator

Definition at line 20 of file def_powm.h.

## Constructor & Destructor Documentation

## ◆ Fixed_Window_Exponentiator()

Botan::Fixed_Window_Exponentiator::Fixed_Window_Exponentiator | ( | const BigInt & | n,
|  | Power_Mod::Usage_Hints | hints
| ) |  |

Definition at line 61 of file powm_fw.cpp.

Referenced by copy().

63 {
64 reducer = Modular_Reducer(n);
65 this->hints = hints;
66 window_bits = 0;
67 }

## Member Function Documentation

## ◆ copy()

Modular_Exponentiator* Botan::Fixed_Window_Exponentiator::copy | ( |  | ) | const
| inline virtual

Implements Botan::Modular_Exponentiator.

Definition at line 27 of file def_powm.h.

References Fixed_Window_Exponentiator().

28 { return new Fixed_Window_Exponentiator(*this); }
Botan::Fixed_Window_Exponentiator::Fixed_Window_Exponentiator
Fixed_Window_Exponentiator(const BigInt &, Power_Mod::Usage_Hints)
Definition: powm_fw.cpp:61

## ◆ execute()

BigInt Botan::Fixed_Window_Exponentiator::execute | ( |  | ) | const
| virtual

Implements Botan::Modular_Exponentiator.

Definition at line 40 of file powm_fw.cpp.

References Botan::BigInt::bits(), Botan::BigInt::get_substring(), Botan::Modular_Reducer::multiply(), and Botan::Modular_Reducer::square().

41 {
42 const size_t exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
43
44 BigInt x = 1;
45
46 for(size_t i = exp_nibbles; i > 0; --i)
47 {
48 for(size_t j = 0; j != window_bits; ++j)
49 x = reducer.square(x);
50
51 const u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits);
52
53 x = reducer.multiply(x, g[nibble]);
54 }
55 return x;
56 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254
Botan::BigInt::get_substring
u32bit get_substring(size_t offset, size_t length) const
Definition: bigint.cpp:169
Botan::Modular_Reducer::square
BigInt square(const BigInt &x) const
Definition: reducer.h:39
Botan::Modular_Reducer::multiply
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31
Botan::u32bit
unsigned int u32bit
Definition: types.h:32

## ◆ set_base()

void Botan::Fixed_Window_Exponentiator::set_base | ( | const BigInt & | base | ) |
| virtual

Implements Botan::Modular_Exponentiator.

Definition at line 25 of file powm_fw.cpp.

26 {
27 window_bits = Power_Mod::window_bits(exp.bits(), base.bits(), hints);
28
29 g.resize((1 << window_bits));
30 g[0] = 1;
31 g[1] = base;
32
33 for(size_t i = 2; i != g.size(); ++i)
34 g[i] = reducer.multiply(g[i-1], g[1]);
35 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254
Botan::Power_Mod::window_bits
static size_t window_bits(size_t exp_bits, size_t base_bits, Power_Mod::Usage_Hints hints)
Definition: pow_mod.cpp:119
Botan::Modular_Reducer::multiply
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31

## ◆ set_exponent()

void Botan::Fixed_Window_Exponentiator::set_exponent | ( | const BigInt & | e | ) |
| virtual

Implements Botan::Modular_Exponentiator.

Definition at line 17 of file powm_fw.cpp.

18 {
19 exp = e;
20 }

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

- src/math/numbertheory/def_powm.h
- src/math/numbertheory/powm_fw.cpp