16 namespace internal_use_do_not_use {
34 int32_t
blake2_f(
uint32_t rounds, const
char*
state,
uint32_t state_len, const
char*
msg,
uint32_t msg_len, const
char*
t0_offset,
uint32_t t0_len, const
char*
t1_offset,
uint32_t t1_len, int32_t
final,
char*
result,
uint32_t result_len);
43 static inline auto sha3_helper(const
char* data,
uint32_t length,
bool keccak) {
44 internal_use_do_not_use::capi_checksum256_ext
hash;
46 eosio::checksum256 dg;
65 template <std::
size_t Size = 32>
83 ec_point(std::vector<char>& x_, std::vector<char>& y_)
86 eosio::check( x_.size() == y_.size(),
"x's size must be equal to y's" );
87 eosio::check ( x_.size() == Size,
"point size must match");
96 :x(p.data(), p.data() + Size), y(p.data() + Size, p.data() + p.
size())
98 eosio::check ( p.size() == Size * 2,
"point size must match");
105 std::vector<char> x_and_y( x );
106 x_and_y.insert( x_and_y.end(), y.begin(), y.end() );
116 template <std::
size_t Size = 32>
142 :x(x_), y(y_),
size(x_size)
144 eosio::check ( x_size == y_size,
"x's size must be equal to y's");
154 :x(p.data()), y(p.data() + Size),
size(Size)
156 eosio::check ( p.size() == Size * 2,
"point size must match");
165 :x(p.x.data()), y(p.y.data()),
size(Size)
173 std::vector<char> x_and_y( x, x +
size );
174 x_and_y.insert( x_and_y.end(), y, y +
size );
179 static constexpr size_t g1_coordinate_size = 32;
180 static constexpr size_t g2_coordinate_size = 64;
202 template <
typename T>
205 auto op_2 =
op2.serialized();
206 std::vector<char> buf ( 2 * g1_coordinate_size );
208 eosio::check ( ret == 0,
"internal_use_do_not_use::alt_bn128_add failed" );
236 template <
typename T>
239 std::vector<char> buf( 2 * g1_coordinate_size );
241 eosio::check ( ret == 0,
"internal_use_do_not_use::alt_bn128_mul failed");
268 template <
typename G1_T,
typename G2_T>
269 inline int32_t
alt_bn128_pair(
const std::vector<std::pair<G1_T, G2_T>>& pairs ) {
270 std::vector<char> g1_g2_pairs;
271 for (
const auto& pair: pairs ) {
272 auto g1_bin = pair.first.serialized();
273 auto g2_bin = pair.second.serialized();
274 g1_g2_pairs.insert( g1_g2_pairs.end(), g1_bin.begin(), g1_bin.end() );
275 g1_g2_pairs.insert( g1_g2_pairs.end(), g2_bin.begin(), g2_bin.end() );
305 eosio::check(
result.size() >=
mod.size(),
"mod_exp result parameter's size must be >= mod's size" );
330 static constexpr size_t blake2f_result_size = 64;
347 eosio::check(
result.size() >= blake2f_result_size,
"blake2_f result parameter's size must be >= 64" );
348 return internal_use_do_not_use::blake2_f( rounds,
state.data(),
state.size(),
msg.data(),
msg.size(),
t0_offset.data(),
t0_offset.size(),
t1_offset.data(),
t1_offset.size(),
final,
result.data(),
result.size());
372 return internal_use_do_not_use::blake2_f( rounds,
state,
state_len,
msg,
msg_len,
t0_offset,
t0_len,
t1_offset,
t1_len,
final,
result,
result_len);
384 return internal_use_do_not_use::sha3_helper(data, length,
false);
397 const auto& res = internal_use_do_not_use::sha3_helper(data, length,
false);
398 check(
hash == res,
"SHA3 hash of `data` does not match given `hash`");
410 return internal_use_do_not_use::sha3_helper(data, length,
true);
423 const auto& res = internal_use_do_not_use::sha3_helper(data, length,
true);
424 check(
hash == res,
"Keccak hash of `data` does not match given `hash`");