Crypto++
8.3
Free C++ class library of cryptographic schemes
|
5 #ifndef CRYPTOPP_IMPORTS
16 m_base = group.NeedConversions() ? group.ConvertIn(i_base) : i_base;
18 if (m_bases.empty() || !(m_base == m_bases[0]))
24 if (group.NeedConversions())
35 m_windowSize = (maxExpBits+storage-1)/storage;
39 m_bases.resize(storage);
40 for (
unsigned i=1; i<storage; i++)
41 m_bases[i] = group.
GetGroup().ScalarMultiply(m_bases[i-1], m_exponentBase);
48 BERDecodeUnsigned<word32>(seq, version,
INTEGER, 1, 1);
49 m_exponentBase.BERDecode(seq);
50 m_windowSize = m_exponentBase.BitCount() - 1;
62 DEREncodeUnsigned<word32>(seq, 1);
63 m_exponentBase.DEREncode(seq);
64 for (
unsigned i=0; i<m_bases.size(); i++)
77 for (i=0; i+1<m_bases.size(); i++)
81 if (fastNegate && r.
GetBit(m_windowSize-1))
94 std::vector<BaseAndExponent<Element> > eb;
95 eb.reserve(m_bases.size());
96 PrepareCascade(group, eb, exponent);
97 return group.
ConvertOut(GeneralCascadeMultiplication<Element>(group.
GetGroup(), eb.begin(), eb.end()));
104 std::vector<BaseAndExponent<Element> > eb;
106 eb.reserve(m_bases.size() + pc2.m_bases.size());
107 PrepareCascade(group, eb, exponent);
108 pc2.PrepareCascade(group, eb, exponent2);
109 return group.
ConvertOut(GeneralCascadeMultiplication<Element>(group.
GetGroup(), eb.begin(), eb.end()));
bool GetBit(size_t i) const
Provides the i-th bit of the Integer.
void swap(::SecBlock< T, A > &a, ::SecBlock< T, A > &b)
Swap two SecBlocks.
Element CascadeExponentiate(const DL_GroupPrecomputation< Element > &pc1, const Integer &exponent1, const DL_FixedBasePrecomputation< Element > &pc2, const Integer &exponent2) const
Exponentiates an element.
DL_FixedBasePrecomputation interface.
static void CRYPTOPP_API DivideByPowerOf2(Integer &r, Integer &q, const Integer &a, unsigned int n)
Extended Division.
void MessageEnd()
Signals the end of messages to the object.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
virtual const AbstractGroup< Element > & GetGroup() const =0
Retrieves AbstractGroup interface.
void Precompute(const DL_GroupPrecomputation< Element > &group, unsigned int maxExpBits, unsigned int storage)
Perform precomputation.
static Integer CRYPTOPP_API Power2(size_t e)
Exponentiates to a power of 2.
DL_GroupPrecomputation interface.
Element Exponentiate(const DL_GroupPrecomputation< Element > &group, const Integer &exponent) const
Exponentiates an element.
void Load(const DL_GroupPrecomputation< Element > &group, BufferedTransformation &storedPrecomputation)
Retrieve previously saved precomputation.
Classes for precomputation in a group.
virtual Element ConvertOut(const Element &v) const
Converts an element between representations.
Classes and functions for working with ANS.1 objects.
virtual bool NeedConversions() const
Determines if elements needs conversion.
void MessageEnd()
Signals the end of messages to the object.
virtual Element BERDecodeElement(BufferedTransformation &bt) const =0
Decodes element in DER format.
DL_FixedBasePrecomputation adapter class.
Classes for performing mathematics over different fields.
Crypto++ library namespace.
virtual void DEREncodeElement(BufferedTransformation &bt, const Element &P) const =0
Encodes element in DER format.
virtual const Element & Inverse(const Element &a) const =0
Inverts the element in the group.
bool EndReached() const
Determine end of stream.
Multiple precision integer with arithmetic operations.
void Save(const DL_GroupPrecomputation< Element > &group, BufferedTransformation &storedPrecomputation) const
Save precomputation for later use.
virtual bool InversionIsFast() const
Determine if inversion is fast.
Multiple precision integer with arithmetic operations.