13 #if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 14 void LUC_TestInstantiations()
26 s = (k + x*(r+e)) % q;
35 Integer Vry = publicKey.ExponentiatePublicElement((r+e)%q);
36 return (Vsg*Vsg + Vry*Vry + r*r) % p == (Vsg * Vry * r + 4) % p;
41 return Lucas(exponent, m_g, static_cast<const DL_GroupPrecomputation_LUC &>(group).GetModulus());
46 for (
unsigned int i=0; i<exponentsCount; i++)
47 results[i] = Lucas(exponents[i], base, GetModulus());
69 return Lucas(m_e, x, m_n);
74 CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(level);
83 return GetValueHelper(
this, name, valueType, pValue).Assignable()
84 CRYPTOPP_GET_FUNCTION_ENTRY(
Modulus)
91 AssignFromHelper(
this, source)
92 CRYPTOPP_SET_FUNCTION_ENTRY(
Modulus)
104 bool IsAcceptable(
const Integer &candidate)
const 106 return RelativelyPrime(m_e, candidate+1) && RelativelyPrime(m_e, candidate-1);
113 int modulusSize = 2048;
116 if (modulusSize < 16)
117 throw InvalidArgument(
"InvertibleLUCFunction: specified modulus size is too small");
121 if (m_e < 5 || m_e.IsEven())
122 throw InvalidArgument(
"InvertibleLUCFunction: invalid public exponent");
126 (
"PointerToPrimeSelector", selector.GetSelectorPointer());
127 m_p.GenerateRandom(rng, primeParam);
128 m_q.GenerateRandom(rng, primeParam);
131 m_u = m_q.InverseMod(m_p);
136 GenerateRandom(rng,
MakeParameters(
"ModulusSize", (
int)keybits)(
"PublicExponent", e));
159 const byte version[] = {INTEGER, 1, 0};
160 seq.
Put(version,
sizeof(version));
172 CRYPTOPP_UNUSED(rng);
173 DoQuickSanityCheck();
174 return InverseLucas(m_e, x, m_q, m_p, m_u);
182 pass = pass && m_u.IsPositive() && m_u < m_p;
185 pass = pass && m_p * m_q == m_n;
186 pass = pass && RelativelyPrime(m_e, m_p+1);
187 pass = pass && RelativelyPrime(m_e, m_p-1);
188 pass = pass && RelativelyPrime(m_e, m_q+1);
189 pass = pass && RelativelyPrime(m_e, m_q-1);
190 pass = pass && m_u * m_q % m_p == 1;
199 return GetValueHelper<LUCFunction>(
this, name, valueType, pValue).Assignable()
200 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime1)
201 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime2)
208 AssignFromHelper<LUCFunction>(
this, source)
209 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime1)
210 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime2)
const char * MultiplicativeInverseOfPrime2ModPrime1()
Integer.
An invalid argument was detected.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
Classes for working with NameValuePairs.
const char * Prime2()
Integer.
bool IsOdd() const
Determines if the Integer is odd parity.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Interface for random number generators.
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
static const Integer & One()
Integer representing 1.
bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
Interface for Discrete Log (DL) public keys.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
const char * Prime1()
Integer.
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const
Calculates the inverse of an element.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
const char * PublicExponent()
Integer.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level=1)
Verifies a prime number.
Application callback to signal suitability of a cabdidate prime.
Multiple precision integer with arithmetic operations.
void BERDecodeError()
Raises a BERDecodeErr.
Classes and functions for working with ANS.1 objects.
Classes for SHA-1 and SHA-2 family of message digests.
Classes and functions for number theoretic operations.
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
Exponentiates a base to multiple exponents.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
An object that implements NameValuePairs.
const char * Modulus()
Integer.
Multiple precision integer with arithmetic operations.
Crypto++ library namespace.
virtual Element ExponentiateBase(const Integer &exponent) const
Retrieves the subgroup generator.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
virtual Integer GetGroupOrder() const
Retrieves the order of the group.
Interface for retrieving values given their names.
Template implementing constructors for public key algorithm classes.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
virtual const Integer & GetSubgroupOrder() const =0
Retrieves the subgroup order.