aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/numbertheory
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-04 21:26:02 -0500
committerJack Lloyd <[email protected]>2018-12-04 21:26:02 -0500
commitf37e1afc4af8cb70f23431077993463117c87202 (patch)
treec4b429a05589a9d3e806af0d20314db45da09695 /src/lib/math/numbertheory
parent4e16f683d7fd3a2ab0553c9423fc725798cd899f (diff)
Reduce the base in the fixed window exponentiator
Otherwise we can end up calling the Barrett reducer with an input that is more than the square of the modulus, which will make it fall back to the (slow) const time division. This only affected even moduli, and only when the base was larger than the modulus. OSS-Fuzz 11750
Diffstat (limited to 'src/lib/math/numbertheory')
-rw-r--r--src/lib/math/numbertheory/powm_fw.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/math/numbertheory/powm_fw.cpp b/src/lib/math/numbertheory/powm_fw.cpp
index c326ffa44..c6ff169a1 100644
--- a/src/lib/math/numbertheory/powm_fw.cpp
+++ b/src/lib/math/numbertheory/powm_fw.cpp
@@ -27,7 +27,7 @@ void Fixed_Window_Exponentiator::set_base(const BigInt& base)
m_g.resize(static_cast<size_t>(1) << m_window_bits);
m_g[0] = 1;
- m_g[1] = base;
+ m_g[1] = m_reducer.reduce(base);
for(size_t i = 2; i != m_g.size(); ++i)
m_g[i] = m_reducer.multiply(m_g[i-1], m_g[1]);