/*############################################################################ # 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 Fq12 implementation. /*! \file */ #include #include "epid/member/tiny/math/unittests/cmp-testhelper.h" extern "C" { #include "epid/member/tiny/math/fq12.h" #include "epid/member/tiny/math/mathtypes.h" } namespace { //////////////////////////////////////////////////////////////////////// // Fq12Add TEST(TinyFq12Test, Fq12AddWorks) { Fq12Elem expected = {{{{0xf8898202, 0xb45883e0, 0x8d18168d, 0xf67a4288, 0xec7c2a8a, 0xfa6f0441, 0xff5583e2, 0x32d88286}, {0x304722d5, 0x113e09d3, 0xeaf32297, 0x32d71c16, 0x1cb0685b, 0xe3315524, 0xafd38377, 0xfeae3272}}, {{0xc82d8518, 0x99cec06c, 0xe8d7d62b, 0x2f00d5c5, 0x0620146e, 0x2741e62b, 0x9e7557ca, 0xeb019297}, {0x15cfc66e, 0x55ba87c0, 0xf1060150, 0xb91180f6, 0xb0d77f5f, 0xc7fa8733, 0x7dc697f1, 0x1e6b8e24}}, {{0x1400db26, 0x0760a0b1, 0x1a64565f, 0x27b5641e, 0xd96484ed, 0x54b02297, 0xa2a57172, 0xc3a04c1c}, {0x17ff87fb, 0x6294fcdb, 0x8f7c4bc2, 0xd0802fe6, 0xee3d7f1b, 0xf19d63af, 0xdb1d00ae, 0x80df53e6}}}, {{{0xc8c6cded, 0x0a290583, 0xd4ab7f8b, 0x867f6ac5, 0x791662bb, 0x893f1baa, 0xfc911068, 0xe97be9e3}, {0xdb9666f2, 0x1ff150ee, 0xd8691261, 0x5efee8a7, 0x0c67c4e5, 0x1501f7e4, 0xde7e72d8, 0x01ab1a71}}, {{0x85a5659c, 0xcfd4464f, 0xea3b0e64, 0x4a85994f, 0x0e842121, 0x939ca516, 0x55e1a4b6, 0xb92af8fa}, {0xb2bfc7eb, 0x71e5dd9d, 0x16b23032, 0x8590e174, 0x88a246af, 0x7d317c63, 0xc8f3a39a, 0x903a091d}}, {{0xf0df5efe, 0x5a88ee12, 0xb0d81569, 0x70172a9f, 0xa330fbf2, 0x36a7ea66, 0x95287dc2, 0x99c6386b}, {0x875888c7, 0xa3fa338b, 0x52d41dbe, 0x36960893, 0xfdf09874, 0x3986d2ba, 0xa9eb891e, 0x5cf05c6f}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem right = {{{{0x848cdb73, 0x6399829e, 0xcaa20cc0, 0x1b02bff6, 0x2b477bd2, 0xf9d48534, 0xff7929a0, 0xd4745161}, {0xe323d956, 0xf8a05a85, 0xe02d5e1e, 0xfd533966, 0xe7d31209, 0xc7786143, 0x91b441f6, 0x7409d67d}}, {{0xc763c01c, 0x8d45cdc1, 0xe46054e2, 0xc6216337, 0x97589d24, 0xe57d5f07, 0xeec3f4b6, 0xfe2a593f}, {0x96748337, 0x31fbd2e4, 0x72e72c33, 0x96fe633a, 0x4f48fed2, 0xf6a92484, 0x5e7de24a, 0x8a963657}}, {{0x48a24137, 0xc529544f, 0xe83111bc, 0xbd151156, 0x6b0c7ee2, 0x1bc18974, 0x01193d6b, 0x6b716d4d}, {0x90c2469b, 0xb1ae7b57, 0x22ce6905, 0x58c5a086, 0xc750dfa2, 0x28ea9d9d, 0x6134f34f, 0x68cf7885}}}, {{{0x771f4d50, 0x113c642f, 0x983d5b97, 0xd8fed4c2, 0x166e53b0, 0x4797d81c, 0x9955788c, 0xbd7c6c23}, {0xd9d2246a, 0x092e1780, 0xd8a1ac25, 0xc23607e5, 0x8c58b02e, 0x2c543c7e, 0x4c082083, 0xc4577f4d}}, {{0xb433c5de, 0x6ab7893e, 0x5ff5e970, 0x24de35b6, 0x65b8022c, 0x89c649d3, 0x7629ec0b, 0x6046bfbd}, {0xcdab3158, 0xefd0e691, 0xeb7ca8b3, 0xbbe4015c, 0xcb5d6828, 0xd313d3ec, 0x0b0125d2, 0xac823c7f}}, {{0x3e500486, 0xd17db7a2, 0x8d174e88, 0x8504ae57, 0x1d09fdcb, 0xeda97288, 0xd8a573c9, 0x32233b3f}, {0x41145b9e, 0x4f61f713, 0xd1caf67d, 0x3299a2ff, 0x3586b78d, 0x6b31995f, 0xe51708e4, 0x9eab4090}}}}; Fq12Elem actual = {0}; Fq12Add(&actual, &left, &right); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Sub TEST(TinyFq12Test, Fq12SubWorks) { Fq12Elem expected = {{{{0x4d162b42, 0x9377da5b, 0x1d041212, 0xda2d8e91, 0x72d07c24, 0x9491de97, 0x005d123b, 0x89efdfc3}, {0x69ff7029, 0x1ffd54c7, 0x2a986659, 0x3830a949, 0x4d0a4447, 0x5440929c, 0x8c6aff8a, 0x169a8577}}, {{0x970c6506, 0x259580a0, 0x4547416c, 0xbc76db4c, 0xb4522362, 0xea130cd9, 0xc0e74ff6, 0xeeace017}, {0x97b9f013, 0xc4ec0fd2, 0x1dcfb36c, 0x97f1207d, 0x00b72659, 0x218e308a, 0xc0c7c429, 0x093f2175}}, {{0x318f88cb, 0x503725ee, 0x5c9a3d68, 0xba67a76b, 0xf1bd2bc6, 0x6413020d, 0xa06fe769, 0xecbd7182}, {0xa54e2ad8, 0xd2613407, 0x5c778439, 0x2bd154d5, 0x4e0d6476, 0xe6ae1ad3, 0x18b00add, 0xaf4062dc}}}, {{{0x895b6360, 0xbad96b00, 0xb6c8d2df, 0xe15e273b, 0x3aab5ff8, 0x40f55dd1, 0xc9e3101d, 0x6e83119c}, {0x85987e44, 0xb3e77da4, 0x4c55cf1c, 0xf44ba4d2, 0xd099adc5, 0x4a2563a4, 0x4668136c, 0x78fc1bd7}}, {{0xcc1109f3, 0xcd8e61ad, 0x3ce74606, 0x0da593de, 0x3185c168, 0xc6f603ce, 0x698abd6c, 0xf89d797f}, {0xc63c954e, 0x656d3e55, 0x5250e94d, 0x1aa544b5, 0xe0591afd, 0x1defc6e8, 0xb2ee48c2, 0x3735901f}}, {{0x743f55f2, 0xb78d7ece, 0x96a97857, 0x660dcdf0, 0x691d005b, 0x5b550556, 0xe3dd962e, 0x357fc1eb}, {0xb403019e, 0xd85f7340, 0xc1d63b46, 0xde3f288e, 0x8154cdf8, 0xaa09925b, 0xdfba6822, 0x1f99db4d}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem right = {{{{0x848cdb73, 0x6399829e, 0xcaa20cc0, 0x1b02bff6, 0x2b477bd2, 0xf9d48534, 0xff7929a0, 0xd4745161}, {0xe323d956, 0xf8a05a85, 0xe02d5e1e, 0xfd533966, 0xe7d31209, 0xc7786143, 0x91b441f6, 0x7409d67d}}, {{0xc763c01c, 0x8d45cdc1, 0xe46054e2, 0xc6216337, 0x97589d24, 0xe57d5f07, 0xeec3f4b6, 0xfe2a593f}, {0x96748337, 0x31fbd2e4, 0x72e72c33, 0x96fe633a, 0x4f48fed2, 0xf6a92484, 0x5e7de24a, 0x8a963657}}, {{0x48a24137, 0xc529544f, 0xe83111bc, 0xbd151156, 0x6b0c7ee2, 0x1bc18974, 0x01193d6b, 0x6b716d4d}, {0x90c2469b, 0xb1ae7b57, 0x22ce6905, 0x58c5a086, 0xc750dfa2, 0x28ea9d9d, 0x6134f34f, 0x68cf7885}}}, {{{0x771f4d50, 0x113c642f, 0x983d5b97, 0xd8fed4c2, 0x166e53b0, 0x4797d81c, 0x9955788c, 0xbd7c6c23}, {0xd9d2246a, 0x092e1780, 0xd8a1ac25, 0xc23607e5, 0x8c58b02e, 0x2c543c7e, 0x4c082083, 0xc4577f4d}}, {{0xb433c5de, 0x6ab7893e, 0x5ff5e970, 0x24de35b6, 0x65b8022c, 0x89c649d3, 0x7629ec0b, 0x6046bfbd}, {0xcdab3158, 0xefd0e691, 0xeb7ca8b3, 0xbbe4015c, 0xcb5d6828, 0xd313d3ec, 0x0b0125d2, 0xac823c7f}}, {{0x3e500486, 0xd17db7a2, 0x8d174e88, 0x8504ae57, 0x1d09fdcb, 0xeda97288, 0xd8a573c9, 0x32233b3f}, {0x41145b9e, 0x4f61f713, 0xd1caf67d, 0x3299a2ff, 0x3586b78d, 0x6b31995f, 0xe51708e4, 0x9eab4090}}}}; Fq12Elem actual = {0}; Fq12Sub(&actual, &left, &right); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Square TEST(TinyFq12Test, Fq12SquareWorks) { Fq12Elem expected = {{{{0xb2718e2f, 0x5acdc81c, 0x00964828, 0x20087676, 0x5ae15b61, 0x4fd4da11, 0xe092dfeb, 0x58534fb6}, {0xccc9dc07, 0x1004c642, 0x4d95229d, 0x82350b1c, 0x9771ce95, 0xd9a24ede, 0xbd10467b, 0xc7ed3445}}, {{0xbde22884, 0x8354762f, 0x86ba1554, 0x63db32bb, 0x0bae02fd, 0x6d0d96e8, 0xcf9ffd11, 0xb8fe4b31}, {0x2d04f196, 0x23e1a987, 0x99e976e3, 0xa037f309, 0xe90221d9, 0x201fec2a, 0x46d79de9, 0xc93a6bd2}}, {{0x5c58af07, 0xd9343489, 0xb4f19136, 0xff508b82, 0xc14265f4, 0xa4d22c7b, 0x6e928f38, 0xe279749e}, {0xa1d790b2, 0xcf37602c, 0xc842e733, 0x72c2773a, 0xc4d0ad50, 0x707594fb, 0x969b8864, 0x0979561b}}}, {{{0x24a687fb, 0xfb396e79, 0xc34718eb, 0x2b491ee6, 0xba812deb, 0xc6dfa2d8, 0x4c2bd958, 0x692fc435}, {0x0b3d5a09, 0xb3310b79, 0xcb0179fe, 0x8e8a4e82, 0x79cf9278, 0x1b884773, 0xe7bfdc35, 0xb64b17bf}}, {{0x7928c472, 0xbc2fe39f, 0xa4eff880, 0xd700813f, 0x555725f0, 0x43a4f63e, 0x857b8b39, 0x96614e14}, {0x0ba1d9bb, 0x78f7e930, 0x13c1d603, 0xe2f9587b, 0x19c67a04, 0x3931bdf3, 0x3c6271ae, 0xdde60cd5}}, {{0xa376e35d, 0xd157352f, 0x040e0af6, 0x0e36afd1, 0x9cfbfb84, 0x9cd3d83a, 0x94b83ec5, 0x1de41161}, {0xf1424d67, 0x5ecaee6f, 0x25a809b2, 0x00abd96d, 0x2b2da6c7, 0xbcfeab22, 0x6072fb3a, 0x75474592}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem actual = {0}; Fq12Square(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Mul TEST(TinyFq12Test, Fq12MultWorks) { Fq12Elem expected = {{{{0x054b2248, 0x40490d13, 0xa309fba1, 0xcda4a1ef, 0xe6efd6b9, 0x6dbdd131, 0xfde112e9, 0xaf90b12e}, {0x4e21c944, 0x03e20ec3, 0xed4543f5, 0x7a577659, 0x81d1fd42, 0xea9a8c1c, 0x791b36af, 0x870740ff}}, {{0x8d2c2a6e, 0xe8ce5ca0, 0xe528c957, 0x84cd9406, 0x34a3c63a, 0x2b928ab5, 0x66655119, 0x91ff61ee}, {0x4c30c782, 0x4fd5522a, 0xfd8d17f1, 0xa3a6f430, 0x37bf9b7b, 0x72928155, 0x66037689, 0x4c8e67bc}}, {{0x35a5ce87, 0x1b25e22e, 0x2313705b, 0x9e3e6eb6, 0x8675e450, 0x33d9cdc4, 0x569c1b3e, 0xd9027fce}, {0x4f74f503, 0xecbc164d, 0x48ce7250, 0x32b9fb72, 0x8b726b18, 0xc0872542, 0xcb8d6a0b, 0xfecc8ed3}}}, {{{0x1a907f78, 0x04356cb2, 0x03360ad2, 0xba867ae8, 0xa1d5266f, 0xb5896fcf, 0x7013d8a3, 0x587b138f}, {0x30de9fe0, 0xacde6ad3, 0xdb1dcd3d, 0x765f2eac, 0x7f665d4e, 0xedc431a0, 0xd9057e43, 0x1bd63b89}}, {{0x16e913c4, 0xdc0a393e, 0xa9780dac, 0xa0e35293, 0x99e4eb2f, 0x80654405, 0x9a51d4b9, 0x890d2fa3}, {0x7a415a23, 0x7252917f, 0xb05a73ac, 0xe8a7f092, 0x9e68afd0, 0xfe5b63d2, 0x68ecfa20, 0xe3a9f4e0}}, {{0x3a77ca45, 0x282422b7, 0x613276da, 0x5bc45097, 0x95ea8ee4, 0x4a7a7633, 0xc9bb3324, 0xe396b7b4}, {0xf37c26a1, 0x8009faaa, 0x0779b7c1, 0x6ef10242, 0xcd5a86eb, 0x2dd2897e, 0x2b5f0b01, 0x0b79178d}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem right = {{{{0x848cdb73, 0x6399829e, 0xcaa20cc0, 0x1b02bff6, 0x2b477bd2, 0xf9d48534, 0xff7929a0, 0xd4745161}, {0xe323d956, 0xf8a05a85, 0xe02d5e1e, 0xfd533966, 0xe7d31209, 0xc7786143, 0x91b441f6, 0x7409d67d}}, {{0xc763c01c, 0x8d45cdc1, 0xe46054e2, 0xc6216337, 0x97589d24, 0xe57d5f07, 0xeec3f4b6, 0xfe2a593f}, {0x96748337, 0x31fbd2e4, 0x72e72c33, 0x96fe633a, 0x4f48fed2, 0xf6a92484, 0x5e7de24a, 0x8a963657}}, {{0x48a24137, 0xc529544f, 0xe83111bc, 0xbd151156, 0x6b0c7ee2, 0x1bc18974, 0x01193d6b, 0x6b716d4d}, {0x90c2469b, 0xb1ae7b57, 0x22ce6905, 0x58c5a086, 0xc750dfa2, 0x28ea9d9d, 0x6134f34f, 0x68cf7885}}}, {{{0x771f4d50, 0x113c642f, 0x983d5b97, 0xd8fed4c2, 0x166e53b0, 0x4797d81c, 0x9955788c, 0xbd7c6c23}, {0xd9d2246a, 0x092e1780, 0xd8a1ac25, 0xc23607e5, 0x8c58b02e, 0x2c543c7e, 0x4c082083, 0xc4577f4d}}, {{0xb433c5de, 0x6ab7893e, 0x5ff5e970, 0x24de35b6, 0x65b8022c, 0x89c649d3, 0x7629ec0b, 0x6046bfbd}, {0xcdab3158, 0xefd0e691, 0xeb7ca8b3, 0xbbe4015c, 0xcb5d6828, 0xd313d3ec, 0x0b0125d2, 0xac823c7f}}, {{0x3e500486, 0xd17db7a2, 0x8d174e88, 0x8504ae57, 0x1d09fdcb, 0xeda97288, 0xd8a573c9, 0x32233b3f}, {0x41145b9e, 0x4f61f713, 0xd1caf67d, 0x3299a2ff, 0x3586b78d, 0x6b31995f, 0xe51708e4, 0x9eab4090}}}}; Fq12Elem actual = {0}; Fq12Mul(&actual, &left, &right); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Inv TEST(TinyFq12Test, Fq12InvWorks) { Fq12Elem expected = {{{{0xcf7ba426, 0x4bb2c4c3, 0xfb50fa73, 0xb70c280d, 0xb5cf02c7, 0xb047bc29, 0x7cd8b4d1, 0xc238e14d}, {0xd1bc45de, 0xc113277d, 0x5189b836, 0x49694d5b, 0xc4084edb, 0xc837f717, 0xf65566eb, 0x519dad22}}, {{0x62b12d6e, 0xc2a49558, 0x0f36f3b8, 0x2274fc44, 0xd7ef63a2, 0x7a0f59da, 0xc4fa06c3, 0x812be980}, {0xc887fc84, 0xbeb1803c, 0x5ec3d49f, 0x7c32ae46, 0x97fb66b2, 0x470acb13, 0x2e9d2992, 0x88dd93d5}}, {{0x47087924, 0x143c1bba, 0x4fe23ddb, 0x6be4e322, 0x3cabd640, 0xdf2f66c9, 0x2d309380, 0xa244260f}, {0xf899db8a, 0xb5a83982, 0x264e1961, 0xe8a8ce8c, 0xe94ceacf, 0xd18bd271, 0x67f10894, 0xc82e0f88}}}, {{{0x61170257, 0x9740a14e, 0xdd90ec1f, 0xfc1a7d8b, 0x2a37d62c, 0xa6577bc2, 0xe610b5d6, 0xe0b70389}, {0x8192b447, 0x2fd37cbc, 0xc3f80c5b, 0x618f95a1, 0x21e22c0c, 0xf35bd82b, 0xbf635e7d, 0x990ac1f2}}, {{0x790d6584, 0xf40c0f6e, 0x83ca3d0f, 0x96f7c28d, 0x8a2662fa, 0xc83bfe45, 0x8be01843, 0x87a00b86}, {0x6020320a, 0x73199db4, 0x4d5dd850, 0x14cf247d, 0x34fb1d44, 0x8ababc0d, 0x7c849de5, 0x81226e85}}, {{0x6453b966, 0xbbd595ea, 0x704c45e2, 0x5d4cd2a1, 0x8ee6cc5e, 0x336a21d8, 0x87955196, 0xc9e0915a}, {0x83330d6a, 0x200dbac0, 0x6b9e8ee8, 0xe6a33cf8, 0x4dc48908, 0xd0a02fdb, 0x0f715987, 0x5f4b9d5b}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem actual = {0}; Fq12Inv(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Neg TEST(TinyFq12Test, Fq12NegWorks) { Fq12Elem expected = {{{{0x8c035971, 0xaf40febd, 0x3d89f632, 0x24887d6e, 0x3ecb5147, 0xff6580f2, 0x0023a5bd, 0xa19bcedb}, {0x61afe694, 0xba8b7e8e, 0x07d2460a, 0xd758834b, 0xb9944e4d, 0x2b2cfe7e, 0xe1ddaf4c, 0x755ba40a}}, {{0xff363b04, 0xf3770d54, 0xfb887eb6, 0x97208d71, 0x913888b6, 0xbe3b78dc, 0x504e9cec, 0x1328c6a8}, {0x80a4bcc9, 0xdc414b24, 0x81e12ae2, 0xddece243, 0x9e717f72, 0x2eae9d50, 0xe0b74a59, 0x6c2aa832}}, {{0xe3749624, 0x90f1e179, 0xe064c5e0, 0xa23c1333, 0x80199e94, 0x0df7593b, 0x5e70bcc6, 0xa7d12130}, {0x2795eeb3, 0x2242ac58, 0xa5ea27c6, 0x9521d69a, 0xc7850525, 0x7e332c4c, 0x8614e36d, 0xe7f0249e}}}, {{{0x5d2baf76, 0xda3c8c87, 0xd629e68e, 0x5f5bcff7, 0x8bc99594, 0x053eaed0, 0x9cc158f1, 0xd400823f}, {0xfe3bbd78, 0xe93cc691, 0x003899c3, 0x63371f3e, 0x7ff0eb49, 0x1752449a, 0x6d89adab, 0xc2ac64db}}, {{0xdd619055, 0x6e0c70ca, 0x8852e58e, 0xe7350261, 0x45a585a9, 0x3d0f971c, 0x20453822, 0xa71bc6c3}, {0x1aeb696d, 0x7deb08f4, 0xd4ca7881, 0x36531fe8, 0x42bb2179, 0x55e25789, 0x420d8238, 0x1c483361}}, {{0xfc43d59b, 0x4a1df76a, 0xeed743a2, 0x21c9e9b2, 0x684aa678, 0xfde77a80, 0x4379e6d4, 0x985d02d4}, {0xb9bbd2d7, 0xab67c387, 0x7ef6d8be, 0xfc039a6c, 0x37961f18, 0x31aac6a4, 0x3b2b7fc6, 0x41bae421}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem actual = {0}; Fq12Neg(&actual, &left); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Set TEST(TinyFq12Test, Fq12SetWorks) { Fq12Elem result = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem expected = {{{{0x00000010, 0}, {0}}}}; uint32_t val = 0x10; Fq12Set(&result, val); EXPECT_EQ(expected, result); } //////////////////////////////////////////////////////////////////////// // Fq12Exp TEST(TinyFq12Test, Fq12ExpWorks) { Fq12Elem expected = {{{{0x07770c93, 0x5820d5a9, 0x65189432, 0x5f5d67ff, 0xe257644a, 0x41318fa0, 0x6ab6be96, 0xf104adf8}, {0x6d5cae3a, 0x2e43c14b, 0xede9dbfe, 0x6743d276, 0x35d13a61, 0xf25d3672, 0x6a36930c, 0x9bdbed9d}}, {{0x12fc551f, 0x9ff0f349, 0x4131b828, 0x50c353ed, 0x785d7e8b, 0xbb894c96, 0xee86c2d1, 0x8af21330}, {0x45a7337a, 0xb0f0d8c5, 0xacfb0dbd, 0x1f775366, 0x12303719, 0x6f7208bd, 0x68c1bf17, 0x14b60ae7}}, {{0xcdf00f9c, 0xbd6529d8, 0x693b8a51, 0xcb9eb968, 0x46c25f48, 0x39cbf307, 0xd7283cd4, 0x8cbb7dd9}, {0xb18b24c2, 0x5a98714f, 0x0782ea19, 0x8af18c94, 0x22373570, 0xe24e7fef, 0x0510369a, 0xc5399438}}}, {{{0x141a7578, 0x05e94e05, 0x08ec385f, 0x3a5ae1ef, 0xccd4f61a, 0x3291d9f6, 0xb7b07242, 0xb1742404}, {0xec5f69b1, 0x68fbad6b, 0x167e8ec8, 0x67c97e56, 0x1ac21584, 0x783e2b30, 0x8c2dd9dd, 0xd4ed7488}}, {{0xb591926f, 0x97f68a1f, 0xd3bccfb8, 0x9a58152b, 0x9e12cf14, 0x0a82dfd6, 0x8c246e88, 0x94bcbc8a}, {0xa95962fe, 0x342b7e99, 0xddc1c0d9, 0x15a4e0f8, 0x64475d29, 0xbce1bd39, 0xa79dd2ee, 0xee505176}}, {{0xdb49f8cf, 0x10cdb302, 0xf5c48053, 0x83ce1f18, 0x988d4d5c, 0xd305fb4e, 0xbb11f2bb, 0x2f391894}, {0x084c02ad, 0x26eae084, 0x4d81e78d, 0x9750454d, 0xdb062196, 0xae6ad23e, 0x18588c31, 0xb3d78420}}}}; Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; VeryLargeInt exponent = {0x76abb18a, 0x92c0f7b9, 0x2c1a37e0, 0x7fdf6ca1, 0xe3401760, 0x66eb7d52, 0x918d50a7, 0x12a65bd6}; Fq12Elem actual = {0}; Fq12Exp(&actual, &left, &exponent); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12MultiExp TEST(TinyFq12Test, Fq12MultiExpWorks) { Fq12Elem expected = {{{{0x9b800ac0, 0x1fb360b8, 0x9af601c4, 0x4931f447, 0x31152f7c, 0x7f6b2489, 0x2fbeed91, 0xcc7a6ac0}, {0xb76c0d77, 0x5b09b4be, 0x4a8fc1d4, 0x2e5222d1, 0x6b6e41e6, 0x9ea53fff, 0x6daabae4, 0x591274a2}}, {{0xb669c611, 0xc8b0430b, 0xa7c054c3, 0x360bd4bc, 0xf09ef81c, 0x4d5bb8b1, 0x9333c78f, 0x32ff73b8}, {0x90ec74e4, 0xe1e77b28, 0xb453b94a, 0xf7bf242c, 0xdbee7487, 0x29b8c962, 0x31bcb2b5, 0x06737ced}}, {{0x26f4def9, 0xc706336d, 0x18aae9bf, 0x9b568de1, 0x4e0fa721, 0x10695d37, 0x44a446e4, 0x1f90fc31}, {0xec9525dc, 0x4f63a5d6, 0x07e9f19c, 0x982ac0b8, 0x818c07fc, 0x2603a2c4, 0x44e6a144, 0xb8a617a5}}}, {{{0x34f08dcb, 0x0afd33cc, 0x38921139, 0x10c707ef, 0x1bcd1d79, 0x1cee939a, 0x08831471, 0x2318f2b4}, {0x8e4f9261, 0x37304a70, 0xb24df55d, 0xd93a8a20, 0x32ff13b2, 0x342ce4a7, 0x25185cd0, 0xd974dca3}}, {{0x0a83a8aa, 0xf2e71e4e, 0x0e0af78b, 0x85363dfa, 0xf825e945, 0x01d733f5, 0xf54d7f42, 0x3c77fa71}, {0xb5a7931b, 0x25c5c577, 0x6d21b52e, 0xbc951e9b, 0x51dd45b9, 0x743e886f, 0x6bc839d4, 0xd7deccd5}}, {{0x947af194, 0xd0239f95, 0x1dde9421, 0x59369d3e, 0xd9863881, 0xb9c24b75, 0xcbdb4021, 0x4c940810}, {0x96070307, 0x4f68fbf2, 0x5a719a10, 0x73b7cc22, 0x4ef192e7, 0xbb5b635e, 0xdeb5746b, 0x89b5a530}}}}; Fq12Elem pairing_out = {{{{0x50ab7bc6, 0xd28d33ca, 0xa7de4ce1, 0x162996ed, 0xad5ee231, 0x4fc0a501, 0x468be932, 0xba101ff6}, {0x14d36207, 0x34c44c84, 0xdfa22b9e, 0x1f4d1fc0, 0xcb0454f2, 0xc4077c42, 0xebde30b6, 0x15eb79f4}}, {{0xf91d7519, 0xc456caad, 0xb908d0d3, 0x31b0be8c, 0x1c0def81, 0x80e14649, 0x4657b6e7, 0xf18b84d1}, {0xec73b557, 0xf8acbc05, 0x2e5f0a7e, 0xf485e0eb, 0x6fd516b6, 0xb7190100, 0xc1fa4e50, 0x3fee7c43}}, {{0xb3ebe0e5, 0xc572866a, 0xa10be392, 0x2d6f653d, 0x138bb1b6, 0x87cf70ba, 0xbbef8650, 0xe3b31829}, {0x4ba31303, 0x8d1afe6e, 0xe7138780, 0x36a08173, 0xcdc3182a, 0x1ecb0486, 0xd5a961a5, 0xda0e5787}}}, {{{0x0b13b454, 0xa62f5fbf, 0xa4bed641, 0xd3632805, 0xe8010941, 0x72cebb51, 0x8aaa0095, 0x669e804d}, {0xe49b7149, 0x8fc69d31, 0x956d88ab, 0x265c926b, 0x3bb2f1d4, 0xbfc206ea, 0x6f29d6da, 0x5b5065dc}}, {{0x0ff0848e, 0x1f3fdf5c, 0xb3533098, 0x1a434003, 0xc80d2a60, 0x4ac6aa4a, 0xc99fbca8, 0xe0ce978f}, {0x3357d172, 0xf5f8a018, 0x5908b3da, 0xe540395c, 0xb654a226, 0x89cef58e, 0x47786d9f, 0x5a5d41d2}}, {{0x788a3989, 0x49a5f719, 0x5a0042e3, 0x92f94303, 0x1bd0e6c8, 0x81c5ac15, 0xe8a05ec8, 0xbbba6ced}, {0x6d17dc8e, 0xaf351b75, 0xba6e2c36, 0x2a04ea26, 0x421e1737, 0x16fd0bfe, 0x4bb33376, 0x32aebf4d}}}}; Fq12Elem pairing_inv = {{{{0x50ab7bc6, 0xd28d33ca, 0xa7de4ce1, 0x162996ed, 0xad5ee231, 0x4fc0a501, 0x468be932, 0xba101ff6}, {0x14d36207, 0x34c44c84, 0xdfa22b9e, 0x1f4d1fc0, 0xcb0454f2, 0xc4077c42, 0xebde30b6, 0x15eb79f4}}, {{0xf91d7519, 0xc456caad, 0xb908d0d3, 0x31b0be8c, 0x1c0def81, 0x80e14649, 0x4657b6e7, 0xf18b84d1}, {0xec73b557, 0xf8acbc05, 0x2e5f0a7e, 0xf485e0eb, 0x6fd516b6, 0xb7190100, 0xc1fa4e50, 0x3fee7c43}}, {{0xb3ebe0e5, 0xc572866a, 0xa10be392, 0x2d6f653d, 0x138bb1b6, 0x87cf70ba, 0xbbef8650, 0xe3b31829}, {0x4ba31303, 0x8d1afe6e, 0xe7138780, 0x36a08173, 0xcdc3182a, 0x1ecb0486, 0xd5a961a5, 0xda0e5787}}}, {{{0xa3bf7bbf, 0x2cf9ce1c, 0x6dd93441, 0x39793df5, 0x06709b5d, 0xd417370d, 0x7552f037, 0x99617fb2}, {0xca37beca, 0x436290a9, 0x7d2a81d7, 0xe67fd38f, 0xb2beb2ca, 0x8723eb74, 0x90d319f2, 0xa4af9a23}}, {{0x9ee2ab85, 0xb3e94e7f, 0x5f44d9ea, 0xf29925f7, 0x26647a3e, 0xfc1f4814, 0x365d3424, 0x1f316870}, {0x7b7b5ea1, 0xdd308dc3, 0xb98f56a7, 0x279c2c9e, 0x381d0278, 0xbd16fcd0, 0xb884832d, 0xa5a2be2d}}, {{0x3648f68a, 0x898336c2, 0xb897c79f, 0x79e322f7, 0xd2a0bdd6, 0xc5204649, 0x175c9204, 0x44459312}, {0x41bb5385, 0x23f41266, 0x5829de4c, 0xe2d77bd4, 0xac538d67, 0x2fe8e660, 0xb449bd57, 0xcd5140b2}}}}; VeryLargeInt exponent = {0x76abb18a, 0x92c0f7b9, 0x2c1a37e0, 0x7fdf6ca1, 0xe3401760, 0x66eb7d52, 0x918d50a7, 0x12a65bd6}; Fq12Elem b1 = pairing_inv; Fq12Elem b2 = pairing_out; Fq12Elem b3 = pairing_out; VeryLargeInt e1 = exponent; VeryLargeInt e2 = {0}; VeryLargeInt e3 = exponent; // pairing_out^exp * pairing_out^(-exp) * pairing_out^0 * pairing_out^exp == // pairing_out^exp Fq12Elem actual = {0}; Fq12MultiExp(&actual, &pairing_out, &exponent, &b1, &e1, &b2, &e2, &b3, &e3); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12Eq TEST(TinyFq12Test, Fq12EqPasses) { Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem left2 = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; EXPECT_TRUE(Fq12Eq(&left, &left2)); } TEST(TinyFq12Test, Fq12EqFails) { Fq12Elem left = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem right = {{{{0x848cdb73, 0x6399829e, 0xcaa20cc0, 0x1b02bff6, 0x2b477bd2, 0xf9d48534, 0xff7929a0, 0xd4745161}, {0xe323d956, 0xf8a05a85, 0xe02d5e1e, 0xfd533966, 0xe7d31209, 0xc7786143, 0x91b441f6, 0x7409d67d}}, {{0xc763c01c, 0x8d45cdc1, 0xe46054e2, 0xc6216337, 0x97589d24, 0xe57d5f07, 0xeec3f4b6, 0xfe2a593f}, {0x96748337, 0x31fbd2e4, 0x72e72c33, 0x96fe633a, 0x4f48fed2, 0xf6a92484, 0x5e7de24a, 0x8a963657}}, {{0x48a24137, 0xc529544f, 0xe83111bc, 0xbd151156, 0x6b0c7ee2, 0x1bc18974, 0x01193d6b, 0x6b716d4d}, {0x90c2469b, 0xb1ae7b57, 0x22ce6905, 0x58c5a086, 0xc750dfa2, 0x28ea9d9d, 0x6134f34f, 0x68cf7885}}}, {{{0x771f4d50, 0x113c642f, 0x983d5b97, 0xd8fed4c2, 0x166e53b0, 0x4797d81c, 0x9955788c, 0xbd7c6c23}, {0xd9d2246a, 0x092e1780, 0xd8a1ac25, 0xc23607e5, 0x8c58b02e, 0x2c543c7e, 0x4c082083, 0xc4577f4d}}, {{0xb433c5de, 0x6ab7893e, 0x5ff5e970, 0x24de35b6, 0x65b8022c, 0x89c649d3, 0x7629ec0b, 0x6046bfbd}, {0xcdab3158, 0xefd0e691, 0xeb7ca8b3, 0xbbe4015c, 0xcb5d6828, 0xd313d3ec, 0x0b0125d2, 0xac823c7f}}, {{0x3e500486, 0xd17db7a2, 0x8d174e88, 0x8504ae57, 0x1d09fdcb, 0xeda97288, 0xd8a573c9, 0x32233b3f}, {0x41145b9e, 0x4f61f713, 0xd1caf67d, 0x3299a2ff, 0x3586b78d, 0x6b31995f, 0xe51708e4, 0x9eab4090}}}}; EXPECT_FALSE(Fq12Eq(&left, &right)); } //////////////////////////////////////////////////////////////////////// // Fq12Conj TEST(TinyFq12Test, Fq12ConjWorks) { Fq12Elem expected = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x5d2baf76, 0xda3c8c87, 0xd629e68e, 0x5f5bcff7, 0x8bc99594, 0x053eaed0, 0x9cc158f1, 0xd400823f}, {0xfe3bbd78, 0xe93cc691, 0x003899c3, 0x63371f3e, 0x7ff0eb49, 0x1752449a, 0x6d89adab, 0xc2ac64db}}, {{0xdd619055, 0x6e0c70ca, 0x8852e58e, 0xe7350261, 0x45a585a9, 0x3d0f971c, 0x20453822, 0xa71bc6c3}, {0x1aeb696d, 0x7deb08f4, 0xd4ca7881, 0x36531fe8, 0x42bb2179, 0x55e25789, 0x420d8238, 0x1c483361}}, {{0xfc43d59b, 0x4a1df76a, 0xeed743a2, 0x21c9e9b2, 0x684aa678, 0xfde77a80, 0x4379e6d4, 0x985d02d4}, {0xb9bbd2d7, 0xab67c387, 0x7ef6d8be, 0xfc039a6c, 0x37961f18, 0x31aac6a4, 0x3b2b7fc6, 0x41bae421}}}}; Fq12Elem input = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem actual = {0}; Fq12Conj(&actual, &input); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12ExpCyc TEST(TinyFq12Test, Fq12ExpCycWorks) { Fq12Elem expected = {{{{0x44415742, 0xce586503, 0xe5cc514f, 0x731d97a3, 0xe8c98357, 0xb1de361d, 0x15cf9bfc, 0x4ca54124}, {0x7decae5a, 0x572ae946, 0x4244f518, 0x1490b9e4, 0xbbbafdb2, 0xb2d13f3f, 0xae1de024, 0xe224dc2f}}, {{0x876377f0, 0x2c75d3ab, 0x5aa65a1d, 0x42ff41fa, 0x2729ff86, 0x8f76d40f, 0x2c224666, 0xce3d5926}, {0x4f0b47eb, 0xa45887d9, 0xf4407be2, 0xaaedbf4a, 0x9f8a426e, 0x809a601a, 0xea000edd, 0x4fe97056}}, {{0x7eb3ea97, 0xd6769b11, 0x2f2bed07, 0x6fbb5801, 0x1e67136e, 0x2fd1e9a3, 0x242559de, 0x5a018155}, {0xb66ad800, 0x51924848, 0xdecddaa8, 0x3eed0649, 0xcf7f3edb, 0x17dcaa6e, 0x27cd41c7, 0x055a6039}}}, {{{0x09d45f4f, 0x3d360f00, 0x7561c4fb, 0x70500d0f, 0x20851a64, 0x5c5ed2a6, 0x6118fe9e, 0xfa05dc75}, {0x57b872d1, 0x9a19e54d, 0x3395e069, 0x29d98c64, 0xcdbdda55, 0x001f07e7, 0x8aeaca7f, 0x747c1dc8}}, {{0x0c0cb22d, 0x75ca59be, 0x202684e4, 0xec1b56c5, 0x46434c3f, 0x55f52f7a, 0xfcb5686b, 0x0a1172be}, {0xf0b043af, 0xbb2ae039, 0xccbdac3c, 0x8f42a6f2, 0x06c264ab, 0xa47599b7, 0xc6a8c454, 0xa5b257e3}}, {{0x8700f8b7, 0x4090b69d, 0x20e35539, 0xfd30e911, 0xa08ecbf5, 0xb038eb7b, 0x6ea872c3, 0xdfa0f669}, {0x5600be7b, 0x43ec3905, 0xc830ae6e, 0xd9780bec, 0xe7d288c3, 0xcff72a6e, 0x059b9c31, 0x66ebb803}}}}; Fq12Elem input = {{{{0x4200e30a, 0xebf627b9, 0x607ebce6, 0x7848a894, 0xe1b736d1, 0x4c9dd307, 0x9e1301e3, 0x07256eb7}, {0xe17a0b54, 0x0e02f2d5, 0x3df772e0, 0x9155aaa2, 0x3c5ffcc6, 0x8427940b, 0x362f51ee, 0x331e0c73}}, {{0x954eecdb, 0x970bc820, 0x92d1776a, 0x02f81e51, 0x8a7a9216, 0x6172111f, 0x9bd29665, 0x9612d47d}, {0x8fceb2c7, 0xb3f7eced, 0xa3d0a21e, 0xd66c6583, 0xf273f385, 0x827df9e6, 0x503de81c, 0x5b2cae32}}, {{0xf08207ed, 0x7ab76686, 0xb681b701, 0x9d19d066, 0x81956e08, 0x2ca17f37, 0x65d1d24e, 0x0cff7cb8}, {0xf9cd6e9e, 0x4821363b, 0xb0bc2b8c, 0xa380ecbb, 0x7b04aea0, 0x396f0948, 0x93619efe, 0x42aa1fd4}}}, {{{0x805b8aa4, 0x23ab6f9a, 0x937ea209, 0x9dba1ab2, 0x426d02b7, 0x36782ff4, 0xe371d373, 0x66873347}, {0x51d27dea, 0xd40cd434, 0xd5627a4d, 0xbcc747de, 0xa54b31ec, 0x3e2c2fa4, 0x4f07b689, 0xb33b79bc}}, {{0xfeea300c, 0x26ab30d9, 0x92c098e9, 0x192c191b, 0xeefd498c, 0x3cd4e4ac, 0xe9a3f142, 0x00bdca46}, {0xeb1edad0, 0xd4c2439e, 0x51025e46, 0x006cfb7c, 0x04b6efda, 0x159f7c19, 0xa1085a5e, 0x459833d5}}, {{0xeb08632d, 0x3c4ecf58, 0x02624178, 0xf65dbcf5, 0xeb320af5, 0xce34c3db, 0x799ea805, 0x1f944aa2}, {0x6f488ba6, 0x07f9f8dc, 0x690e6d4b, 0xa45b11be, 0x8d39f017, 0x96619fec, 0x6100af71, 0x16201c36}}}}; VeryLargeInt pairing_t = {0x30b0a801, 0x6882f5c0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; Fq12Elem actual = {0}; Fq12ExpCyc(&actual, &input, &pairing_t); EXPECT_EQ(expected, actual); } //////////////////////////////////////////////////////////////////////// // Fq12SqCyc TEST(TinyFq12Test, Fq12SqCycWorks) { const Fq12Elem a = {{{{0x4200e30a, 0xebf627b9, 0x607ebce6, 0x7848a894, 0xe1b736d1, 0x4c9dd307, 0x9e1301e3, 0x07256eb7}, {0xe17a0b54, 0x0e02f2d5, 0x3df772e0, 0x9155aaa2, 0x3c5ffcc6, 0x8427940b, 0x362f51ee, 0x331e0c73}}, {{0x954eecdb, 0x970bc820, 0x92d1776a, 0x02f81e51, 0x8a7a9216, 0x6172111f, 0x9bd29665, 0x9612d47d}, {0x8fceb2c7, 0xb3f7eced, 0xa3d0a21e, 0xd66c6583, 0xf273f385, 0x827df9e6, 0x503de81c, 0x5b2cae32}}, {{0xf08207ed, 0x7ab76686, 0xb681b701, 0x9d19d066, 0x81956e08, 0x2ca17f37, 0x65d1d24e, 0x0cff7cb8}, {0xf9cd6e9e, 0x4821363b, 0xb0bc2b8c, 0xa380ecbb, 0x7b04aea0, 0x396f0948, 0x93619efe, 0x42aa1fd4}}}, {{{0x805b8aa4, 0x23ab6f9a, 0x937ea209, 0x9dba1ab2, 0x426d02b7, 0x36782ff4, 0xe371d373, 0x66873347}, {0x51d27dea, 0xd40cd434, 0xd5627a4d, 0xbcc747de, 0xa54b31ec, 0x3e2c2fa4, 0x4f07b689, 0xb33b79bc}}, {{0xfeea300c, 0x26ab30d9, 0x92c098e9, 0x192c191b, 0xeefd498c, 0x3cd4e4ac, 0xe9a3f142, 0x00bdca46}, {0xeb1edad0, 0xd4c2439e, 0x51025e46, 0x006cfb7c, 0x04b6efda, 0x159f7c19, 0xa1085a5e, 0x459833d5}}, {{0xeb08632d, 0x3c4ecf58, 0x02624178, 0xf65dbcf5, 0xeb320af5, 0xce34c3db, 0x799ea805, 0x1f944aa2}, {0x6f488ba6, 0x07f9f8dc, 0x690e6d4b, 0xa45b11be, 0x8d39f017, 0x96619fec, 0x6100af71, 0x16201c36}}}}; const Fq12Elem expected = { {{{0x526a44b5, 0x9ad9e0d5, 0x7fc8d87d, 0xdac7f569, 0xb7160629, 0xc5073804, 0x217aac0c, 0x71b7efa7}, {0xd0accd40, 0x66aed48f, 0x3e8cb003, 0x54d56ad9, 0x5f6d6996, 0x0be42117, 0xa36948ed, 0xbb155b11}}, {{0x806eec23, 0xf4e66785, 0xaffdc175, 0xa19e8e95, 0xa11edc9d, 0xfad5f701, 0x4bf831bc, 0xe743b59e}, {0xfc57a415, 0xb843987c, 0x3aabe4e3, 0xb23ed43d, 0xc418a1cd, 0xc46cc003, 0xb646c6b0, 0x32af93c9}}, {{0x20c76439, 0xc9915b9f, 0x34fae4ad, 0x952c702a, 0xf2edbbd9, 0x06aa03db, 0x10219f83, 0x905d0b4c}, {0xab64286e, 0xb368606d, 0xa469d731, 0xbc1f7604, 0xeae89f06, 0xd6d6b335, 0x68da2258, 0x4ab0021e}}}, {{{0xa69a08d7, 0xbac72f6e, 0xaf9c76c7, 0x67d54f71, 0x41aea080, 0x36129b92, 0xd25549e1, 0xa261f5ef}, {0xd663885e, 0xd0de96b5, 0x6631c5ab, 0x1826eea2, 0xab116580, 0xc41e9bd7, 0x935a4539, 0x1283ccf4}}, {{0xc279b3a5, 0x750dcbe7, 0x8f96e4ba, 0xd3321942, 0xf837f073, 0x11ed32b8, 0x26691990, 0x06c077da}, {0x4d690c41, 0x47d447a7, 0xb0ecd6ca, 0xbab6e94b, 0xb1984cb4, 0xb104eb7f, 0xd0b8e924, 0xe8c70bef}}, {{0x1c750b7c, 0x9923d34c, 0xc88a0dda, 0x2e14c6ca, 0x6748bad3, 0x50d05e2b, 0x14f32504, 0x2dc7a9d3}, {0xa1c4328d, 0x9e8f16d8, 0xd31d739a, 0x0c9da028, 0x613f8c91, 0x75fbf7f3, 0x78575301, 0x496c9a7b}}}}; Fq12Elem res; Fq12SqCyc(&res, &a); EXPECT_EQ(expected, res); } //////////////////////////////////////////////////////////////////////// // Fq12MulSpecial TEST(TinyFq12Test, Fq12MulSpecialWorks) { const Fq12Elem left = {{{{0xbee28a1d, 0x57d6402c, 0x61cd0458, 0x194e2452, 0x1c223de9, 0x6546ced9, 0xdcd0878f, 0xc55048e3}, {0x6a8d5fe2, 0xfcf17083, 0xb608693b, 0x981bd9fe, 0x54a9e8fa, 0x0e8250f4, 0x93430f47, 0xf862d9af}}, {{0x57975e42, 0xf57416a0, 0x08a35031, 0x9d28f11c, 0xa9467df1, 0x58159cfa, 0x48cb43f1, 0x7f6f1e63}, {0xb6199d76, 0xf0ee74eb, 0xc2413051, 0x5ee7af00, 0xed646e81, 0xa34adbc8, 0xb30cb947, 0xc256758a}}, {{0xd2100f2c, 0x34bef28c, 0xe6ffd998, 0x3f8de361, 0x711229db, 0x143ccdbf, 0x4fad6107, 0x35365f92}, {0xea2fbf36, 0x14a160b2, 0x5051bd0f, 0x6f056434, 0x2d53ef9f, 0x00d84656, 0xc8535c97, 0x23aaa4e4}}}, {{{0xfa291b36, 0xdff94440, 0xc016a92d, 0xe44a0e69, 0xdb2d97f6, 0xb1747475, 0x1cbc7fc4, 0x0e94ef53}, {0x0ea6037c, 0x9a639210, 0xd84404c5, 0x4b8c16ef, 0xfc9e6161, 0x3914ae4c, 0xd1b76423, 0x63ef638b}}, {{0xfbe030a1, 0x2a114147, 0x6639fbac, 0x0349a4a5, 0x5c7d47de, 0x63888f75, 0x7224cc85, 0x4c1bfeb3}, {0xb214f453, 0x403afc2f, 0xa61d5e45, 0x4392c48a, 0xc4f5aec3, 0xce77b85a, 0xc8d59c7e, 0xd0060196}}, {{0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}}; const Fq12Elem right = {{{{0xd878f624, 0xb6e07457, 0x64c79fdf, 0x0b8cebe9, 0x97be762b, 0xbc4aea64, 0xf72d75cc, 0xdc8ed85d}, {0x65847e3a, 0x2a2ff0f3, 0x87af7204, 0xfb4cba91, 0x0df3d736, 0x77e1a4e0, 0x138efcca, 0xc427f6ab}}, {{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, 0x00000000}}}, {{{0x163784b5, 0x2a7d4fd5, 0x1f5a1a18, 0xe89cba68, 0xc233b435, 0xa20456c0, 0x6397ae08, 0x7b76d157}, {0xb68f8337, 0x079302c1, 0x99e4326a, 0xc14686de, 0x866e7108, 0x685e797e, 0x3a4b03e5, 0x9aab4042}}, {{0x2cd4fe4d, 0xb4660e9a, 0xf99f415d, 0x627f9703, 0x902301e4, 0xcf3c4224, 0xaca9779d, 0x917a2609}, {0x9da1e8ac, 0xadb15382, 0x6d31577a, 0xcfd95901, 0xf4fdf69b, 0x8ebf8ef3, 0xc15f4a65, 0x0d6458ec}}, {{0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}}}}; const Fq12Elem expected = { {{{0x9f8d4cd8, 0x00fcb121, 0xb1383622, 0xff83d7d7, 0xa4b229fb, 0xcece9321, 0x81ef1f73, 0x05137d4e}, {0x9f6177a7, 0x050a266e, 0x73bb8d3b, 0xc99e1d33, 0x678d1f52, 0xc63568f1, 0x1920273f, 0x11a25307}}, {{0xcf70c64d, 0x99892381, 0xf6f6a6de, 0xfec24fa5, 0x8d18873e, 0x4f621aad, 0x7d3599d0, 0x128407fe}, {0x33e6c086, 0xa85bf06c, 0x2edfd568, 0xc2426dbe, 0xdbbd397c, 0x2b6e80b2, 0x63dd5f45, 0x98bc904e}}, {{0xb56c9e77, 0x84063128, 0x830da180, 0xa3d9be01, 0x7ec1cfe7, 0x817c7cc1, 0x409da3aa, 0xb05dcc43}, {0x356380bf, 0x72eb335a, 0xb6f2b26c, 0x080613dc, 0x67720d78, 0x488a988f, 0xee0e1bff, 0x0758479e}}}, {{{0xa640a57d, 0xc171805c, 0xd1c81064, 0xef2644a8, 0xe28b6e89, 0xd031ff2f, 0xf734a21b, 0x0d8e465e}, {0x609de07b, 0x1d248226, 0x19fed7c8, 0x2b378e3d, 0xd55d1461, 0x719d0037, 0x6fe515b8, 0x34f03c08}}, {{0xdcdcb9d0, 0x814badfe, 0x01405a2a, 0x2e1a5295, 0x3d08cb46, 0xd0dc0d2b, 0x4ca64738, 0x2b2e5180}, {0x503385b0, 0x030d5f71, 0xd24ad48c, 0x4f246e0b, 0x9e904a36, 0x302748d6, 0x1c034d23, 0xf6aa74f6}}, {{0x05fc0305, 0xfb7ba8fd, 0x4a8425a1, 0xd69ff60a, 0x356d1941, 0x4559a790, 0xcf1088e9, 0x63784e99}, {0xa8a6d207, 0x6e6ed383, 0xf8a9804e, 0x0be13d11, 0xcef9010b, 0x90c8c91a, 0x0b1302ef, 0xe2ce5b67}}}}; Fq12Elem res; Fq12MulSpecial(&res, &left, &right); EXPECT_EQ(expected, res); } //////////////////////////////////////////////////////////////////////// // Fq12Cp TEST(TinyFq12Test, Fq12CpWorks) { Fq12Elem a = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Elem result = {0}; Fq12Cp(&result, &a); EXPECT_EQ(a, result); } //////////////////////////////////////////////////////////////////////// // Fq12Clear TEST(TinyFq12Test, Fq12ClearWorks) { Fq12Elem zero = {0}; Fq12Elem a = {{{{0x22cfd6a2, 0x23e82f1e, 0xd50e1450, 0xe853e88c, 0xafa65357, 0x4780716c, 0xffd94b0f, 0x5e643124}, {0x4d23497f, 0x189daf4d, 0x0ac5c478, 0x3583e2b0, 0x34dd5651, 0x1bb8f3e0, 0x1e1f4181, 0x8aa45bf5}}, {{0xaf9cf50f, 0xdfb22086, 0x170f8bcb, 0x75bbd889, 0x5d391be8, 0x88aa7982, 0xafae53e0, 0xecd73957}, {0x2e2e734a, 0xf6e7e2b7, 0x90b6df9f, 0x2eef83b7, 0x5000252c, 0x1837550e, 0x1f45a674, 0x93d557cd}}, {{0xcb5e99ef, 0x42374c61, 0x323344a2, 0x6aa052c7, 0x6e58060a, 0x38ee9923, 0xa18c3407, 0x582edecf}, {0x873d4160, 0xb0e68183, 0x6cade2bc, 0x77ba8f60, 0x26ec9f79, 0xc8b2c612, 0x79e80d5f, 0x180fdb61}}}, {{{0x51a7809d, 0xf8eca154, 0x3c6e23f3, 0xad809603, 0x62a80f0a, 0x41a7438e, 0x633b97dc, 0x2bff7dc0}, {0xb097729b, 0xe9ec6749, 0x125f70be, 0xa9a546bd, 0x6e80b955, 0x2f93adc4, 0x92734322, 0x3d539b24}}, {{0xd1719fbe, 0x651cbd10, 0x8a4524f4, 0x25a76399, 0xa8cc1ef5, 0x09d65b42, 0xdfb7b8ab, 0x58e4393c}, {0x93e7c6a6, 0x553e24e7, 0x3dcd9201, 0xd6894612, 0xabb68325, 0xf1039ad5, 0xbdef6e94, 0xe3b7cc9e}}, {{0xb28f5a78, 0x890b3670, 0x23c0c6e0, 0xeb127c48, 0x8626fe26, 0x48fe77de, 0xbc8309f8, 0x67a2fd2b}, {0xf5175d3c, 0x27c16a53, 0x93a131c4, 0x10d8cb8e, 0xb6db8586, 0x153b2bba, 0xc4d17107, 0xbe451bde}}}}; Fq12Clear(&a); EXPECT_EQ(zero, a); } } // namespace