update CheckMOVCondition() according to http://eprint.iacr.org/2007/343

pull/2/head
weidai 2007-09-24 02:54:22 +00:00
parent 800bd3ad85
commit 8edb9adc83
2 changed files with 10 additions and 6 deletions

View File

@ -46,12 +46,16 @@ static inline Integer ConvertToInteger(const Integer &x)
static bool CheckMOVCondition(const Integer &q, const Integer &r)
{
Integer t=1;
unsigned int n=q.BitCount(), m=r.BitCount();
// see "Updated standards for validating elliptic curves", http://eprint.iacr.org/2007/343
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)
{
t = (t*q)%r;
if (q.IsEven())
t = (t+t)%r;
else
t = (t*q)%r;
if (t == 1)
return false;
}

View File

@ -658,10 +658,10 @@ bool ValidateEC2N()
#if 0 // TODO: turn this back on when I make EC2N faster for pentanomial basis
cout << "Testing SEC 2 recommended curves..." << endl;
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);
bool fail = !params.ValidateParameters(GlobalRNG());
DL_GroupParameters_EC<EC2N> params(oid);
bool fail = !params.Validate(GlobalRNG(), 2);
cout << (fail ? "FAILED" : "passed") << " " << params.GetCurve().GetField().MaxElementBitLength() << " bits" << endl;
pass = pass && !fail;
}