Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
public_input_component.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>
13#include <span>
14namespace bb {
15
22template <typename ComponentType>
25 { // A method to reconstruct the object from the limbs stored in public inputs
26 ComponentType::reconstruct_from_public(public_inputs)
28 { // A constant defining the number of limbs needed to represent the object in the public inputs
29 ComponentType::PUBLIC_INPUTS_SIZE
31 };
32
38template <typename ComponentType>
41 static constexpr uint32_t COMPONENT_SIZE = ComponentType::PUBLIC_INPUTS_SIZE;
42
43 public:
45
46 // Reconstruct the component from the public inputs and the key indicating its location
47 static ComponentType reconstruct(const std::vector<bb::fr>& public_inputs, const Key& key)
48 {
49 // Ensure that the key has been set
50 if (!key.is_set()) {
51 throw_or_abort("ERROR: Trying to construct a PublicInputComponent from an invalid key!");
52 }
53
54 // Use the provided key to extract the limbs of the component from the public inputs then reconstruct it
56 public_inputs.size(),
57 "PublicInputComponent cannot be reconstructed - PublicInputComponentKey start_idx out of bounds");
58 std::span<const bb::fr, COMPONENT_SIZE> limbs{ public_inputs.data() + key.start_idx, COMPONENT_SIZE };
59 return ComponentType::reconstruct_from_public(limbs);
60 }
61};
62
63} // namespace bb
#define BB_ASSERT_LTE(left, right,...)
Definition assert.hpp:129
A wrapper class for deserializing objects from the public inputs of a circuit.
static constexpr uint32_t COMPONENT_SIZE
static ComponentType reconstruct(const std::vector< bb::fr > &public_inputs, const Key &key)
A concept defining requirements for types that are to be deserialized from the public inputs of a cir...
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
void throw_or_abort(std::string const &err)