14template <std::
size_t N>
15void append(std::vector<unsigned char>& output,
16 const std::array<unsigned char, N>& bytes) {
17 output.insert(output.end(), bytes.begin(), bytes.end());
21 std::vector<unsigned char>& descriptors,
24 std::array<unsigned char, 32>& raw_generator_digest,
25 bool& have_raw_generator_digest) {
26 if (have_raw_generator_digest &&
30 "construction_parent:raw_generator_digest");
33 have_raw_generator_digest =
true;
35 append(descriptors, circuit_precommitment);
47 std::span<const ResolvedConstructionReceiptEntry> resolved_entries,
52 "construction_parent:recovery_root");
56 if (setup_entries.size() != setup.
roster().
members().size()) {
58 "construction_parent:setup_count");
63 "construction_parent:leaf_count");
66 std::vector<RecoveryRootShare> setup_shares;
67 setup_shares.reserve(setup_entries.size());
68 for (
const auto& entry : setup_entries) {
69 setup_shares.push_back(entry.share);
74 "construction_parent:setup_aggregate");
77 "construction_parent:setup_root");
80 auto statement_digest,
83 "construction_parent:statement");
85 std::size_t leaf_count = 0;
89 std::numeric_limits<std::size_t>::max() /
92 "construction_parent:descriptors");
94 std::vector<unsigned char> descriptors;
96 std::array<unsigned char, 32> raw_generator_digest{};
97 bool have_raw_generator_digest =
false;
99 for (std::size_t index = 0; index < setup_entries.size(); ++index) {
100 const auto& entry = setup_entries[index];
105 entry.circuit_precommitment, secp_context),
106 "construction_parent:setup_constants");
108 append_constants(descriptors, constants,
109 entry.circuit_precommitment,
110 raw_generator_digest,
111 have_raw_generator_digest),
112 "construction_parent:setup_descriptor");
114 for (std::size_t index = 0; index < anchor_entries.size(); ++index) {
115 const auto& resolved = resolved_entries[index];
116 const auto& entry = anchor_entries[index];
121 resolved.anchor_root, resolved.punishment_key,
122 resolved.context_digest, entry.ciphertext,
123 entry.circuit_precommitment, secp_context),
124 "construction_parent:anchor_constants");
126 append_constants(descriptors, constants,
127 entry.circuit_precommitment,
128 raw_generator_digest,
129 have_raw_generator_digest),
130 "construction_parent:anchor_descriptor");
135 std::move(aggregate),
136 std::move(descriptors),
137 raw_generator_digest,
138 static_cast<std::uint32_t
>(setup_entries.size()),
139 static_cast<std::uint32_t
>(anchor_entries.size())};
Result< ConstructionLeafParentConstants > derive_parent_constants(const RecoveryBoundSigningRoster &roster, const UInt512 &advertised_anchor_root, const AnchorPunishmentPublicKey &punishment_key, const AnchorEscrowContextDigest &context_digest, const AnchorEscrowCiphertext &ciphertext, const bppp::ScalarBytes &circuit_precommitment, purify_secp_context *secp_context) const
Result< ConstructionLeafParentConstants > derive_pending_anchor_parent_constants(const NonceHostBoundSigningRoster &roster, const UInt512 &recovery_root, const UInt512 &advertised_anchor_root, const AnchorPunishmentPublicKey &punishment_key, const AnchorEscrowContextDigest &context_digest, const AnchorEscrowCiphertext &ciphertext, const bppp::ScalarBytes &circuit_precommitment, purify_secp_context *secp_context) const
Canonical public payload for a coalition construction receipt.
std::span< const ConstructionReceiptSetupEntry > setup_entries() const noexcept
std::span< const ConstructionReceiptAnchorEntry > anchor_entries() const noexcept
const UInt512 & recovery_root() const noexcept
std::span< const SigningRosterMember > members() const
const ResolvedConstructionSetupDigest & resolved_digest() const noexcept
const UInt512 & recovery_root() const noexcept
const NonceHostBoundSigningRoster & roster() const noexcept
const CoalitionFormation & formation() const noexcept
#define PURIFY_RETURN_IF_ERROR(expr, context)
Evaluates an expected-like expression and returns the wrapped error on failure.
#define PURIFY_ASSIGN_OR_RETURN(lhs, expr, context)
Evaluates an expected-like expression, binds the value to lhs, and propagates errors.
constexpr std::size_t kConstructionParentDescriptorSize
Result< ResolvedConstructionParentPublicInputs > resolve_construction_parent_public_inputs(const ResolvedConstructionSetup &setup, const ConstructionReceiptPayload &payload, std::span< const ResolvedConstructionReceiptEntry > resolved_entries, const ConstructionLeafAccumulator &leaves, purify_secp_context *secp_context)
Result< RecoveryRootShareAggregate > aggregate_recovery_root_shares(std::span< const RecoveryRootShare > ordered_shares)
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 > ScalarBytes
Big-endian 32-byte scalar encoding.
constexpr Unexpected< Error > unexpected_error(ErrorCode code, const char *context=nullptr)
Constructs an unexpected Error value from a machine-readable code.
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Expected< void, Error > Status
Expected-returning convenience alias for Purify status-only APIs.
bool size_fits_u32(std::size_t value) noexcept
bool checked_add_size(std::size_t lhs, std::size_t rhs, std::size_t &out) noexcept
std::array< unsigned char, 32 > circuit_binding_digest
bppp::PointBytes anchored_offset
std::array< unsigned char, 32 > raw_generator_digest
bppp::PointBytes coefficient_commitment