summaryrefslogtreecommitdiff
path: root/rw.h
diff options
context:
space:
mode:
Diffstat (limited to 'rw.h')
-rw-r--r--rw.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/rw.h b/rw.h
index 6820251..45b3946 100644
--- a/rw.h
+++ b/rw.h
@@ -48,8 +48,9 @@ class CRYPTOPP_DLL InvertibleRWFunction : public RWFunction, public TrapdoorFunc
typedef InvertibleRWFunction ThisClass;
public:
- void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u)
- {m_n = n; m_p = p; m_q = q; m_u = u;}
+ InvertibleRWFunction() : m_precompute(false) {}
+
+ void Initialize(const Integer &n, const Integer &p, const Integer &q, const Integer &u);
// generate a random private key
void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits)
{GenerateRandomWithKeySize(rng, modulusBits);}
@@ -79,8 +80,21 @@ public:
void SetPrime2(const Integer &q) {m_q = q;}
void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer &u) {m_u = u;}
+ virtual bool SupportsPrecomputation() const {return true;}
+ virtual void Precompute(unsigned int unused = 0) {PrecomputeTweakedRoots();}
+ virtual void Precompute(unsigned int unused = 0) const {PrecomputeTweakedRoots();}
+
+ virtual void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
+ virtual void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
+
+protected:
+ void PrecomputeTweakedRoots() const;
+
protected:
Integer m_p, m_q, m_u;
+
+ mutable Integer m_pre_2_9p, m_pre_2_3q, m_pre_q_p;
+ mutable bool m_precompute;
};
//! RW