10 NAMESPACE_BEGIN(CryptoPP)
12 void LUC_TestInstantiations()
21 const Integer &q = params.GetSubgroupOrder();
22 r = params.ExponentiateBase(k);
23 s = (k + x*(r+e)) % q;
28 Integer p = params.GetGroupOrder()-1;
29 const Integer &q = params.GetSubgroupOrder();
31 Integer Vsg = params.ExponentiateBase(s);
32 Integer Vry = publicKey.ExponentiatePublicElement((r+e)%q);
33 return (Vsg*Vsg + Vry*Vry + r*r) % p == (Vsg * Vry * r + 4) % p;
38 return Lucas(exponent, m_g, static_cast<const DL_GroupPrecomputation_LUC &>(group).GetModulus());
41 void DL_GroupParameters_LUC::SimultaneousExponentiate(Element *results,
const Element &base,
const Integer *exponents,
unsigned int exponentsCount)
const
43 for (
unsigned int i=0; i<exponentsCount; i++)
44 results[i] = Lucas(exponents[i], base, GetModulus());
66 return Lucas(m_e, x, m_n);
73 pass = pass && m_e >
Integer::One() && m_e.IsOdd() && m_e < m_n;
79 return GetValueHelper(
this, name, valueType, pValue).Assignable()
80 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
81 CRYPTOPP_GET_FUNCTION_ENTRY(PublicExponent)
87 AssignFromHelper(
this, source)
88 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
89 CRYPTOPP_SET_FUNCTION_ENTRY(PublicExponent)
100 bool IsAcceptable(
const Integer &candidate)
const
102 return RelativelyPrime(m_e, candidate+1) && RelativelyPrime(m_e, candidate-1);
109 int modulusSize = 2048;
112 if (modulusSize < 16)
113 throw InvalidArgument(
"InvertibleLUCFunction: specified modulus size is too small");
117 if (m_e < 5 || m_e.IsEven())
118 throw InvalidArgument(
"InvertibleLUCFunction: invalid public exponent");
122 (
"PointerToPrimeSelector", selector.GetSelectorPointer());
123 m_p.GenerateRandom(rng, primeParam);
124 m_q.GenerateRandom(rng, primeParam);
132 GenerateRandom(rng, MakeParameters(
"ModulusSize", (
int)keybits)(
"PublicExponent", e));
155 const byte version[] = {INTEGER, 1, 0};
156 seq.Put(version,
sizeof(version));
168 DoQuickSanityCheck();
169 return InverseLucas(m_e, x, m_q, m_p, m_u);
175 pass = pass && m_p >
Integer::One() && m_p.IsOdd() && m_p < m_n;
176 pass = pass && m_q >
Integer::One() && m_q.IsOdd() && m_q < m_n;
177 pass = pass && m_u.IsPositive() && m_u < m_p;
180 pass = pass && m_p * m_q == m_n;
181 pass = pass && RelativelyPrime(m_e, m_p+1);
182 pass = pass && RelativelyPrime(m_e, m_p-1);
183 pass = pass && RelativelyPrime(m_e, m_q+1);
184 pass = pass && RelativelyPrime(m_e, m_q-1);
185 pass = pass && m_u * m_q % m_p == 1;
188 pass = pass && VerifyPrime(rng, m_p, level-2) && VerifyPrime(rng, m_q, level-2);
194 return GetValueHelper<LUCFunction>(
this, name, valueType, pValue).Assignable()
195 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
196 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
197 CRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
203 AssignFromHelper<LUCFunction>(
this, source)
204 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
205 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
206 CRYPTOPP_SET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
exception thrown when an invalid argument is detected
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
to be implemented by derived classes, users should use one of the above functions instead ...
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
T GetValueWithDefault(const char *name, T defaultValue) const
get a named value, returns the default if the name doesn't exist
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
interface for random number generators
static const Integer & One()
avoid calling constructors for these frequently used integers
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
to be implemented by derived classes, users should use one of the above functions instead ...
multiple precision integer and basic arithmetics
void DEREncode(BufferedTransformation &bt) const
encode using Distinguished Encoding Rules, put result into a BufferedTransformation object ...
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
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