update CheckMOVCondition() according to http://eprint.iacr.org/2007/343
parent
800bd3ad85
commit
8edb9adc83
|
|
@ -46,11 +46,15 @@ static inline Integer ConvertToInteger(const Integer &x)
|
||||||
|
|
||||||
static bool CheckMOVCondition(const Integer &q, const Integer &r)
|
static bool CheckMOVCondition(const Integer &q, const Integer &r)
|
||||||
{
|
{
|
||||||
Integer t=1;
|
// see "Updated standards for validating elliptic curves", http://eprint.iacr.org/2007/343
|
||||||
unsigned int n=q.BitCount(), m=r.BitCount();
|
Integer t = 1;
|
||||||
|
unsigned int n = q.IsEven() ? 1 : q.BitCount(), m = r.BitCount();
|
||||||
|
|
||||||
for (unsigned int i=n; DiscreteLogWorkFactor(i)<m/2; i+=n)
|
for (unsigned int i=n; DiscreteLogWorkFactor(i)<m/2; i+=n)
|
||||||
{
|
{
|
||||||
|
if (q.IsEven())
|
||||||
|
t = (t+t)%r;
|
||||||
|
else
|
||||||
t = (t*q)%r;
|
t = (t*q)%r;
|
||||||
if (t == 1)
|
if (t == 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -658,10 +658,10 @@ bool ValidateEC2N()
|
||||||
#if 0 // TODO: turn this back on when I make EC2N faster for pentanomial basis
|
#if 0 // TODO: turn this back on when I make EC2N faster for pentanomial basis
|
||||||
cout << "Testing SEC 2 recommended curves..." << endl;
|
cout << "Testing SEC 2 recommended curves..." << endl;
|
||||||
OID oid;
|
OID oid;
|
||||||
while (!(oid = ECParameters<EC2N>::GetNextRecommendedParametersOID(oid)).m_values.empty())
|
while (!(oid = DL_GroupParameters_EC<EC2N>::GetNextRecommendedParametersOID(oid)).m_values.empty())
|
||||||
{
|
{
|
||||||
ECParameters<EC2N> params(oid);
|
DL_GroupParameters_EC<EC2N> params(oid);
|
||||||
bool fail = !params.ValidateParameters(GlobalRNG());
|
bool fail = !params.Validate(GlobalRNG(), 2);
|
||||||
cout << (fail ? "FAILED" : "passed") << " " << params.GetCurve().GetField().MaxElementBitLength() << " bits" << endl;
|
cout << (fail ? "FAILED" : "passed") << " " << params.GetCurve().GetField().MaxElementBitLength() << " bits" << endl;
|
||||||
pass = pass && !fail;
|
pass = pass && !fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue