25template <
typename Builder>
class keccak {
42 static constexpr std::array<uint64_t, NUM_KECCAK_ROUNDS>
RC = {
43 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, 0x8000000080008000, 0x000000000000808b,
44 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, 0x0000000000000088,
45 0x0000000080008009, 0x000000008000000a, 0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
46 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 0x000000000000800a, 0x800000008000000a,
47 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
51 static constexpr std::array<size_t, NUM_KECCAK_LANES>
ROTATIONS = {
52 0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14,
69 uint64_t bit =
static_cast<uint64_t
>(input & 1);
70 out_bits[count++] = bit;
74 for (
size_t i = 0; i < count; ++i) {
76 output += out_bits[count - 1 - i];
98 uint64_t bit =
static_cast<uint64_t
>(
slice) & 1;
99 out_bits[count++] = bit;
103 for (
size_t i = 0; i < count; ++i) {
105 out += out_bits[count - 1 - i];
118 for (
size_t i = 0; i < 24; ++i) {
138 for (
size_t i = 0; i < 64; ++i) {
167 std::vector<uint8_t> output;
170 memcpy((
void*)&output[0], (
void*)&hash_result.word64s[0], 32);
constexpr std::pair< uint256_t, uint256_t > divmod(const uint256_t &b) const
Implements boolean logic in-circuit.
Represents a dynamic array of bytes in-circuit.
static constexpr uint256_t get_chi_offset()
Compute the constant offset added in the Chi round.
static void rho(keccak_state &state)
RHO round.
static constexpr uint256_t CHI_OFFSET
static constexpr uint256_t BASE
static constexpr uint256_t normalize_sparse(uint256_t input)
Normalize a base-11 integer where each base value can be > 1.
static constexpr std::array< uint256_t, NUM_KECCAK_ROUNDS > get_sparse_round_constants()
Get the sparse round constants object.
static void pi(keccak_state &state)
PI.
static void theta(keccak_state &state)
THETA round.
static void compute_twisted_state(keccak_state &internal)
Compute twisted representation of hash lane.
static void chi(keccak_state &state)
CHI.
static std::vector< uint8_t > hash_native(const std::vector< uint8_t > &data)
static field_t< Builder > normalize_and_rotate(const field_ct &limb, field_ct &msb)
Normalize a base-11 limb and left-rotate by keccak::ROTATIONS[lane_index] bits. This method also extr...
static constexpr std::array< size_t, NUM_KECCAK_LANES > ROTATIONS
static constexpr std::array< uint64_t, NUM_KECCAK_ROUNDS > RC
static constexpr size_t NUM_KECCAK_ROUNDS
static constexpr std::array< uint256_t, NUM_KECCAK_ROUNDS > SPARSE_RC
static std::array< field_ct, NUM_KECCAK_LANES > permutation_opcode(std::array< field_ct, NUM_KECCAK_LANES > state, Builder *context)
static std::array< field_ct, NUM_KECCAK_LANES > extended_2_normal(keccak_state &internal)
static void keccakf1600(keccak_state &state)
static constexpr size_t NUM_KECCAK_LANES
static void iota(keccak_state &state, size_t round)
IOTA.
static constexpr uint256_t convert_to_sparse(uint256_t input)
Convert a binary integer into a base11 integer.
const std::vector< MemoryValue > data
StrictMock< MockContext > context
struct keccak256 ethash_keccak256(const uint8_t *data, size_t size) NOEXCEPT
C slice(C const &container, size_t start)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::array< field_ct, NUM_KECCAK_LANES > state
std::array< field_ct, NUM_KECCAK_LANES > twisted_state
std::array< field_ct, NUM_KECCAK_LANES > state_msb