28Unexpected<Error> load_error(
33 "construction_parent:artifact_path");
36 "construction_parent:artifact_open");
39 "construction_parent:artifact_identity");
42 "construction_parent:artifact_snapshot");
48 "construction_parent:artifact_backend");
51 "construction_parent:artifact_status");
54Unexpected<Error> verify_error(
59 "construction_parent:malformed");
62 "construction_parent:proof");
70 "construction_parent:backend");
73 "construction_parent:status");
90 std::unique_ptr<Impl> impl)
91 : impl_(std::move(impl)) {}
103 std::
size_t anchor_index,
105 if (entries_.size() != resolved_entries_.size() ||
106 entries_.size() != anchor_count_) {
107 return unexpected_error(ErrorCode::InternalMismatch,
108 "construction_parent:receipt_entries");
110 if (anchor_index >= entries_.size()) {
111 return unexpected_error(ErrorCode::IndexOutOfRange,
112 "construction_parent:anchor_index");
115 const auto& recipient,
117 roster_, aggregate_, exposed_signing_scalar, secp_context),
118 "construction_parent:recover_recipient");
119 const auto& entry = entries_[anchor_index];
120 const auto& resolved = resolved_entries_[anchor_index];
122 recipient, resolved.punishment_key, entry.ciphertext,
127 std::string_view artifact_path) {
128 if (artifact_path.empty() ||
129 artifact_path.find(
'\0') != std::string_view::npos) {
131 "construction_parent:artifact_path");
135 reinterpret_cast<const std::uint8_t*
>(artifact_path.data()),
138 return load_error(status);
142 "construction_parent:artifact_owner");
151 std::span<const ResolvedConstructionReceiptEntry> resolved_entries,
154 if (!impl_ || impl_->verifier ==
nullptr) {
156 "construction_parent:verifier");
159 const auto& payload = envelope.
payload();
164 setup, payload, resolved_entries, leaves, secp_context),
165 "construction_parent:public_inputs");
166 std::array<
unsigned char,
169 const auto& basis_digest = leaves.
basis().
digest();
173 impl_->verifier, inputs.statement_digest.data(),
175 basis_digest.data(), inputs.raw_generator_digest.data(),
176 inputs.setup_count, inputs.anchor_count, inputs.descriptors.data(),
177 inputs.descriptors.size(), proof.data(), proof.size(),
178 pending_root.data(), pending_root.size());
180 return verify_error(status);
186 leaves.
basis(), pending_root, secp_context),
187 "construction_parent:parse_root");
190 leaves.
basis(), final_claim, secp_context),
191 "construction_parent:decide");
193 inputs.statement_digest, setup.
roster(),
194 std::move(inputs.aggregate),
195 std::vector<ConstructionReceiptAnchorEntry>(
196 anchor_entries.begin(), anchor_entries.end()),
197 std::vector<ResolvedConstructionReceiptEntry>(
198 resolved_entries.begin(), resolved_entries.end()));
Field element modulo the backend scalar field used by this implementation.
const bppp::accumulation::Basis & basis() const noexcept
ConstructionParentVerifier(const ConstructionParentVerifier &)=delete
Result< VerifiedConstructionReceipt > verify(const ResolvedConstructionSetup &setup, const ConstructionReceiptEnvelope &envelope, std::span< const ResolvedConstructionReceiptEntry > resolved_entries, const ConstructionLeafAccumulator &leaves, purify_secp_context *secp_context) const
static Result< ConstructionParentVerifier > load(std::string_view artifact_path)
static constexpr std::size_t kRootClaimSerializedSize
const Bytes & parent_proof() const noexcept
const ConstructionReceiptPayload & payload() const noexcept
static constexpr std::size_t kParentProofSize
std::span< const ConstructionReceiptAnchorEntry > anchor_entries() const noexcept
const ResolvedConstructionSetupDigestBytes & bytes() const noexcept
const ResolvedConstructionSetupDigest & resolved_digest() const noexcept
const UInt512 & recovery_root() const noexcept
const NonceHostBoundSigningRoster & roster() const noexcept
Result< AnchorPunishmentKey > recover_anchor(const FieldElement &exposed_signing_scalar, std::size_t anchor_index, purify_secp_context *secp_context) const
const Digest & digest() const
void purify_construction_parent_verifier_destroy(purify_construction_parent_verifier *verifier)
purify_construction_parent_status purify_construction_parent_verify(const purify_construction_parent_verifier *verifier, const uint8_t construction_statement_digest[32], const uint8_t resolved_setup_record_digest[32], const uint8_t recovery_root[64], const uint8_t native_basis_digest[32], const uint8_t native_raw_generator_digest[32], uint32_t setup_count, uint32_t anchor_count, const uint8_t *leaf_descriptors, size_t leaf_descriptors_length, const uint8_t *proof, size_t proof_length, uint8_t *pending_root_output, size_t pending_root_capacity)
@ PURIFY_CONSTRUCTION_PARENT_ROOT_SIZE
@ PURIFY_CONSTRUCTION_PARENT_DESCRIPTOR_SIZE
@ PURIFY_CONSTRUCTION_PARENT_PROOF_SIZE
struct purify_construction_parent_verifier purify_construction_parent_verifier
purify_construction_parent_status
@ PURIFY_CONSTRUCTION_PARENT_ARTIFACT_SNAPSHOT_FAILED
@ PURIFY_CONSTRUCTION_PARENT_INTERNAL_ERROR
@ PURIFY_CONSTRUCTION_PARENT_ARTIFACT_OPEN_FAILED
@ PURIFY_CONSTRUCTION_PARENT_ARTIFACT_REJECTED
@ PURIFY_CONSTRUCTION_PARENT_OK
@ PURIFY_CONSTRUCTION_PARENT_MALFORMED
@ PURIFY_CONSTRUCTION_PARENT_BUFFER_TOO_SMALL
@ PURIFY_CONSTRUCTION_PARENT_PROOF_REJECTED
purify_construction_parent_status purify_construction_parent_verifier_load(const uint8_t *artifact_path, size_t artifact_path_length, purify_construction_parent_verifier **verifier_output)
Locally verified construction receipts under the selected suite.
#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< GeneratedKey > recover_aggregated_recovery_root(const NonceHostBoundSigningRoster &roster, const RecoveryRootShareAggregate &aggregate, const FieldElement &exposed_signing_scalar, purify_secp_context *secp_context)
Result< AnchorPunishmentKey > recover_authenticated_anchor_ciphertext(const GeneratedKey &recovered_recipient, const AnchorPunishmentPublicKey &punishment_key, const AnchorEscrowCiphertext &ciphertext, purify_secp_context *secp_context)
Result< PendingClaim > parse_root_claim(const Basis &basis, std::span< const unsigned char > encoded, purify_secp_context *context)
Status decide(const Basis &basis, const PendingClaim &claim, purify_secp_context *context)
constexpr Unexpected< Error > unexpected_error(ErrorCode code, const char *context=nullptr)
Constructs an unexpected Error value from a machine-readable code.
Result< std::string > verifier(const Bytes &message, const UInt512 &pubkey)
Builds the legacy serialized verifier description for a message and public key.
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
std::vector< unsigned char > Bytes
Dynamically sized byte string used for messages, serialized witnesses, and proofs.
std::array< unsigned char, Words *8 > to_bytes_be() const
Serializes the value to a fixed-width big-endian byte array.
purify_construction_parent_verifier * verifier
Impl(purify_construction_parent_verifier *verifier_in)