Otmane123 / relic-toolkit

Automatically exported from code.google.com/p/relic-toolkit
Other
0 stars 0 forks source link

is_even functions #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. fp_is_even errors
2. fb_is_even don't exists
3. bn_is_even succeeds, uff

What is the expected output? What do you see instead?
fp_is_even errors

What version of the product are you using? On what operating system?
0.2.3 - linux

Please provide any additional information below.

Original issue reported on code.google.com by dio...@gmail.com on 15 Jun 2011 at 9:34

GoogleCodeExporter commented 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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago

Original comment by dfaranha on 25 Dec 2013 at 11:32