2#include "../bool/bool.hpp"
3#include "../circuit_builders/circuit_builders_fwd.hpp"
4#include "../field/field.hpp"
5#include "../safe_uint/safe_uint.hpp"
11 typedef std::vector<field_t<Builder>> bytes_t;
22 template <
typename ItBegin,
typename ItEnd>
24 : context(parent_context)
27 for (
auto& val : values) {
28 val = val.normalize();
42 assert(values.size() > 0);
50 byte_array slice(
size_t offset,
size_t length)
const;
53 size_t size()
const {
return values.size(); }
55 bytes_t
const& bytes()
const {
return values; }
63 ASSERT(index < values.size());
64 values[index] = byte_val;
69 ASSERT(context ==
nullptr);
73 Builder* get_context()
const {
return context; }
75 std::vector<uint8_t> get_value()
const;
77 std::string get_string()
const;
88 byte_slice split_byte(
const size_t bit_index)
const;
91template <
typename Builder>
inline std::ostream& operator<<(std::ostream& os,
byte_array<Builder> const& arr)
93 std::ios_base::fmtflags f(os.flags());
94 os <<
"[" << std::hex << std::setfill(
'0');
95 for (
auto byte : arr.get_value()) {
96 os <<
' ' << std::setw(2) << +(
unsigned char)
byte;
103EXTERN_STDLIB_TYPE(byte_array);
Definition: standard_circuit_builder.hpp:12
Definition: byte_array.hpp:9
bool_t< Builder > get_bit(size_t index) const
Extract a bit from the byte array.
Definition: byte_array.cpp:298
void set_bit(size_t index, bool_t< Builder > const &value)
Set a bit in the byte array.
Definition: byte_array.cpp:320
byte_array reverse() const
Reverse the bytes in the byte array.
Definition: byte_array.cpp:264
Definition: safe_uint.hpp:17
Definition: widget.bench.cpp:13