barretenberg
Loading...
Searching...
No Matches
proof.hpp
1#pragma once
2#include "barretenberg/common/serialize.hpp"
3#include "barretenberg/serialize/msgpack.hpp"
4#include <cstdint>
5#include <iomanip>
6#include <ostream>
7#include <vector>
8
9namespace proof_system::plonk {
10
11struct proof {
12 std::vector<uint8_t> proof_data;
13 // For serialization, serialize as a buffer alias
14 void msgpack_pack(auto& packer) const { packer.pack(proof_data); }
15 void msgpack_unpack(auto object) { proof_data = (std::vector<uint8_t>)object; }
16 void msgpack_schema(auto& packer) const { packer.pack_alias("Proof", "bin32"); }
17 bool operator==(proof const& other) const = default;
18};
19
20inline void read(uint8_t const*& it, proof& data)
21{
22 using serialize::read;
23 read(it, data.proof_data);
24};
25
26template <typename B> inline void write(B& buf, proof const& data)
27{
28 using serialize::write;
29 write(buf, data.proof_data);
30}
31
32inline std::ostream& operator<<(std::ostream& os, proof const& data)
33{
34 // REFACTOR: This is copied from barretenberg/common/streams.hpp,
35 // which means we could just cout proof_data directly, but that breaks the build in the CI with
36 // a redefined operator<< error in barretenberg/stdlib/hash/keccak/keccak.test.cpp,
37 // which is something we really don't want to deal with right now.
38 std::ios_base::fmtflags f(os.flags());
39 os << "[" << std::hex << std::setfill('0');
40 for (auto byte : data.proof_data) {
41 os << ' ' << std::setw(2) << +(unsigned char)byte;
42 }
43 os << " ]";
44 os.flags(f);
45 return os;
46}
47
48} // namespace proof_system::plonk
Definition: widget.bench.cpp:13
Definition: proof.hpp:11