Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
databus.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 "../circuit_builders/circuit_builders_fwd.hpp"
9#include "../field/field.hpp"
14
15namespace bb::stdlib {
16
17template <typename Builder> class databus {
18 public:
19 databus() = default;
20
21 private:
22 class bus_vector {
23 private:
25
26 public:
29
38 void set_values(const std::vector<field_pt>& entries_in)
40
47 field_pt operator[](const field_pt& index) const
49
50 size_t size() const { return length; }
51 Builder* get_context() const { return context; }
52
53 private:
54 mutable std::vector<field_pt> entries; // bus vector entries
55 size_t length = 0;
56 BusId bus_idx; // Idx of column in bus
57 mutable Builder* context = nullptr;
58 };
59
60 public:
61 // The columns of the DataBus
65};
66
85template <class Builder> class DataBusDepot {
86 public:
88 using Commitment = typename Curve::Group;
91
92 // Storage for the return data commitments to be propagated via the public inputs
95
96 // Existence flags indicating whether each return data commitment has been set
99
105
107 {
108 app_return_data_commitment = commitment;
110 }
111
118 {
119 CommitmentNative DEFAULT_COMMITMENT_VALUE = CommitmentNative::one() * FrNative(BusVector::DEFAULT_VALUE);
120 auto default_commitment = Commitment(DEFAULT_COMMITMENT_VALUE);
121 default_commitment.convert_constant_to_fixed_witness(&builder);
122 return default_commitment;
123 }
124
137
143 {
146 }
147 app_return_data_commitment_exists = false; // Reset the existence flag after retrieval
149 }
150};
151
152} // namespace bb::stdlib
Class for managing propagation of databus return data commitments used in consistency checks.
Definition databus.hpp:85
Commitment get_kernel_return_data_commitment(Builder &builder)
Get the previously set kernel return data commitment if it exists, else a default one.
Definition databus.hpp:129
Commitment app_return_data_commitment
Definition databus.hpp:93
typename Curve::ScalarFieldNative FrNative
Definition databus.hpp:90
bool kernel_return_data_commitment_exists
Definition databus.hpp:98
typename Curve::AffineElementNative CommitmentNative
Definition databus.hpp:89
bool app_return_data_commitment_exists
Definition databus.hpp:97
static Commitment construct_default_commitment(Builder &builder)
Construct a default commitment for the databus return data.
Definition databus.hpp:117
Commitment kernel_return_data_commitment
Definition databus.hpp:94
Commitment get_app_return_data_commitment(Builder &builder)
Get the previously set app return data commitment if it exists, else a default one.
Definition databus.hpp:142
typename Curve::Group Commitment
Definition databus.hpp:88
void set_app_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:106
void set_kernel_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:100
field_pt operator[](const field_pt &index) const
Read from the bus vector with a witness index value. Creates a read gate.
Definition databus.cpp:42
bus_vector(const BusId bus_idx)
Definition databus.hpp:27
void set_values(const std::vector< field_pt > &entries_in)
Set the entries of the bus vector from possibly unnormalized or constant inputs.
Definition databus.cpp:14
std::vector< field_pt > entries
Definition databus.hpp:54
Builder * get_context() const
Definition databus.hpp:51
bus_vector return_data
Definition databus.hpp:64
bus_vector calldata
Definition databus.hpp:62
bus_vector secondary_calldata
Definition databus.hpp:63
AluTraceBuilder builder
Definition alu.test.cpp:123
BusId
Definition databus.hpp:77
@ SECONDARY_CALLDATA
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
static constexpr bb::fr DEFAULT_VALUE
Definition databus.hpp:29
GroupNative::affine_element AffineElementNative
Definition bn254.hpp:28
curve::BN254::ScalarField ScalarFieldNative
Definition bn254.hpp:24
element< CircuitBuilder, bigfield< CircuitBuilder, bb::Bn254FqParams >, ScalarField, GroupNative > Group
Definition bn254.hpp:34