Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
utils.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
11#include <vector>
12
13namespace acir_format {
14
15using namespace bb;
16
26template <typename Builder>
27static std::vector<stdlib::field_t<Builder>> fields_from_witnesses(Builder& builder,
28 std::span<const uint32_t> witness_indices)
29{
31 result.reserve(witness_indices.size());
32 for (const auto& idx : witness_indices) {
33 result.emplace_back(stdlib::field_t<Builder>::from_witness_index(&builder, idx));
34 }
35 return result;
36}
37
47template <typename T>
49{
50 std::vector<uint32_t> indices;
51 indices.reserve(input.size());
52 auto witness_idx = static_cast<uint32_t>(witness.size());
53 for (const auto& value : input) {
54 witness.push_back(bb::fr(value));
55 indices.push_back(witness_idx++);
56 }
57 return indices;
58};
59
71template <typename T, std::size_t N>
73{
75 auto witness_idx = static_cast<uint32_t>(witness.size());
76 size_t idx = 0;
77 for (const auto& value : input) {
78 witness.push_back(bb::fr(value));
79 indices[idx++] = witness_idx++;
80 }
81 return indices;
82};
83
84} // namespace acir_format
AluTraceBuilder builder
Definition alu.test.cpp:123
std::vector< uint32_t > add_to_witness_and_track_indices(WitnessVector &witness, std::span< const T > input)
Append values to a witness vector and track their indices.
Definition utils.hpp:48
bb::SlabVector< bb::fr > WitnessVector
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13