12std::ostream&
operator<<(std::ostream& st,
const std::variant<fc::alt_bn128_error, bytes>& err)
14 if( std::holds_alternative<fc::alt_bn128_error>(err) )
15 st << static_cast<int32_t>(std::get<fc::alt_bn128_error>(err));
17 st << fc::to_hex(std::get<bytes>(err));
34 using test_add = std::tuple<std::string, std::string, std::variant<fc::alt_bn128_error, bytes>>;
35 const std::vector<test_add> tests = {
38 "222480c9f95409bfa4ac6ae890b9c150bc88542b87b352e92950c340458b0c092976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8ae2",
39 "1bd20beca3d8d28e536d2b5bd3bf36d76af68af5e6c96ca6e5519ba9ff8f53322a53edf6b48bcf5cb1c0b4ad1d36dfce06a79dcd6526f1c386a14d8ce4649844",
40 to_bytes(
"16c7c4042e3a725ddbacf197c519c3dcad2bc87dfd9ac7e1e1631154ee0b7d9c19cd640dd28c9811ebaaa095a16b16190d08d6906c4f926fce581985fe35be0e")
45 "222480c9f95409bfa4ac6ae890b9c150bc88542b87b352e92950c340458b0c092976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8ae2",
46 "2a53edf6b48bcf5cb1c0b4ad1d36dfce06a79dcd6526f1c386a14d8ce46498441bd20beca3d8d28e536d2b5bd3bf36d76af68af5e6c96ca6e5519ba9ff8f5332",
47 alt_bn128_error::operand_not_in_curve
53 "222480c9f95409bfa4ac6ae890b9c150bc88542b87b352e92950c340458b0c092976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8ae2",
54 alt_bn128_error::input_len_error
60 "30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd472976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8ae2",
61 "1bd20beca3d8d28e536d2b5bd3bf36d76af68af5e6c96ca6e5519ba9ff8f53322a53edf6b48bcf5cb1c0b4ad1d36dfce06a79dcd6526f1c386a14d8ce4649844",
62 alt_bn128_error::operand_component_invalid
67 "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
68 "1bd20beca3d8d28e536d2b5bd3bf36d76af68af5e6c96ca6e5519ba9ff8f53322a53edf6b48bcf5cb1c0b4ad1d36dfce06a79dcd6526f1c386a14d8ce4649844",
69 to_bytes(
"1bd20beca3d8d28e536d2b5bd3bf36d76af68af5e6c96ca6e5519ba9ff8f53322a53edf6b48bcf5cb1c0b4ad1d36dfce06a79dcd6526f1c386a14d8ce4649844")
73 for(
const auto& test : tests) {
74 auto op1 =
to_bytes(std::get<0>(test));
75 auto op2 =
to_bytes(std::get<1>(test));
86 using test_mul = std::tuple<std::string, std::string, std::variant<fc::alt_bn128_error, bytes>>;
87 const std::vector<test_mul> tests = {
90 "007c43fcd125b2b13e2521e395a81727710a46b34fe279adbf1b94c72f7f91360db2f980370fb8962751c6ff064f4516a6a93d563388518bb77ab9a6b30755be",
91 "0312ed43559cf8ecbab5221256a56e567aac5035308e3f1d54954d8b97cd1c9b",
92 to_bytes(
"2d66cdeca5e1715896a5a924c50a149be87ddd2347b862150fbb0fd7d0b1833c11c76319ebefc5379f7aa6d85d40169a612597637242a4bbb39e5cd3b844becd")
97 "007c43fcd125b2b13e2521e395a81727710a46b34fe279adbf1b94c72f7f91360db2f980370fb8962751c6ff064f4516a6a93d563388518bb77ab9a6b30755be",
99 alt_bn128_error::invalid_scalar_size,
104 "0db2f980370fb8962751c6ff064f4516a6a93d563388518bb77ab9a6b30755be007c43fcd125b2b13e2521e395a81727710a46b34fe279adbf1b94c72f7f9136",
105 "0312ed43559cf8ecbab5221256a56e567aac5035308e3f1d54954d8b97cd1c9b",
106 alt_bn128_error::operand_not_in_curve,
111 "222480c9f95409bfa4ac6ae890b9c150bc88542b87b352e92950c340458b0c092976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8a",
112 "0312ed43559cf8ecbab5221256a56e567aac5035308e3f1d54954d8b97cd1c9b",
113 alt_bn128_error::input_len_error,
119 "2976efd698cf23b414ea622b3f720dd9080d679042482ff3668cb2e32cad8ae230644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47",
120 "0100010001000100010001000100010001000100010001000100010001000100",
121 alt_bn128_error::operand_component_invalid,
126 "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
127 "0312ed43559cf8ecbab5221256a56e567aac5035308e3f1d54954d8b97cd1c9b",
128 to_bytes(
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
133 for(
const auto& test : tests) {
135 auto scalar =
to_bytes(std::get<1>(test));
147 using g1g2_pair = std::vector<std::string>;
148 using pair_test = std::tuple<std::vector<g1g2_pair>, std::variant<fc::alt_bn128_error, bool>>;
150 const std::vector<pair_test> tests =
156 "0f25929bcb43d5a57391564615c9e70a992b10eafa4db109709649cf48c50dd2",
157 "16da2f5cb6be7a0aa72c440c53c9bbdfec6c36c7d515536431b3a865468acbba",
158 "2e89718ad33c8bed92e210e81d1853435399a271913a6520736a4729cf0d51eb",
159 "01a9e2ffa2e92599b68e44de5bcf354fa2642bd4f26b259daa6f7ce3ed57aeb3",
160 "14a9a87b789a58af499b314e13c3d65bede56c07ea2d418d6874857b70763713",
161 "178fb49a2d6cd347dc58973ff49613a20757d0fcc22079f9abd10c3baee24590",
165 "1b9e027bd5cfc2cb5db82d4dc9677ac795ec500ecd47deee3b5da006d6d049b8",
166 "11d7511c78158de484232fc68daf8a45cf217d1c2fae693ff5871e8752d73b21",
167 "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
168 "1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
169 "090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
170 "12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
180 "0000000000000000000000000000000000000000000000000000000000000001",
181 "0000000000000000000000000000000000000000000000000000000000000002",
182 "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
183 "1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
184 "090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
185 "12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
196 "00000000000000000000000000000000000000000000000000000000000001",
197 "0000000000000000000000000000000000000000000000000000000000000002",
198 "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
199 "1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
200 "090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
201 "12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
205 alt_bn128_error::pairing_list_size_error
212 "0000000000000000000000000000000000000000000000000000000000000000",
213 "0000000000000000000000000000000100000000000000000000000000000000",
214 "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
215 "1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
216 "090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
217 "12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
221 alt_bn128_error::operand_not_in_curve
228 "30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47",
229 "0000000000000000000000000000000100000000000000000000000000000000",
230 "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
231 "1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
232 "090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
233 "12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
237 alt_bn128_error::operand_component_invalid
241 auto concat = [&](
const std::string&
s,
bytes& buffer) {
243 buffer.insert( buffer.end(), res.begin(), res.end());
248 for(
const auto& test : tests) {
249 const auto& pairs = std::get<0>(test);
253 for(
const auto& pair : pairs) {
254 BOOST_REQUIRE(pair.size() == 6);
255 concat(pair[0], g1_g2_pairs);
256 concat(pair[1], g1_g2_pairs);
257 concat(pair[2], g1_g2_pairs);
258 concat(pair[3], g1_g2_pairs);
259 concat(pair[4], g1_g2_pairs);
260 concat(pair[5], g1_g2_pairs);