Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
dynamic_array.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 "ram_table.hpp"
10namespace bb::stdlib {
11
17template <typename Builder> class DynamicArray {
18 private:
22
23 public:
24 DynamicArray(Builder* builder, const size_t maximum_size);
25
26 DynamicArray(const DynamicArray& other);
28
29 DynamicArray& operator=(const DynamicArray& other);
31
32 void resize(const field_pt& new_length, const field_pt default_value = 0);
33
34 field_pt read(const field_pt& index) const;
35 void write(const field_pt& index, const field_pt& value);
36
37 void push(const field_pt& index);
38 void pop();
39
40 void conditional_push(const bool_pt& predicate, const field_pt& index);
41 void conditional_pop(const bool_pt& predicate);
42
43 field_pt size() const { return _length; }
44 size_t native_size() const { return static_cast<size_t>(static_cast<uint256_t>(_length.get_value())); }
45 size_t max_size() const { return _max_size; }
46
47 Builder* get_context() const { return _context; }
48
49 private:
50 Builder* _context = nullptr;
51 size_t _max_size;
54};
55} // namespace bb::stdlib
A dynamic array of field elements.
witness_t< Builder > witness_pt
void conditional_pop(const bool_pt &predicate)
Conditionallhy pop a field element off of the dynamic array.
bool_t< Builder > bool_pt
field_t< Builder > field_pt
ram_table< Builder > _inner_table
void write(const field_pt &index, const field_pt &value)
Write a field element into the dynamic array at an index value.
void resize(const field_pt &new_length, const field_pt default_value=0)
Resize array. Current method v. inefficient!
void push(const field_pt &index)
Push a field element onto the dynamic array.
field_pt read(const field_pt &index) const
Read a field element from the dynamic array at an index value.
void pop()
Pop a field element off of the dynamic array.
DynamicArray & operator=(const DynamicArray &other)
Assignment Operator.
void conditional_push(const bool_pt &predicate, const field_pt &index)
Conditionally push a field element onto the dynamic array.
Builder * get_context() const
Implements boolean logic in-circuit.
Definition bool.hpp:59
bb::fr get_value() const
Given a := *this, compute its value given by a.v * a.mul + a.add.
Definition field.cpp:827
AluTraceBuilder builder
Definition alu.test.cpp:123