Closed GoogleCodeExporter closed 8 years ago
A solution:
int fp_is_even2(fp_t a) {
bn_t t;
bn_null(t);
bn_new(t);
fp_prime_back(t, a);
bn_trim(t); //case FP_RDC == BASIC
if (bn_is_zero(t)) {
bn_free(t);
return 1;
}
if ((t->dp[0] & 0x01) == 0) {
bn_free(t);
return 1;
}
bn_free(t);
return 0;
}
Original comment by dio...@gmail.com
on 16 Jun 2011 at 12:34
Because I think:
fp_rand(f);
fp_prime_back(b);
TEST_ASSERT(fp_is_even(f) == bn_is_even(b), end); //but, it fails sometimes
Original comment by dio...@gmail.com
on 16 Jun 2011 at 6:59
Hello,
Please note that fp_is_even() returns if the prime field element is even on the
currently configured representation. For example, it should return the same
answer as bn_is_even() when FP_RDc == BASIC, but this is not required for
FP_RDC == MONTY.
What you are suggesting is a change in the module interface instead of a bug to
be fixed. Why do you need fp_is_even() and bn_is_even() to produce the same
result?
Thanks for the report!
Original comment by dfaranha
on 17 Jun 2011 at 7:52
I have a method that try break a Elliptic Curve Diffie-Hellman shared key, and
for this, execute a binary gcd, that need to know parities.
I am considering to convert my program to bn_t, although I will need to use
bn_mod after each operation.
Original comment by dio...@gmail.com
on 17 Jun 2011 at 11:37
If you don't execute a lot of operations mod p, it would be better to use bn_t,
or to convert the input to bn_t to use the bn_gcd() functions.
Original comment by dfaranha
on 17 Jun 2011 at 4:35
[deleted comment]
I assume the issue was solved by the user, since no further comments were
added, and consider the issue as solved.
Original comment by dfaranha
on 3 Jul 2011 at 3:01
Original comment by dfaranha
on 25 Dec 2013 at 11:32
Original issue reported on code.google.com by
dio...@gmail.com
on 15 Jun 2011 at 9:34