|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <string_view> |
| 4 | + |
| 5 | +#include "barretenberg/common/op_count.hpp" |
| 6 | +#include "barretenberg/relations/relation_parameters.hpp" |
| 7 | +#include "barretenberg/relations/relation_types.hpp" |
| 8 | +#include "barretenberg/vm2/generated/columns.hpp" |
| 9 | + |
| 10 | +namespace bb::avm2 { |
| 11 | + |
| 12 | +template <typename FF_> class optimized_poseidon2_permImpl { |
| 13 | + public: |
| 14 | + using FF = FF_; |
| 15 | + |
| 16 | + static constexpr std::array<size_t, 265> SUBRELATION_PARTIAL_LENGTHS = { |
| 17 | + 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 18 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 19 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 20 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 21 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 22 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 23 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, |
| 24 | + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 3, 3 |
| 25 | + }; |
| 26 | + |
| 27 | + template <typename AllEntities> inline static bool skip(const AllEntities& in) |
| 28 | + { |
| 29 | + using C = ColumnAndShifts; |
| 30 | + |
| 31 | + return (in.get(C::poseidon2_perm_sel)).is_zero(); |
| 32 | + } |
| 33 | + |
| 34 | + template <typename ContainerOverSubrelations, typename AllEntities> |
| 35 | + void static accumulate(ContainerOverSubrelations& evals, |
| 36 | + const AllEntities& in, |
| 37 | + [[maybe_unused]] const RelationParameters<FF>&, |
| 38 | + [[maybe_unused]] const FF& scaling_factor); |
| 39 | +}; |
| 40 | + |
| 41 | +template <typename FF> class optimized_poseidon2_perm : public Relation<optimized_poseidon2_permImpl<FF>> { |
| 42 | + public: |
| 43 | + static constexpr const std::string_view NAME = "poseidon2_perm"; |
| 44 | + |
| 45 | + static std::string get_subrelation_label(size_t index) |
| 46 | + { |
| 47 | + switch (index) {} |
| 48 | + return std::to_string(index); |
| 49 | + } |
| 50 | +}; |
| 51 | + |
| 52 | +} // namespace bb::avm2 |
0 commit comments