Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplying G2 elements fails if scalar is bigger than group order #126

Closed
wouterl opened this issue Feb 27, 2020 · 2 comments
Closed

Multiplying G2 elements fails if scalar is bigger than group order #126

wouterl opened this issue Feb 27, 2020 · 2 comments

Comments

@wouterl
Copy link
Contributor

wouterl commented Feb 27, 2020

It seems that g2_mul misbehaves if the scalar is larger than the group order. Here is a failing test for a scalar that is twice the group order. I would expect the test to pass, and in fact it does for G1.

diff --git a/test/test_pc.c b/test/test_pc.c
index ab83deca..0b5f86e3 100755
--- a/test/test_pc.c
+++ b/test/test_pc.c
@@ -930,6 +930,14 @@ static int multiplication2(void) {
                        g2_mul(r, p, n);
                        TEST_ASSERT(g2_is_infty(r) == 1, end);
                } TEST_END;
+
+               TEST_BEGIN("reduction by group order is correct") {
+                       bn_set_dig(k, 2);
+                       bn_mul(k, k, n);
+                       // k = 2 * order
+                       g2_mul(r, p, k);
+                       TEST_ASSERT(g2_is_infty(r) == 1, end);
+               } TEST_END;
        }
        CATCH_ANY {
                util_print("FATAL ERROR!\n");

At least when using presets/x64-pbc-bls638.sh this fails. Tested on latest master.

@dfaranha
Copy link
Contributor

Thanks for notifying!

This was tentatively fixed in the latest version in the repository. Can you please check?

It is still a problem for lower level interfaces (f.x. see issue #64), but the PC module now always reduces the exponent/scalar.

@wouterl
Copy link
Contributor Author

wouterl commented Feb 28, 2020

Yes, fixed! Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants