13 #if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 14 void LUC_TestInstantiations()
24 const Integer &q = params.GetSubgroupOrder();
25 r = params.ExponentiateBase(k);
26 s = (k + x*(r+e)) % q;
31 const Integer p = params.GetGroupOrder()-1;
32 const Integer &q = params.GetSubgroupOrder();
34 Integer Vsg = params.ExponentiateBase(s);
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());
44 void DL_GroupParameters_LUC::SimultaneousExponentiate(Element *results,
const Element &base,
const Integer *exponents,
unsigned int exponentsCount)
const 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);
77 pass = pass && m_e >
Integer::One() && m_e.IsOdd() && m_e < m_n;
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);
180 pass = pass && m_p >
Integer::One() && m_p.IsOdd() && m_p < m_n;
181 pass = pass && m_q >
Integer::One() && m_q.IsOdd() && m_q < m_n;
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.
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 DL public keys
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
const char * Prime1()
Integer.
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.
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 AssignFrom(const NameValuePairs &source)
Assign values to this object.
An object that implements NameValuePairs.
const char * Modulus()
Integer.
Crypto++ library namespace.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
Interface for retrieving values given their names.
A template implementing constructors for public key algorithm classes.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.