/*############################################################################ # Copyright 2017 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################*/ /// Unit tests of EFq2 implementation. /*! \file */ #include #include "epid/member/tiny/math/unittests/cmp-testhelper.h" extern "C" { #include "epid/member/tiny/math/efq2.h" #include "epid/member/tiny/math/mathtypes.h" } namespace { //////////////////////////////////////////////////////////////////////// // EFq2IsInf TEST(TinyEFq2Test, EFq2IsInfAcceptsPointAtInfinity) { const EccPointJacobiFq2 infinity = { {{0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}, {{0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EXPECT_TRUE(EFq2IsInf(&infinity)); } TEST(TinyEFq2Test, EFq2IsInfRejectsPointNotAtInfinity) { const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EXPECT_FALSE(EFq2IsInf(&left)); } //////////////////////////////////////////////////////////////////////// // EFq2FromAffine TEST(TinyEFq2Test, EFq2FromAffineWorks) { const EccPointJacobiFq2 expected = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointFq2 left_affine = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}}; EccPointJacobiFq2 actual = {0}; EFq2FromAffine(&actual, &left_affine); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // EFq2ToAffine TEST(TinyEFq2Test, EFq2ToAffineWorks) { const EccPointFq2 expected = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}}; const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EccPointFq2 actual = {0}; EFq2ToAffine(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // EFq2Dbl TEST(TinyEFq2Test, EFq2DblWorks) { const EccPointJacobiFq2 expected = { {{0xca2899c2, 0x38294bdb, 0xcf0b6b44, 0x270787b1, 0x28e6e40a, 0x2b848c15, 0x03729665, 0xd042f637}, {0xda226e33, 0x9e951b73, 0x7df4afb1, 0x4b44fcd5, 0x133d08f1, 0x703ec2c1, 0x93fe9a4c, 0x014c1d38}}, {{0xbd697392, 0x2bed001e, 0xde312107, 0x1c7a00ac, 0xc1c7c40e, 0xd720bece, 0x6e98a67e, 0xaac006b6}, {0x43a25c32, 0x51296e80, 0x318d99a6, 0xd60e60d3, 0xdb3084d0, 0x0625d792, 0x25f4ca7e, 0x0a310fe4}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EccPointJacobiFq2 actual = {0}; EFq2Dbl(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // EFq2Add TEST(TinyEFq2Test, EFq2AddWorks) { const EccPointJacobiFq2 expected = { {{0x39d576f0, 0x314c3e0a, 0xdc7933c4, 0xb93a1af7, 0xa0b903f1, 0xd5648523, 0x4745740d, 0xcd182581}, {0x32365bad, 0x8351f42f, 0xd587f58a, 0x46b5c664, 0x11a71e4f, 0x8fde4189, 0xa0dbb9b6, 0x35a921cf}}, {{0xb1d07f87, 0x27fca861, 0xeb87751b, 0x40dee15b, 0x7abc2d89, 0xde6431b7, 0x23bcc963, 0x79a7d75a}, {0x5adc76e4, 0xb6a78fa4, 0xb4e50dbd, 0xd503cacd, 0xf188a97f, 0xc89769d8, 0xd3da3cb0, 0x4e50dbe9}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 right = { {{0x4103138f, 0xfa13e67e, 0x6837bfdf, 0x00565944, 0x11264453, 0x23f40661, 0x673da0e0, 0xed12700d}, {0x98f68547, 0x9cb87218, 0xc5ec70e5, 0x0c893388, 0x21dd4d22, 0x53386c5c, 0x2b310753, 0xeca20f0e}}, {{0x17a5237e, 0x3f8bfc68, 0xfd8f3ccc, 0xa630561a, 0xbf57703a, 0x68135f32, 0xe230d781, 0xd544af99}, {0x92ebeb94, 0x99b0cff6, 0xeebac3e7, 0x7d7aa73f, 0x7064674d, 0x25d8834a, 0x7c64ff8b, 0x97e6a2ac}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EccPointJacobiFq2 actual = {0}; EFq2Add(&actual, &left, &right); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // EFq2Neg TEST(TinyEFq2Test, EFq2NegWorks) { const EccPointJacobiFq2 expected = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x876cdaca, 0x1d7a77aa, 0x730fb243, 0x1817c20a, 0x66f6a147, 0x7a82f2b1, 0xb83b6256, 0x08963678}, {0xd6e605ff, 0x3585805b, 0x9ecba21a, 0x921d0bd7, 0x033c1324, 0x8b6f68a7, 0xb9cb5b5f, 0xb8809ef0}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EccPointJacobiFq2 actual = {0}; EFq2Neg(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // EFq2MulSSCM TEST(TinyEFq2Test, EFq2MultSSCMWorks) { const EccPointJacobiFq2 expected = { {{0x75e057c7, 0x324aeb39, 0x0246ce8a, 0xe467356d, 0x4fcae21a, 0xeb58c86e, 0x12447362, 0x1c02af0c}, {0xfc9e5806, 0x790f79e8, 0xeffb940f, 0x44b942aa, 0xce364572, 0x8f1d0b6d, 0xf2238fe0, 0x4c281551}}, {{0x8e525052, 0x840bf78d, 0xf0a1e53a, 0xd43b1688, 0x1566bee6, 0x715cb6d2, 0x27f8a10c, 0x62806aa5}, {0xfe573502, 0x1b24a341, 0xffab4d71, 0x445e2e0c, 0x7f3aa342, 0x3013d966, 0x69b239fa, 0x074a471c}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const FpElem power = {0xeb515e82, 0xda641a2f, 0x642e3fdc, 0x242d1caf, 0xfd1cd76b, 0x60558750, 0x13fd607c, 0xd4a85a40}; EccPointJacobiFq2 actual = {0}; EFq2MulSSCM(&actual, &left, &power); EXPECT_EQ(expected, actual); } TEST(TinyEFq2Test, EFq2MultSSCMWorksInPlace) { const EccPointJacobiFq2 expected = { {{0x75e057c7, 0x324aeb39, 0x0246ce8a, 0xe467356d, 0x4fcae21a, 0xeb58c86e, 0x12447362, 0x1c02af0c}, {0xfc9e5806, 0x790f79e8, 0xeffb940f, 0x44b942aa, 0xce364572, 0x8f1d0b6d, 0xf2238fe0, 0x4c281551}}, {{0x8e525052, 0x840bf78d, 0xf0a1e53a, 0xd43b1688, 0x1566bee6, 0x715cb6d2, 0x27f8a10c, 0x62806aa5}, {0xfe573502, 0x1b24a341, 0xffab4d71, 0x445e2e0c, 0x7f3aa342, 0x3013d966, 0x69b239fa, 0x074a471c}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EccPointJacobiFq2 left = {{{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const FpElem power = {0xeb515e82, 0xda641a2f, 0x642e3fdc, 0x242d1caf, 0xfd1cd76b, 0x60558750, 0x13fd607c, 0xd4a85a40}; EFq2MulSSCM(&left, &left, &power); EXPECT_EQ(expected, left); } //////////////////////////////////////////////////////////////////////// // EFq2Eq TEST(TinyEFq2Test, EFq2EqConfirmsPointsAreEqual) { const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 left_2 = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EXPECT_TRUE(EFq2Eq(&left, &left_2)); } TEST(TinyEFq2Test, EFq2EqDeniesPointsAreEqual) { const EccPointJacobiFq2 left = { {{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; const EccPointJacobiFq2 right = { {{0x4103138f, 0xfa13e67e, 0x6837bfdf, 0x00565944, 0x11264453, 0x23f40661, 0x673da0e0, 0xed12700d}, {0x98f68547, 0x9cb87218, 0xc5ec70e5, 0x0c893388, 0x21dd4d22, 0x53386c5c, 0x2b310753, 0xeca20f0e}}, {{0x17a5237e, 0x3f8bfc68, 0xfd8f3ccc, 0xa630561a, 0xbf57703a, 0x68135f32, 0xe230d781, 0xd544af99}, {0x92ebeb94, 0x99b0cff6, 0xeebac3e7, 0x7d7aa73f, 0x7064674d, 0x25d8834a, 0x7c64ff8b, 0x97e6a2ac}}, {{0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}; EXPECT_FALSE(EFq2Eq(&left, &right)); } //////////////////////////////////////////////////////////////////////// // EFq2OnCurve TEST(TinyEFq2Test, EFq2OnCurveConfirmsPointOnCurve) { const EccPointFq2 left = {{{0xbf501131, 0x84025734, 0xe72a81d4, 0x0a3da790, 0x5303da83, 0x693bbb16, 0x679b2a8a, 0x06f54dd4}, {0xa15aebed, 0x5eabe073, 0x5585c8aa, 0xc27f168c, 0xa7b61e37, 0x209517cf, 0x534cd776, 0x4759d7f6}}, {{0x27665549, 0xb5aeb631, 0x9f88583f, 0xf4c4a3f0, 0x877b0357, 0xcc62ffad, 0x47c18e76, 0xf769c987}, {0xd7ed2a14, 0x9da3ad7f, 0x73cc6868, 0x7abf5a23, 0xeb35917a, 0xbb7689b7, 0x4631956d, 0x477f610f}}}; EXPECT_TRUE(EFq2OnCurve(&left)); } TEST(TinyEFq2Test, EFq2OnCurveRejectsPointOffCurve) { const EccPointFq2 invalid = { {{0x705eb0a4, 0xf30863e3, 0x6127e751, 0x15adee42, 0xb00baac0, 0x194dee74, 0xb39bf2f3, 0x88b75019}, {0x60d7ec1d, 0xd80f96dd, 0x731c01d7, 0xbf697161, 0x087e5f87, 0x91f4fe08, 0xd1942d15, 0x62b03177}}, {{0x38f6d02a, 0xae5274db, 0xb7eddcf3, 0xcf4ff611, 0x589140a6, 0xcbacb49c, 0x48c50543, 0x1da802e9}, {0x45b0c6f3, 0x52393bf1, 0xc70746b0, 0xa08caeba, 0x5cb44254, 0x53ebeb2a, 0x620ea440, 0x2c3a40f1}}}; EXPECT_FALSE(EFq2OnCurve(&invalid)); } } // namespace