purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
construction_receipt.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Judica, Inc.
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or https://opensource.org/license/mit/.
4
9
10#pragma once
11
14
15namespace purify::accountable {
16
17using AnchorReference = std::array<unsigned char, 32>;
18using ConstructionReceiptStatementDigest = std::array<unsigned char, 32>;
20 std::array<unsigned char, 32>;
21
30class ResolvedConstructionSetupDigest {
31public:
32 static constexpr std::size_t kSerializedSize = 32;
33
36
38 const noexcept {
39 return digest_;
40 }
41
42private:
45 : digest_(digest) {}
46
48};
49
61
67
78class ConstructionReceiptPayload {
79public:
80 static constexpr unsigned char kSerializationVersion = 4;
81 static constexpr std::size_t kFixedHeaderSize = 1 + 64 + 4 + 4;
82 static constexpr std::size_t kSetupEntrySize =
84 bppp::ScalarBytes{}.size();
85 static constexpr std::size_t kAnchorEntrySize =
87 bppp::ScalarBytes{}.size();
88 static_assert(kSetupEntrySize == 98);
89 static_assert(kAnchorEntrySize == 128);
90
91 [[nodiscard]] static Result<ConstructionReceiptPayload> create(
93 std::vector<ConstructionReceiptSetupEntry> setup_entries,
94 std::vector<ConstructionReceiptAnchorEntry> anchor_entries);
95
96 [[nodiscard]] Bytes serialize() const;
97
99 std::span<const unsigned char> encoded);
100
101 [[nodiscard]] const UInt512& recovery_root() const noexcept {
102 return recovery_root_;
103 }
104
105 [[nodiscard]] std::span<const ConstructionReceiptSetupEntry>
106 setup_entries() const noexcept {
107 return setup_entries_;
108 }
109
110 [[nodiscard]] std::span<const ConstructionReceiptAnchorEntry>
111 anchor_entries() const noexcept {
112 return anchor_entries_;
113 }
114
115 [[nodiscard]] std::size_t serialized_size() const noexcept {
116 return kFixedHeaderSize +
117 setup_entries_.size() * kSetupEntrySize +
118 anchor_entries_.size() * kAnchorEntrySize;
119 }
120
121private:
124 std::vector<ConstructionReceiptSetupEntry> setup_entries,
125 std::vector<ConstructionReceiptAnchorEntry> anchor_entries)
126 : recovery_root_(recovery_root),
127 setup_entries_(std::move(setup_entries)),
128 anchor_entries_(std::move(anchor_entries)) {}
129
130 UInt512 recovery_root_{};
131 std::vector<ConstructionReceiptSetupEntry> setup_entries_;
132 std::vector<ConstructionReceiptAnchorEntry> anchor_entries_;
133};
134
155
169 const ConstructionReceiptPayload& payload,
170 const ResolvedConstructionSetupDigest& resolved_setup,
171 std::span<const ResolvedConstructionReceiptEntry> resolved_entries);
172
173} // namespace purify::accountable
Canonical public payload for a coalition construction receipt.
std::span< const ConstructionReceiptSetupEntry > setup_entries() const noexcept
std::span< const ConstructionReceiptAnchorEntry > anchor_entries() const noexcept
static Result< ConstructionReceiptPayload > create(UInt512 recovery_root, std::vector< ConstructionReceiptSetupEntry > setup_entries, std::vector< ConstructionReceiptAnchorEntry > anchor_entries)
static Result< ConstructionReceiptPayload > deserialize(std::span< const unsigned char > encoded)
static constexpr std::size_t kSerializedSize
Immutable registry-record digest selected by a recovery root.
static Result< ResolvedConstructionSetupDigest > create(const ResolvedConstructionSetupDigestBytes &digest)
const ResolvedConstructionSetupDigestBytes & bytes() const noexcept
std::array< unsigned char, 32 > ResolvedConstructionSetupDigestBytes
std::array< unsigned char, 32 > AnchorEscrowContextDigest
std::array< unsigned char, 32 > AnchorReference
Result< ConstructionReceiptStatementDigest > construction_receipt_statement_digest(const ConstructionReceiptPayload &payload, const ResolvedConstructionSetupDigest &resolved_setup, std::span< const ResolvedConstructionReceiptEntry > resolved_entries)
Bind a canonical payload to its ordered, resolved anchor inputs.
std::array< unsigned char, 32 > ConstructionReceiptStatementDigest
std::array< unsigned char, 32 > ScalarBytes
Big-endian 32-byte scalar encoding.
Definition bppp.hpp:30
BigUInt< 8 > UInt512
512-bit unsigned integer used for private and packed public keys.
Definition numeric.hpp:821
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Definition error.hpp:99
std::vector< unsigned char > Bytes
Dynamically sized byte string used for messages, serialized witnesses, and proofs.
Definition common.hpp:99
static constexpr std::size_t kSerializedSize
ConstructionReceiptSetupEntry(RecoveryRootShare recovery_share, bppp::ScalarBytes precommitment)
ResolvedConstructionReceiptEntry(AnchorReference reference, UInt512 root, AnchorPunishmentPublicKey punishment, AnchorEscrowContextDigest context)