|
|
|
@ -893,6 +893,71 @@ void testHashToFp2v7(const T& mapto) |
|
|
|
|
mcl::fp::expand_message_xmd(md, msg, msgSize, dst, dstSize); |
|
|
|
|
CYBOZU_TEST_EQUAL(toHexStr(md, sizeof(md)), expect); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
const char *dst = "BLS12381G2_XMD:SHA-256_SSWU_RO_TESTGEN"; |
|
|
|
|
size_t dstSize = strlen(dst); |
|
|
|
|
const struct { |
|
|
|
|
const char *msg; |
|
|
|
|
Fp2Str x; |
|
|
|
|
Fp2Str y; |
|
|
|
|
} tbl[] = { |
|
|
|
|
// fd12ba0 : https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/poc/vectors/BLS12381G2_XMD:SHA-256_SSWU_RO_.json
|
|
|
|
|
{ |
|
|
|
|
"", // msg
|
|
|
|
|
{ // P.x
|
|
|
|
|
"0x0a650bd36ae7455cb3fe5d8bb1310594551456f5c6593aec9ee0c03d2f6cb693bd2c5e99d4e23cbaec767609314f51d3", |
|
|
|
|
"0x0fbdae26f9f9586a46d4b0b70390d09064ef2afe5c99348438a3c7d9756471e015cb534204c1b6824617a85024c772dc", |
|
|
|
|
}, |
|
|
|
|
{ // P.y
|
|
|
|
|
"0x0d8d49e7737d8f9fc5cef7c4b8817633103faf2613016cb86a1f3fc29968fe2413e232d9208d2d74a89bf7a48ac36f83", |
|
|
|
|
"0x02e5cf8f9b7348428cc9e66b9a9b36fe45ba0b0a146290c3a68d92895b1af0e1f2d9f889fb412670ae8478d8abd4c5aa", |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"abc", |
|
|
|
|
{ |
|
|
|
|
"0x1953ce6d4267939c7360756d9cca8eb34aac4633ef35369a7dc249445069888e7d1b3f9d2e75fbd468fbcbba7110ea02", |
|
|
|
|
"0x03578447618463deb106b60e609c6f7cc446dc6035f84a72801ba17c94cd800583b493b948eff0033f09086fdd7f6175", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"0x0882ab045b8fe4d7d557ebb59a63a35ac9f3d312581b509af0f8eaa2960cbc5e1e36bb969b6e22980b5cbdd0787fcf4e", |
|
|
|
|
"0x0184d26779ae9d4670aca9b267dbd4d3b30443ad05b8546d36a195686e1ccc3a59194aea05ed5bce7c3144a29ec047c4", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"abcdef0123456789", |
|
|
|
|
{ |
|
|
|
|
"0x17b461fc3b96a30c2408958cbfa5f5927b6063a8ad199d5ebf2d7cdeffa9c20c85487204804fab53f950b2f87db365aa", |
|
|
|
|
"0x195fad48982e186ce3c5c82133aefc9b26d55979b6f530992a8849d4263ec5d57f7a181553c8799bcc83da44847bdc8d", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"0x174a3473a3af2d0302b9065e895ca4adba4ece6ce0b41148ba597001abb152f852dd9a96fb45c9de0a43d944746f833e", |
|
|
|
|
"0x005cdf3d984e3391e7e969276fb4bc02323c5924a4449af167030d855acc2600cf3d4fab025432c6d868c79571a95bef", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
|
|
|
|
{ |
|
|
|
|
"0x0a162306f3b0f2bb326f0c4fb0e1fea020019c3af796dcd1d7264f50ddae94cacf3cade74603834d44b9ab3d5d0a6c98", |
|
|
|
|
"0x123b6bd9feeba26dd4ad00f8bfda2718c9700dc093ea5287d7711844644eb981848316d3f3f57d5d3a652c6cdc816aca", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"0x15c1d4f1a685bb63ee67ca1fd96155e3d091e852a684b78d085fd34f6091e5249ddddbdcf2e7ec82ce6c04c63647eeb7", |
|
|
|
|
"0x05483f3b96d9252dd4fc0868344dfaf3c9d145e3387db23fa8e449304fab6a7b6ec9c15f05c0a1ea66ff0efcc03e001a", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) { |
|
|
|
|
const char *msg = tbl[i].msg; |
|
|
|
|
size_t msgSize = strlen(msg); |
|
|
|
|
G2 P1, P2; |
|
|
|
|
set(P1.x, tbl[i].x); |
|
|
|
|
set(P1.y, tbl[i].y); |
|
|
|
|
P1.z = 1; |
|
|
|
|
mapto.map2curve_osswu2(P2, msg, msgSize, dst, dstSize); |
|
|
|
|
CYBOZU_TEST_EQUAL(P1, P2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(test) |
|
|
|
|