Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
circuit_input.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
17#include <msgpack/adaptor/define_decl.hpp>
18
19#include <cstdint>
20#include <memory>
21#include <ostream>
22#include <string>
23#include <utility>
24#include <variant>
25
26namespace bb {
27
28enum class CircuitKind : uint8_t {
29 App = 0,
30 Kernel = 1,
31 HidingKernel = 2,
32 // Sentinel for an unset kind. It is the default for every wire struct, so a `kind` that was
33 // never set (e.g. an old or external msgpack) is rejected by dispatch_kind / the IVC guard
34 // instead of silently decoding as a real kind. Kept distinct from the wire values 0/1/2.
35 None = 255,
36};
37
38inline std::ostream& operator<<(std::ostream& os, CircuitKind kind)
39{
40 switch (kind) {
42 return os << "app";
44 return os << "kernel";
46 return os << "hiding";
48 return os << "none";
49 }
50 return os << "unknown(" << static_cast<int>(kind) << ")";
51}
52
56
59
60template <CircuitKind K> struct flavor_for_impl;
61template <> struct flavor_for_impl<CircuitKind::App> {
63};
64template <> struct flavor_for_impl<CircuitKind::Kernel> {
66};
69};
70template <CircuitKind K> using flavor_for = typename flavor_for_impl<K>::type;
71
72template <CircuitKind K, typename Builder> struct io_for_impl;
73template <typename Builder> struct io_for_impl<CircuitKind::App, Builder> {
75};
76template <typename Builder> struct io_for_impl<CircuitKind::Kernel, Builder> {
78};
82template <CircuitKind K, typename Builder = MegaCircuitBuilder> using io_for = typename io_for_impl<K, Builder>::type;
83
84template <typename F> constexpr decltype(auto) dispatch_kind(CircuitKind kind, F&& f)
85{
86 switch (kind) {
88 return std::forward<F>(f).template operator()<CircuitKind::App>();
90 return std::forward<F>(f).template operator()<CircuitKind::Kernel>();
92 return std::forward<F>(f).template operator()<CircuitKind::HidingKernel>();
94 break;
95 }
96 // Throw (not unreachable): the VK paths dispatch on the raw wire kind, which may be None or an
97 // out-of-range msgpack byte. Must fail clearly in release/WASM rather than fall past the switch.
98 throw_or_abort("dispatch_kind: invalid CircuitKind " + std::to_string(static_cast<int>(kind)));
99}
100
101} // namespace bb
102
103MSGPACK_ADD_ENUM(bb::CircuitKind)
Mega flavor specialized for Chonk app circuits.
Mega flavor specialized for Chonk kernel circuits.
Hiding-kernel-only Mega variant: runs with ZK Sumcheck and a reduced relation set.
Manages the data that is propagated on the public inputs of an application/function circuit.
Manages the data that is propagated on the public inputs of a hiding kernel circuit.
Manages the data that is propagated on the public inputs of a kernel circuit.
KernelIO_< MAX_APPS_PER_KERNEL > KernelIO
DefaultIO< MegaCircuitBuilder > AppIO
The data that is propagated on the public inputs of an application/function circuit.
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
std::ostream & operator<<(std::ostream &os, CircuitKind kind)
typename io_for_impl< K, Builder >::type io_for
std::variant< std::shared_ptr< MegaAppFlavor::VerificationKey >, std::shared_ptr< MegaKernelFlavor::VerificationKey >, std::shared_ptr< MegaZKFlavor::VerificationKey > > CircuitVerificationKey
typename flavor_for_impl< K >::type flavor_for
std::variant< std::shared_ptr< MegaAppRecursiveFlavor::VKAndHash >, std::shared_ptr< MegaKernelRecursiveFlavor::VKAndHash > > StdlibCircuitVKAndHash
constexpr decltype(auto) dispatch_kind(CircuitKind kind, F &&f)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
std::string to_string(bb::avm2::ValueTag tag)
void throw_or_abort(std::string const &err)