Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
poseidon2_permutation.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Sergei], commit: 777717f6af324188ecd6bb68c3c86ee7befef94d}
3// external_1: { status: Complete, auditors: [@ed25519 (Spearbit)], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8#include <array>
9#include <cstddef>
10#include <cstdint>
11
15
16namespace bb::stdlib {
17
33template <typename Builder> class Poseidon2Permutation {
34 public:
37 // t = sponge permutation size (in field elements)
38 // t = rate + capacity
39 // capacity = 1 field element
40 // rate = number of field elements that can be compressed per permutation
41 static constexpr size_t t = Params::t;
42 // number of full sbox rounds
43 static constexpr size_t rounds_f = Params::rounds_f;
44 // number of partial sbox rounds
45 static constexpr size_t rounds_p = Params::rounds_p;
46 static constexpr size_t NUM_ROUNDS = Params::rounds_f + Params::rounds_p;
47
48 using FF = typename Params::FF;
51
55
64 static State permutation(Builder* builder, const State& input);
65
69 static void matrix_multiplication_external(State& state)
71
73 requires(!IsMegaBuilder<Builder>);
74
84 static void propagate_current_state_to_next_row(Builder* builder, const State& state, auto& block)
85 {
86 builder->create_unconstrained_gate(block,
87 state[0].get_witness_index(),
88 state[1].get_witness_index(),
89 state[2].get_witness_index(),
90 state[3].get_witness_index());
91 };
92};
93
94} // namespace bb::stdlib
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323.
Circuit form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
static void propagate_current_state_to_next_row(Builder *builder, const State &state, auto &block)
The result of applying a round of Poseidon2 is stored in the next row and is accessed by Poseidon2 In...
static void matrix_multiplication_external(State &state)
In-circuit method to efficiently multiply the initial state by the external matrix .
static constexpr RoundConstantsContainer round_constants
std::array< field_t< Builder >, t > State
static State permutation(Builder *builder, const State &input)
Circuit form of Poseidon2 permutation from https://eprint.iacr.org/2023/323.
std::array< RoundConstants, NUM_ROUNDS > RoundConstantsContainer
static void matrix_multiplication_external(State &state)
AluTraceBuilder builder
Definition alu.test.cpp:124
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static constexpr std::array< std::array< FF, t >, rounds_f+rounds_p > round_constants