26 #ifndef CRYPTO3_ALGEBRA_CURVES_HASH_TO_CURVE2_HPP
27 #define CRYPTO3_ALGEBRA_CURVES_HASH_TO_CURVE2_HPP
33 #include <type_traits>
35 #include <nil/crypto3/multiprecision/cpp_int.hpp>
42 using namespace nil::crypto3::multiprecision;
44 template<
typename GroupType>
57 constexpr
static std::size_t m = suite_type::m;
58 constexpr
static std::size_t L = suite_type::L;
59 constexpr
static std::size_t k = suite_type::k;
65 static_assert(m == 2,
"underlying field has wrong extension");
67 template<
typename InputType,
typename DstType,
68 typename =
typename std::enable_if<
69 std::is_same<std::uint8_t, typename InputType::value_type>::value &&
70 std::is_same<std::uint8_t, typename DstType::value_type>::value>::type>
72 auto u = hash_to_field<2, expand_message_ro>(msg, dst);
75 return clear_cofactor(Q0 + Q1);
78 template<std::size_t N,
typename expand_message_type,
typename InputType,
typename DstType,
79 typename =
typename std::enable_if<
80 std::is_same<std::uint8_t, typename InputType::value_type>::value &&
81 std::is_same<std::uint8_t, typename DstType::value_type>::value>::type>
82 static inline std::array<field_value_type, N>
hash_to_field(
const InputType &msg,
84 std::array<std::uint8_t, N * m * L> uniform_bytes {0};
85 expand_message_type::process(N * m * L, msg, dst, uniform_bytes);
88 std::array<modular_type, m> coordinates;
89 std::array<field_value_type, N> result;
90 for (std::size_t i = 0; i < N; i++) {
91 for (std::size_t j = 0; j < m; j++) {
92 auto elm_offset = L * (j + i * m);
93 import_bits(e, uniform_bytes.begin() + elm_offset,
94 uniform_bytes.begin() + elm_offset + L);
104 return R * suite_type::h_eff;
Definition: h2c_expand.hpp:57
suite_type::hash_type hash_type
Definition: ep2.hpp:55
static std::array< field_value_type, N > hash_to_field(const InputType &msg, const DstType &dst)
Definition: ep2.hpp:82
suite_type::modular_backend modular_backend
Definition: ep2.hpp:51
suite_type::group_value_type group_value_type
Definition: ep2.hpp:48
nil::crypto3::multiprecision::modular_params< modular_backend > modular_params_type
Definition: ep2.hpp:53
expand_message_xmd< k, hash_type > expand_message_ro
Definition: ep2.hpp:61
static group_value_type clear_cofactor(const group_value_type &R)
Definition: ep2.hpp:103
h2c_suite< GroupType > suite_type
Definition: ep2.hpp:46
suite_type::field_value_type field_value_type
Definition: ep2.hpp:49
static group_value_type hash_to_curve(const InputType &msg, const DstType &dst)
Definition: ep2.hpp:71
suite_type::modular_type modular_type
Definition: ep2.hpp:50
Definition: algebra/include/nil/crypto3/algebra/curves/detail/h2c/h2c_suites.hpp:48
Definition: h2c_m2c.hpp:96