65 for (
const auto&
event : events) {
67 const size_t input_len =
event.calldata.size() + 1;
73 const auto padding_amount = (2 * input_len) % 3;
74 const auto padded_len = input_len + padding_amount;
76 calldata_with_sep.reserve(padded_len);
77 calldata_with_sep.insert(calldata_with_sep.end(),
event.calldata.begin(),
event.calldata.end());
79 calldata_with_sep.insert(calldata_with_sep.end(), padding_amount,
FF(0));
81 auto num_rounds_rem = padded_len / 3;
83 while (num_rounds_rem > 0) {
84 bool start =
index == 0;
85 bool end = num_rounds_rem == 1;
88 { C::calldata_hashing_sel, 1 },
89 { C::calldata_hashing_start, start ? 1 : 0 },
90 { C::calldata_hashing_sel_not_start, !start ? 1 : 0 },
91 { C::calldata_hashing_context_id,
event.context_id },
92 { C::calldata_hashing_calldata_size,
event.calldata.size() },
93 { C::calldata_hashing_input_len, input_len },
94 { C::calldata_hashing_rounds_rem, num_rounds_rem },
95 { C::calldata_hashing_index_0_,
index },
96 { C::calldata_hashing_index_1_,
index + 1 },
97 { C::calldata_hashing_index_2_,
index + 2 },
98 { C::calldata_hashing_input_0_, calldata_with_sep[
index] },
99 { C::calldata_hashing_input_1_, calldata_with_sep[
index + 1] },
100 { C::calldata_hashing_input_2_, calldata_with_sep[
index + 2] },
101 { C::calldata_hashing_output_hash,
event.calldata_hash },
102 { C::calldata_hashing_sel_not_padding_1, end && (padding_amount == 2) ? 0 : 1 },
103 { C::calldata_hashing_sel_not_padding_2, end && (padding_amount > 0) ? 0 : 1 },
104 { C::calldata_hashing_end, end ? 1 : 0 },
105 { C::calldata_hashing_sel_end_not_empty, end && !
event.calldata.empty() ? 1 : 0 },