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"
13
14namespace bb::stdlib {
15
16template <typename Builder> class databus {
17 public:
18 databus() = default;
19
20 private:
21 class bus_vector {
22 private:
24
25 public:
28
37 void set_values(const std::vector<field_pt>& entries_in)
39
46 field_pt operator[](const field_pt& index) const
48
49 size_t size() const { return length; }
50 Builder* get_context() const { return context; }
51
52 private:
53 mutable std::vector<field_pt> entries; // bus vector entries
54 size_t length = 0;
55 BusId bus_idx; // Idx of column in bus
56 mutable Builder* context = nullptr;
57 };
58
59 public:
60 // The columns of the DataBus
64};
65
84template <class Builder> class DataBusDepot {
85 public:
87 using Commitment = typename Curve::Group;
90
91 // Storage for the return data commitments to be propagated via the public inputs
94
95 // Existence flags indicating whether each return data commitment has been set
98
104
106 {
107 app_return_data_commitment = commitment;
109 }
110
117 {
118 CommitmentNative DEFAULT_COMMITMENT_VALUE = CommitmentNative::one() * FrNative(BusVector::DEFAULT_VALUE);
119 auto default_commitment = Commitment(DEFAULT_COMMITMENT_VALUE);
120 default_commitment.convert_constant_to_fixed_witness(&builder);
121 return default_commitment;
122 }
123
136
142 {
145 }
146 app_return_data_commitment_exists = false; // Reset the existence flag after retrieval
148 }
149};
150
151} // namespace bb::stdlib
Class for managing propagation of databus return data commitments used in consistency checks.
Definition databus.hpp:84
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:128
Commitment app_return_data_commitment
Definition databus.hpp:92
typename Curve::ScalarFieldNative FrNative
Definition databus.hpp:89
bool kernel_return_data_commitment_exists
Definition databus.hpp:97
typename Curve::AffineElementNative CommitmentNative
Definition databus.hpp:88
bool app_return_data_commitment_exists
Definition databus.hpp:96
static Commitment construct_default_commitment(Builder &builder)
Construct a default commitment for the databus return data.
Definition databus.hpp:116
Commitment kernel_return_data_commitment
Definition databus.hpp:93
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:141
typename Curve::Group Commitment
Definition databus.hpp:87
void set_app_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:105
void set_kernel_return_data_commitment(const Commitment &commitment)
Definition databus.hpp:99
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:26
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:53
Builder * get_context() const
Definition databus.hpp:50
bus_vector return_data
Definition databus.hpp:63
bus_vector calldata
Definition databus.hpp:61
bus_vector secondary_calldata
Definition databus.hpp:62
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