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
15
16namespace bb::stdlib {
17
18template <typename Params, typename Builder> class Poseidon2Permutation {
19 public:
21 // t = sponge permutation size (in field elements)
22 // t = rate + capacity
23 // capacity = 1 field element (256 bits)
24 // rate = number of field elements that can be compressed per permutation
25 static constexpr size_t t = Params::t;
26 // d = degree of s-box polynomials. For a given field, `d` is the smallest element of `p` such that gdc(d, p - 1) =
27 // 1 (excluding 1) For bn254/grumpkin, d = 5
28 static constexpr size_t d = Params::d;
29 // sbox size = number of bits in p
30 static constexpr size_t sbox_size = Params::sbox_size;
31 // number of full sbox rounds
32 static constexpr size_t rounds_f = Params::rounds_f;
33 // number of partial sbox rounds
34 static constexpr size_t rounds_p = Params::rounds_p;
35 static constexpr size_t NUM_ROUNDS = Params::rounds_f + Params::rounds_p;
36
37 using FF = typename Params::FF;
39 using NativeState = std::array<FF, t>;
40
41 using RoundConstants = std::array<FF, t>;
44
53 static State permutation(Builder* builder, const State& input);
54
69};
70
71} // namespace bb::stdlib
Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323 ....
std::array< RoundConstants, NUM_ROUNDS > RoundConstantsContainer
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.
static void matrix_multiplication_external(Builder *builder, State &state)
Separate function to do just the first linear layer (equivalent to external matrix mul).
static constexpr RoundConstantsContainer round_constants
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