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: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8#include <array>
9#include <cstddef>
10#include <cstdint>
11
14
15namespace bb::stdlib {
16
30template <typename Builder> class Poseidon2Permutation {
31 public:
34 // t = sponge permutation size (in field elements)
35 // t = rate + capacity
36 // capacity = 1 field element
37 // rate = number of field elements that can be compressed per permutation
38 static constexpr size_t t = Params::t;
39 // number of full sbox rounds
40 static constexpr size_t rounds_f = Params::rounds_f;
41 // number of partial sbox rounds
42 static constexpr size_t rounds_p = Params::rounds_p;
43 static constexpr size_t NUM_ROUNDS = Params::rounds_f + Params::rounds_p;
44
45 using FF = typename Params::FF;
47 using NativeState = std::array<FF, t>;
48
49 using RoundConstants = std::array<FF, t>;
52
61 static State permutation(Builder* builder, const State& input);
62
68
78 static void propagate_current_state_to_next_row(Builder* builder, const State& state, auto& block)
79 {
80 builder->create_unconstrained_gate(block,
81 state[0].get_witness_index(),
82 state[1].get_witness_index(),
83 state[2].get_witness_index(),
84 state[3].get_witness_index());
85 };
86};
87
88} // 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 matrix_multiplication_external(State &state)
In-circuit method to efficiently multiply the inital state by the external matrix ....
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 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
AluTraceBuilder builder
Definition alu.test.cpp:123
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