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
12#include <cstdint>
13namespace bb {
14
15// We assume all kernels have space for two return data commitments on their public inputs
16constexpr uint32_t NUM_DATABUS_COMMITMENTS = 2;
19
24struct BusVector {
25
26 // A default value added to every databus column to avoid the point at infinity commitment and to ensure the
27 // validity of the databus commitment consistency checks. Note: in principle we could allow point at infinity
28 // default commitment but there is precedent for avoiding this by default.
29 static constexpr bb::fr DEFAULT_VALUE = 25;
30
36 void append(const uint32_t& idx)
37 {
38 data.emplace_back(idx);
39 read_counts.emplace_back(0);
40 }
41
42 size_t size() const { return data.size(); }
43
44 const uint32_t& operator[](size_t idx) const
45 {
46 BB_ASSERT_LT(idx, size());
47 return data[idx];
48 }
49
50 const uint32_t& get_read_count(size_t idx) const
51 {
52 BB_ASSERT_LT(idx, read_counts.size());
53 return read_counts[idx];
54 }
55
56 void increment_read_count(size_t idx)
57 {
58 BB_ASSERT_LT(idx, read_counts.size());
59 read_counts[idx]++;
60 }
61
62 private:
63 std::vector<uint32_t> read_counts; // count of reads at each index into data
64 std::vector<uint32_t> data; // variable indices corresponding to data in this bus vector
65};
66
76using DataBus = std::array<BusVector, 3>;
78
79} // namespace bb
#define BB_ASSERT_LT(left, right,...)
Definition assert.hpp:115
Entry point for Barretenberg command-line interface.
constexpr uint32_t PROPAGATED_DATABUS_COMMITMENTS_SIZE
Definition databus.hpp:18
std::array< BusVector, 3 > DataBus
The DataBus; facilitates storage of public circuit input/output.
Definition databus.hpp:76
constexpr uint32_t NUM_DATABUS_COMMITMENTS
Definition databus.hpp:16
constexpr uint32_t PROPAGATED_DATABUS_COMMITMENT_SIZE
Definition databus.hpp:17
BusId
Definition databus.hpp:77
@ SECONDARY_CALLDATA
A DataBus column.
Definition databus.hpp:24
std::vector< uint32_t > read_counts
Definition databus.hpp:63
void increment_read_count(size_t idx)
Definition databus.hpp:56
void append(const uint32_t &idx)
Add an element to the data defining this bus column.
Definition databus.hpp:36
std::vector< uint32_t > data
Definition databus.hpp:64
size_t size() const
Definition databus.hpp:42
const uint32_t & operator[](size_t idx) const
Definition databus.hpp:44
static constexpr bb::fr DEFAULT_VALUE
Definition databus.hpp:29
const uint32_t & get_read_count(size_t idx) const
Definition databus.hpp:50