72 keccakf1600_event.
src_addr = src_addr;
81 bool src_out_of_range =
gt.gt(
static_cast<uint128_t>(src_addr),
static_cast<uint128_t>(HIGHEST_SLICE_ADDRESS));
88 if (src_out_of_range) {
91 if (dst_out_of_range) {
102 for (
size_t i = 0; i < 5; i++) {
103 for (
size_t j = 0; j < 5; j++) {
104 const auto addr = src_addr +
static_cast<MemoryAddress>((i * 5) + j);
107 src_mem_values[i][j] = mem_val;
114 format(
"Read slice tag invalid - addr: ", addr,
" tag: ",
static_cast<uint32_t
>(tag)));
129 for (
size_t i = 0; i < 5; ++i) {
130 MemoryValue xor_accumulator = state_input_values[i][0];
131 for (
size_t j = 0; j < 4; ++j) {
132 xor_accumulator =
bitwise.xor_op(xor_accumulator, state_input_values[i][j + 1]);
133 theta_xor_values[i][j] = xor_accumulator;
139 for (
size_t i = 0; i < 5; ++i) {
140 theta_xor_row_rotl1_values.at(i) = unconstrained_rotate_left(theta_xor_values[i][3], 1);
145 for (
size_t i = 0; i < 5; ++i) {
146 theta_combined_xor_values.at(i) =
147 bitwise.xor_op(theta_xor_values[(i + 4) % 5][3], theta_xor_row_rotl1_values.at((i + 1) % 5));
152 for (
size_t i = 0; i < 5; ++i) {
153 for (
size_t j = 0; j < 5; ++j) {
154 state_theta_values[i][j] =
155 bitwise.xor_op(state_input_values[i][j], theta_combined_xor_values.at(i));
166 for (
size_t i = 0; i < 5; ++i) {
167 for (
size_t j = 0; j < 5; ++j) {
170 state_rho_values[i][j] = unconstrained_rotate_left(state_theta_values[i][j],
len);
171 if (
len > 0 &&
len <= 32) {
172 range_check.assert_range(state_theta_values[i][j].as<uint64_t>() >> (64 -
len),
len);
173 }
else if (
len > 32) {
174 range_check.assert_range(state_theta_values[i][j].as<uint64_t>() & ((1U << (64 -
len)) - 1),
184 for (
size_t i = 0; i < 5; ++i) {
185 for (
size_t j = 0; j < 5; ++j) {
187 state_pi_not_values[i][j] = ~state_pi_values[i][j];
195 for (
size_t i = 0; i < 5; ++i) {
196 for (
size_t j = 0; j < 5; ++j) {
197 state_pi_and_values[i][j] =
198 bitwise.and_op(state_pi_not_values[(i + 1) % 5][j], state_pi_values[(i + 2) % 5][j]);
199 state_chi_values[i][j] =
bitwise.xor_op(state_pi_values[i][j], state_pi_and_values[i][j]);
208 rounds_data.at(round_idx) = {
209 .state = two_dim_array_to_uint64(state_input_values),
210 .theta_xor = two_dim_array_to_uint64(theta_xor_values),
211 .theta_xor_row_rotl1 = array_to_uint64(theta_xor_row_rotl1_values),
212 .theta_combined_xor = array_to_uint64(theta_combined_xor_values),
213 .state_theta = two_dim_array_to_uint64(state_theta_values),
214 .state_rho = two_dim_array_to_uint64(state_rho_values),
215 .state_pi_not = two_dim_array_to_uint64(state_pi_not_values),
216 .state_pi_and = two_dim_array_to_uint64(state_pi_and_values),
217 .state_chi = two_dim_array_to_uint64(state_chi_values),
218 .state_iota_00 = iota_00_value.
as<uint64_t>(),
221 state_input_values = state_chi_values;
222 state_input_values[0][0] = iota_00_value;
226 for (
size_t i = 0; i < 5; i++) {
227 for (
size_t j = 0; j < 5; j++) {
232 keccakf1600_event.
rounds = rounds_data;
void permutation(MemoryInterface &memory, MemoryAddress dst_addr, MemoryAddress src_addr) override
Permutation Keccak-f[1600] consisting in AVM_KECCAKF1600_NUM_ROUNDS (24) rounds and a state of 25 64-...