Botan
3.11.0
Crypto and TLS for C&
src
lib
math
numbertheory
reducer.cpp
Go to the documentation of this file.
1
/*
2
* Modular Reducer
3
* (C) 1999-2011,2018,2025 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#include <botan/reducer.h>
9
10
#include <botan/exceptn.h>
11
#include <botan/internal/divide.h>
12
13
namespace
Botan
{
14
15
Modular_Reducer::Modular_Reducer
(
const
BigInt
& mod) : m_mod_words(mod.sig_words()) {
16
if
(mod < 0) {
17
throw
Invalid_Argument
(
"Modular_Reducer: modulus must be positive"
);
18
}
19
20
m_modulus = mod;
21
}
22
23
BigInt
Modular_Reducer::reduce
(
const
BigInt
& x)
const
{
24
return
ct_modulo
(x, m_modulus);
25
}
26
27
}
// namespace Botan
Botan::BigInt
Definition
bigint.h:26
Botan::Invalid_Argument
Definition
exceptn.h:132
Botan::Modular_Reducer::Modular_Reducer
Modular_Reducer()
Definition
reducer.h:69
Botan::Modular_Reducer::reduce
BigInt reduce(const BigInt &x) const
Definition
reducer.cpp:23
Botan
Definition
alg_id.cpp:13
Botan::ct_modulo
BigInt ct_modulo(const BigInt &x, const BigInt &y)
Definition
divide.cpp:192
Generated by
1.15.0