|
|
@ -985,6 +985,75 @@ void testHashToFp2v7(const T& mapto) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void testEth2phase0() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const struct { |
|
|
|
|
|
|
|
const char *sec; |
|
|
|
|
|
|
|
const char *msg; |
|
|
|
|
|
|
|
const char *out; |
|
|
|
|
|
|
|
} tbl[] = { |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", |
|
|
|
|
|
|
|
"abababababababababababababababababababababababababababababababab", |
|
|
|
|
|
|
|
"ae82747ddeefe4fd64cf9cedb9b04ae3e8a43420cd255e3c7cd06a8d88b7c7f8638543719981c5d16fa3527c468c25f0026704a6951bde891360c7e8d12ddee0559004ccdbe6046b55bae1b257ee97f7cdb955773d7cf29adf3ccbb9975e4eb9", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", |
|
|
|
|
|
|
|
"abababababababababababababababababababababababababababababababab", |
|
|
|
|
|
|
|
"9674e2228034527f4c083206032b020310face156d4a4685e2fcaec2f6f3665aa635d90347b6ce124eb879266b1e801d185de36a0a289b85e9039662634f2eea1e02e670bc7ab849d006a70b2f93b84597558a05b879c8d445f387a5d5b653df", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", |
|
|
|
|
|
|
|
"5656565656565656565656565656565656565656565656565656565656565656", |
|
|
|
|
|
|
|
"a4efa926610b8bd1c8330c918b7a5e9bf374e53435ef8b7ec186abf62e1b1f65aeaaeb365677ac1d1172a1f5b44b4e6d022c252c58486c0a759fbdc7de15a756acc4d343064035667a594b4c2a6f0b0b421975977f297dba63ee2f63ffe47bb6", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", |
|
|
|
|
|
|
|
"5656565656565656565656565656565656565656565656565656565656565656", |
|
|
|
|
|
|
|
"af1390c3c47acdb37131a51216da683c509fce0e954328a59f93aebda7e4ff974ba208d9a4a2a2389f892a9d418d618418dd7f7a6bc7aa0da999a9d3a5b815bc085e14fd001f6a1948768a3f4afefc8b8240dda329f984cb345c6363272ba4fe", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", |
|
|
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000", |
|
|
|
|
|
|
|
"b6ed936746e01f8ecf281f020953fbf1f01debd5657c4a383940b020b26507f6076334f91e2366c96e9ab279fb5158090352ea1c5b0c9274504f4f0e7053af24802e51e4568d164fe986834f41e55c8e850ce1f98458c0cfc9ab380b55285a55", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"47b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138", |
|
|
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000", |
|
|
|
|
|
|
|
"b23c46be3a001c63ca711f87a005c200cc550b9429d5f4eb38d74322144f1b63926da3388979e5321012fb1a0526bcd100b5ef5fe72628ce4cd5e904aeaa3279527843fae5ca9ca675f4f51ed8f83bbf7155da9ecc9663100a885d5dc6df96d9", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216", |
|
|
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000", |
|
|
|
|
|
|
|
"948a7cb99f76d616c2c564ce9bf4a519f1bea6b0a624a02276443c245854219fabb8d4ce061d255af5330b078d5380681751aa7053da2c98bae898edc218c75f07e24d8802a17cd1f6833b71e58f5eb5b94208b4d0bb3848cecb075ea21be115", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", |
|
|
|
|
|
|
|
"abababababababababababababababababababababababababababababababab", |
|
|
|
|
|
|
|
"91347bccf740d859038fcdcaf233eeceb2a436bcaaee9b2aa3bfb70efe29dfb2677562ccbea1c8e061fb9971b0753c240622fab78489ce96768259fc01360346da5b9f579e5da0d941e4c6ba18a0e64906082375394f337fa1af2b7127b0d121", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", |
|
|
|
|
|
|
|
"5656565656565656565656565656565656565656565656565656565656565656", |
|
|
|
|
|
|
|
"882730e5d03f6b42c3abc26d3372625034e1d871b65a8a6b900a56dae22da98abbe1b68f85e49fe7652a55ec3d0591c20767677e33e5cbb1207315c41a9ac03be39c2e7668edc043d6cb1d9fd93033caa8a1c5b0e84bedaeb6c64972503a43eb", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
bn::setMapToMode(MCL_MAP_TO_MODE_HASH_TO_CURVE_07); |
|
|
|
|
|
|
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) { |
|
|
|
|
|
|
|
const Uint8Vec msg = fromHexStr(tbl[i].msg); |
|
|
|
|
|
|
|
const Uint8Vec out = fromHexStr(tbl[i].out); |
|
|
|
|
|
|
|
Fr r; |
|
|
|
|
|
|
|
r.setStr(tbl[i].sec, 16); |
|
|
|
|
|
|
|
G2 P; |
|
|
|
|
|
|
|
mcl::bn::hashAndMapToG2(P, msg.data(), msg.size()); |
|
|
|
|
|
|
|
P *= r; |
|
|
|
|
|
|
|
P.normalize(); |
|
|
|
|
|
|
|
uint8_t buf[256]; |
|
|
|
|
|
|
|
size_t n = P.serialize(buf, sizeof(buf)); |
|
|
|
|
|
|
|
CYBOZU_TEST_EQUAL_ARRAY(out.data(), buf, n); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(test) |
|
|
|
CYBOZU_TEST_AUTO(test) |
|
|
|
{ |
|
|
|
{ |
|
|
|
initPairing(mcl::BLS12_381); |
|
|
|
initPairing(mcl::BLS12_381); |
|
|
@ -1006,4 +1075,5 @@ CYBOZU_TEST_AUTO(test) |
|
|
|
ethMsgToG2testAll("../bls_sigs_ref/test-vectors/hash_g2/"); |
|
|
|
ethMsgToG2testAll("../bls_sigs_ref/test-vectors/hash_g2/"); |
|
|
|
testHashToFp2v6(mapto); |
|
|
|
testHashToFp2v6(mapto); |
|
|
|
testHashToFp2v7(mapto); |
|
|
|
testHashToFp2v7(mapto); |
|
|
|
|
|
|
|
testEth2phase0(); |
|
|
|
} |
|
|
|
} |
|
|
|