arbitration

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Kind 10/11 buyer custody retrieval under the unified wire model. A Kind 10 carries the buyer-signed content_retrieval_request_cbor = [arbitration_claim_id, retrieval_nonce]. A Kind 11 is an explicitly discriminated two-branch union signed by the arbiter through the unified SignWireDocument(1, 11, ...) helper: branch 0 answers "currently unavailable" with a structured reason and no attachment; branch 1 binds the exact content_payloads_cbor through its SHA-256 content_payloads_id and attaches the payloads verbatim. No embedded Kind 8/9 bytes exist anymore.

Package arbitration 是 007/008 的纯领域包:Kind 8/9 托管证据、Kind 10/11 取回报文的 DTO、确定性编解码、证据链验证与取回结果验证。它不持有任何角色 身份或签名能力;角色编排位于 arbiter/buyer/seller 包,签名一律经受约束 protocol.Signer 进入。

Kind 9 是硬切换后的四元回执应答:仲裁方获得一笔由调用方显式决定的正数 仲裁费,回执通过一次普通消息签名把 Claim ID、该费用与仲裁交易签名绑定为 单一真值;arbitration_claim_id = SHA-256(exact claim cbor)。

Index

Constants

View Source
const (

	// RetrievalNonceBytes is the fixed width of the replay key. 默认入口由
	// SDK 用 crypto/rand 经 protocol.GenerateRetrievalNonce 生成;显式 nonce
	// 的底层入口只服务测试与恢复路径。
	RetrievalNonceBytes = sha256.Size

	// MinContentRetrievalSignatureBytes is the lower bound of the DER buyer
	// retrieval signature child.
	MinContentRetrievalSignatureBytes = 1

	// MaxContentRetrievalRequestBytes is derived from the four-element wire
	// shape [1, 10, request_cbor(3+69), signature(3+256)]:
	// 1 + 1 + 1 + 72 + 259 = 334 bytes.
	MaxContentRetrievalRequestBytes = 1 + 1 + 1 + maxSignatureBstrOverhead + maxContentRetrievalRequestDocBytes + maxSignatureBstrOverhead + MaxArbitrationSignatureBytes

	// MaxContentRetrievalUnavailableBytes is the fixed upper size of the
	// unavailable branch [1, 11, result(3+70), signature(3+256)] = 335.
	MaxContentRetrievalUnavailableBytes = 1 + 1 + 1 + maxSignatureBstrOverhead + maxContentRetrievalResultDocBytes + maxSignatureBstrOverhead + MaxArbitrationSignatureBytes

	// MaxContentRetrievalAvailableBytes is derived from the five-element
	// available branch shape [1, 11, result(3+70), signature(3+256),
	// payloads(uint32 head + bundle)]. It is not an independent quota.
	MaxContentRetrievalAvailableBytes = 1 + 1 + 1 + maxSignatureBstrOverhead + maxContentRetrievalResultDocBytes + maxSignatureBstrOverhead + MaxArbitrationSignatureBytes + 5 + content.MaxContentPayloadsCBORBytes

	// MaxContentRetrievalResponseBytes is the single pre-allocation guard used
	// before the branch discriminator is known; the unavailable branch is
	// strictly smaller than the available one.
	MaxContentRetrievalResponseBytes = MaxContentRetrievalAvailableBytes
)
View Source
const (

	// These are protocol limits, applied before CBOR decoding. They bound both
	// the outer messages and the large bstr children that a decoder would
	// otherwise allocate before semantic validation. Applications may impose
	// smaller transport limits, but must not silently raise these limits.
	MaxArbitrationSignatureBytes      = 256
	MaxArbitrationRefundTemplateBytes = 16 * 1024
	MaxArbitrationAuthorizationBytes  = 16 * 1024
	MaxArbitrationClaimBytes          = 64 * 1024

	// MaxArbitrationReceiptBytes is derived from the Receipt child limits:
	// [claim_id(34), amount(9), transaction_signature(3+256)] plus the array
	// head = 1 + 34 + 9 + 259 = 303. It is intentionally NOT an independent
	// quota; raising it silently or shrinking it below the child limits breaks
	// interoperability.
	MaxArbitrationReceiptBytes = 1 + maxClaimIDBstrBytes + maxDeterministicUint64Bytes + maxSignatureBstrOverhead + MaxArbitrationSignatureBytes

	// MaxArbitrationResponseBytes is derived from the four-element response
	// shape [1, 9, receipt_cbor, receipt_signature]: array head, version,
	// kind, the receipt wrapped in a uint16-headed bstr, and the receipt
	// signature = 1 + 1 + 1 + (3 + 303) + (3 + 256) = 568.
	MaxArbitrationResponseBytes = 1 + 1 + 1 + maxSignatureBstrOverhead + MaxArbitrationReceiptBytes + maxSignatureBstrOverhead + MaxArbitrationSignatureBytes
)

Kind 8/9 的统一 wire Kind 值;版本只使用 protocol.WireVersion。

View Source
const MaxArbitrationRequestBytes = contentMaxPayloadsLimit + MaxArbitrationClaimBytes + MaxArbitrationSignatureBytes + maxArbitrationRequestEnvelopeBytes

MaxArbitrationRequestBytes 是 Kind 8 外层报文的完整 wire 字节上限: payload 上限 + Claim 上限 + 签名上限 + 固定外壳开销。它是公开常量, wire 层全局解析上限必须以它为下界之一,否则合法满载 Kind 8 会在进入 typed decoder 之前被误判为 malformed_wire。

Variables

This section is empty.

Functions

func ArbitrationClaimID

func ArbitrationClaimID(claimCBOR []byte) (protocol.ArbitrationClaimID, error)

ArbitrationClaimID returns SHA-256(exact_claim_cbor) as the typed Kind 8 document identity. The Claim document is the sole ID source; no signing-domain wrapper participates in the identity.

func AuthenticateContentRetrievalRequest

func AuthenticateContentRetrievalRequest(retrievalRequest *ContentRetrievalRequest, storedArbitrationRequest *ArbitrationRequest, arbiterPublicKey []byte) error

AuthenticateContentRetrievalRequest 只依赖已持久化的 Kind 8 完成 Buyer 鉴权, 不要求 Kind 9 已存在。它是时间无关纯函数:先从 Claim 的资金池锁定脚本恢复 角色公钥,确认 Claim 归属目标 Arbiter 公钥,再通过统一 helper 验证 Buyer 对 精确 content_retrieval_request_cbor 的签名。任何其他 Claim ID、nonce 或 Kind 域下的有效签名都不可能通过。

func DecodeContentRetrievalRequestDocument

func DecodeContentRetrievalRequestDocument(data []byte) (protocol.ArbitrationClaimID, []byte, error)

DecodeContentRetrievalRequestDocument strictly decodes the child document and returns deep copies of its Claim ID and nonce.

func EncodeContentRetrievalRequestDocument

func EncodeContentRetrievalRequestDocument(claimID protocol.ArbitrationClaimID, nonce []byte) ([]byte, error)

EncodeContentRetrievalRequestDocument returns the exact canonical child document [arbitration_claim_id, retrieval_nonce] after enforcing both field constraints.

func EncodeContentRetrievalResultDocument

func EncodeContentRetrievalResultDocument(requestID protocol.ContentRetrievalRequestID, result ContentRetrievalResult, branchValue []byte) ([]byte, error)

EncodeContentRetrievalResultDocument builds the exact canonical content_retrieval_result_cbor for either branch. The discriminator decides the meaning of the third element; callers cannot mix branches.

func MarshalClaim

func MarshalClaim(claim *ArbitrationClaim) ([]byte, error)

MarshalClaim encodes the canonical five-element deterministic CBOR child.

func MarshalContentRetrievalRequest

func MarshalContentRetrievalRequest(request *ContentRetrievalRequest) ([]byte, error)

MarshalContentRetrievalRequest encodes the canonical four-element Kind 10.

func MarshalContentRetrievalResponse

func MarshalContentRetrievalResponse(response *ContentRetrievalResponse) ([]byte, error)

MarshalContentRetrievalResponse encodes the canonical Kind 11 for whichever branch ContentRetrievalResultCBOR declares.

func MarshalReceipt

func MarshalReceipt(receipt *ArbitrationReceipt) ([]byte, error)

MarshalReceipt encodes the receipt as the canonical three-element deterministic CBOR child document.

func MarshalRequest

func MarshalRequest(request *ArbitrationRequest) ([]byte, error)

MarshalRequest encodes the complete Kind 8 wire message: [1, 8, claim_cbor, seller_claim_signature, content_payloads_cbor].

func MarshalResponse

func MarshalResponse(response *ArbitrationResponse) ([]byte, error)

MarshalResponse encodes the complete Kind 9 wire message: [1, 9, receipt_cbor, arbiter_receipt_signature].

func ValidateClaim

func ValidateClaim(claim *ArbitrationClaim) error

ValidateClaim validates a decoded arbitration Claim: a positive pool output, the canonical 2-of-3 locking script, bounded refund template and authorization children, and the buyer signature over the exact Kind 5 document. It is pure evidence checking; no fee, deadline, or clock input exists here.

func ValidateContentRetrievalRequest

func ValidateContentRetrievalRequest(request *ContentRetrievalRequest) error

ValidateContentRetrievalRequest enforces the fixed Kind 10 shapes: a canonical 32-byte Claim ID plus non-zero nonce inside the child document, and a bounded DER signature over exactly that document.

func ValidateContentRetrievalResponse

func ValidateContentRetrievalResponse(response *ContentRetrievalResponse) error

ValidateContentRetrievalResponse enforces branch-consistent structure: the discriminator inside ContentRetrievalResultCBOR decides whether an attachment may exist.

func ValidateReceipt

func ValidateReceipt(receipt *ArbitrationReceipt) error

ValidateReceipt validates a decoded arbitration receipt: a fixed 32-byte Claim ID, a positive arbiter amount, and a bounded transaction signature.

func ValidateRequest

func ValidateRequest(request *ArbitrationRequest) error

ValidateRequest enforces the exact five-element Kind 8 shape: bounded Claim child, seller signature, and canonical payload bundle attachment.

func ValidateResponse

func ValidateResponse(response *ArbitrationResponse) error

ValidateResponse enforces the four-element Kind 9 shape: bounded receipt child plus the arbiter unified receipt signature.

func VerifySellerClaimSignature

func VerifySellerClaimSignature(request *ArbitrationRequest, keys pool.MultisigPoolPublicKeys) error

VerifySellerClaimSignature 验证卖方对精确 Claim 文档的统一签名;供角色包 在完整证据链之外复用(例如 seller 仲裁路径的本地证据检查)。

Types

type ArbitrationClaim

type ArbitrationClaim struct {
	// PoolOutputSatoshis 是被托管资金池输出的聪数(uint64);仲裁 candidate
	// 的输入金额必须与它一致。
	PoolOutputSatoshis uint64
	// PoolOutputLockingScript 是角色顺序固定 [Buyer, Seller, Arbiter] 的
	// 2-of-3 压缩公钥锁定脚本(恰好 105 字节);三方公钥由它恢复。
	PoolOutputLockingScript []byte
	// RefundTemplateRaw 是规范未签名退款模板交易的原始字节;到期后买方凭它
	// 广播退款,仲裁方用它派生 refund_template_txid 与保留矿工费。
	RefundTemplateRaw []byte
	// PaymentAuthorizationCBOR 是买方签名的 exact Kind 5 付款授权子文档;
	// 目标序号与绝对卖方金额由此提供,绝不解码重编码。
	PaymentAuthorizationCBOR []byte
	// BuyerPaymentAuthorizationSignature 是买方对 WireSignatureInput(1, 5,
	// payment_authorization_cbor) 的统一消息签名。
	BuyerPaymentAuthorizationSignature []byte
}

ArbitrationClaim is the versionless, kindless inner Kind 8 authentication document. Its exact bytes are both the business truth and the source of the Claim ID: arbitration_claim_id = SHA-256(arbitration_claim_cbor).

func UnmarshalClaim

func UnmarshalClaim(data []byte) (*ArbitrationClaim, error)

UnmarshalClaim strictly decodes Claim bytes: size limit first, strict decode, validation, then deterministic re-encode byte equality.

func ValidateRequestEvidence

validateRequestEvidence performs the complete pre-signature evidence chain: strict Kind 8 decoding, Claim and authorization validation, role recovery, Buyer and Seller signature checks, per-payload hash verification, and independent candidate reconstruction with the explicit arbitration fee. The zero-fee rejection lives in the success builder, so no caller ever passes a placeholder amount. 它是纯证据函数:无时钟、无高度、无签名副作用。

type ArbitrationReceipt

type ArbitrationReceipt struct {
	// ArbitrationClaimID 路由本回执对应的托管记录(SHA-256(exact claim cbor));
	// 必须与验证时重算的 Claim ID 一致。
	ArbitrationClaimID protocol.ArbitrationClaimID
	// ArbiterAmountSatoshis 是分配给 output[2] 的冻结绝对仲裁费(单位
	// satoshi);成功回执恒为正数。
	ArbiterAmountSatoshis uint64
	// ArbiterPaymentTransactionSignature 是仲裁方对独立重建付费 candidate 的
	// ForkID|All 原生交易签名;不能替代回执普通消息签名。
	ArbiterPaymentTransactionSignature []byte
}

ArbitrationReceipt is the versionless, kindless inner Kind 9 document. It binds the exact Claim ID, the absolute arbiter fee paid by output[2], and the ForkID|All transaction signature over the independently rebuilt candidate. A successful receipt always carries a positive fee.

func UnmarshalReceipt

func UnmarshalReceipt(data []byte) (*ArbitrationReceipt, error)

UnmarshalReceipt strictly decodes receipt bytes: size limit first, strict decode, validation, then deterministic re-encode byte equality.

type ArbitrationRequest

type ArbitrationRequest struct {
	// ArbitrationClaimCBOR 是 exact 确定性 Claim 子文档字节;wire 不解码重编码,
	// arbitration_claim_id = SHA-256(该字段)。
	ArbitrationClaimCBOR []byte
	// SellerArbitrationClaimSignature 是卖方对 WireSignatureInput(1, 8,
	// arbitration_claim_cbor) 的统一消息签名;payload 不直接入签。
	SellerArbitrationClaimSignature []byte
	// ContentPayloadsCBOR 是确定性 CBOR payload 批次(attachment):顺序与
	// 授权哈希一一对应,经买方已签 content_hashes_cbor 间接绑定。
	ContentPayloadsCBOR []byte
}

ArbitrationRequest is the exact five-element Kind 8 message. ArbitrationClaimCBOR is the exact deterministic ArbitrationClaim child document; it is not decoded and re-encoded on the wire.

func CloneRequest

func CloneRequest(request *ArbitrationRequest) *ArbitrationRequest

CloneRequest 返回深拷贝的 Kind 8 请求(跨包防御性复制边界)。

func UnmarshalRequest

func UnmarshalRequest(data []byte) (*ArbitrationRequest, error)

UnmarshalRequest strictly decodes Kind 8 bytes: size limit first, strict decode, outer version/kind checks, validation, then deterministic re-encode byte equality.

type ArbitrationResponse

type ArbitrationResponse struct {
	// ArbitrationReceiptCBOR 是 exact 确定性回执子文档字节;wire 不解码重编码。
	ArbitrationReceiptCBOR []byte
	// ArbiterArbitrationReceiptSignature 是仲裁方对 WireSignatureInput(1, 9,
	// arbitration_receipt_cbor) 的统一消息签名,把 Claim ID、费用和交易签名绑定在一起。
	ArbiterArbitrationReceiptSignature []byte
}

ArbitrationResponse is the exact four-element Kind 9 message. ArbitrationReceiptCBOR is the exact deterministic ArbitrationReceipt child document; it is not decoded and re-encoded on the wire.

func CloneResponse

func CloneResponse(response *ArbitrationResponse) *ArbitrationResponse

CloneResponse 返回深拷贝的 Kind 9 应答(跨包防御性复制边界)。

func UnmarshalResponse

func UnmarshalResponse(data []byte) (*ArbitrationResponse, error)

UnmarshalResponse strictly decodes Kind 9 bytes: size limit first, strict decode, outer version/kind checks, validation, then deterministic re-encode byte equality.

type BuiltClaim

type BuiltClaim struct {
	// Claim 是 ArbitrationClaimCBOR 背后的已解码、深拷贝 Claim 证据。
	Claim *ArbitrationClaim
	// ArbitrationClaimCBOR 是精确规范的五元 Claim 子文档字节。
	ArbitrationClaimCBOR []byte
	// ArbitrationClaimID = SHA-256(exact_claim_cbor),Seller 与 Buyer 独立重建必得同一值。
	ArbitrationClaimID protocol.ArbitrationClaimID
	// Authorization 是 Claim 携带的已解码 Kind 5 付款授权(含目标序号与绝对卖方金额)。
	Authorization *content.PaymentAuthorization
}

BuiltClaim is the shared, time-independent result of assembling the exact Kind 8 Claim evidence from a complete OpeningProof and the Buyer-signed payment authorization. Seller arbitration (007) and buyer content retrieval (008) both consume this single builder so both roles always derive byte-identical ArbitrationClaimCBOR and ArbitrationClaimID from the same opening plus authorization.

func BuildClaimFromAuthorization

func BuildClaimFromAuthorization(opening *pool.OpeningProof, signedAuthorization *content.SignedContentRequest) (*BuiltClaim, error)

BuildClaimFromAuthorization derives the pool output facts from the supplied OpeningProof, verifies that the signed payment authorization belongs to that exact opening, assembles and canonically encodes the Claim, and computes its Claim ID. It clones every input, applies no clock or block-height gate, and produces no signature; deadline/refund gates remain with the calling workflows.

type ContentRetrievalRequest

type ContentRetrievalRequest struct {
	// ContentRetrievalRequestCBOR 是 exact 规范子文档
	// [arbitration_claim_id, retrieval_nonce];它是买方唯一签署的对象,
	// 其 SHA-256 即 content_retrieval_request_id。
	ContentRetrievalRequestCBOR []byte
	// BuyerContentRetrievalRequestSignature 是买方对 WireSignatureInput(1, 10,
	// content_retrieval_request_cbor) 的统一消息签名。
	BuyerContentRetrievalRequestSignature []byte
}

ContentRetrievalRequest is the exact four-element Kind 10 message. It carries no Buyer public key, OpeningProof, payment authorization, Claim bytes, or payment authorization ID: the arbiter recovers every role key from the stored Claim named by the Claim ID inside ContentRetrievalRequestCBOR.

func CloneContentRetrievalRequest

func CloneContentRetrievalRequest(request *ContentRetrievalRequest) *ContentRetrievalRequest

CloneContentRetrievalRequest 返回深拷贝的 Kind 10(跨包防御性复制边界)。

func NewContentRetrievalRequest

func NewContentRetrievalRequest(ctx context.Context, claimID protocol.ArbitrationClaimID, nonce protocol.RetrievalNonce, signer protocol.Signer) (*ContentRetrievalRequest, error)

NewContentRetrievalRequest builds and signs a complete Kind 10 through the unified SignWireDocument(1, 10, ...) helper with the supplied constrained Signer and self-verifies the result. 这是显式 nonce 的底层入口:nonce 必须是 SDK 生成的 typed 随机数(测试/恢复路径);普通角色 API 不接受任意 []byte。

func UnmarshalContentRetrievalRequest

func UnmarshalContentRetrievalRequest(data []byte) (*ContentRetrievalRequest, error)

UnmarshalContentRetrievalRequest strictly decodes Kind 10 bytes: size limit, strict shape, version/kind checks, validation, then deterministic round-trip equality.

type ContentRetrievalResponse

type ContentRetrievalResponse struct {
	// ContentRetrievalResultCBOR 是 exact 规范结果子文档
	// [content_retrieval_request_id, result, branch_value];判别值决定外层形状。
	ContentRetrievalResultCBOR []byte
	// ArbiterContentRetrievalResultSignature 是仲裁方对 WireSignatureInput(1, 11,
	// content_retrieval_result_cbor) 的统一消息签名(两分支同域)。
	ArbiterContentRetrievalResultSignature []byte
	// ContentPayloadsCBOR 仅 available 分支存在:exact content_payloads_cbor
	// attachment,经签名的 content_payloads_id 绑定;unavailable 分支禁止携带。
	ContentPayloadsCBOR []byte
}

ContentRetrievalResponse is the exact Kind 11 message. The discriminator inside ContentRetrievalResultCBOR selects the only legal outer shape:

unavailable: [1, 11, result_cbor, signature]
available:   [1, 11, result_cbor, signature, content_payloads_cbor]

func BuildContentRetrievalAvailable

func BuildContentRetrievalAvailable(ctx context.Context, requestID protocol.ContentRetrievalRequestID, payloads [][]byte, signer protocol.Signer) (*ContentRetrievalResponse, error)

BuildContentRetrievalAvailable constructs and signs the positive Kind 11 branch. The payload bundle is canonically encoded here so the signed content_payloads_id always binds the exact attached bytes.

func BuildContentRetrievalAvailableRaw

func BuildContentRetrievalAvailableRaw(ctx context.Context, requestID protocol.ContentRetrievalRequestID, payloadsCBOR []byte, signer protocol.Signer) (*ContentRetrievalResponse, error)

BuildContentRetrievalAvailableRaw is the raw-bytes variant of BuildContentRetrievalAvailable for applications that persist the exact canonical payload bundle. The bundle must already be canonical.

func BuildContentRetrievalUnavailable

func BuildContentRetrievalUnavailable(ctx context.Context, requestID protocol.ContentRetrievalRequestID, reason ContentRetrievalUnavailableReason, signer protocol.Signer) (*ContentRetrievalResponse, error)

BuildContentRetrievalUnavailable constructs and signs the negative Kind 11 branch through the supplied constrained Signer. The caller supplies only the structurally valid request ID and the honest reason; the signed response carries no Claim, role key, payload, or record metadata.

func CloneContentRetrievalResponse

func CloneContentRetrievalResponse(response *ContentRetrievalResponse) *ContentRetrievalResponse

CloneContentRetrievalResponse 返回深拷贝的 Kind 11(跨包防御性复制边界)。

func UnmarshalContentRetrievalResponse

func UnmarshalContentRetrievalResponse(data []byte) (*ContentRetrievalResponse, error)

UnmarshalContentRetrievalResponse strictly decodes Kind 11 bytes. It checks the size limit first, then the outer version/kind pair, then reads the branch discriminator from ContentRetrievalResultCBOR before accepting the unique outer length for that branch. Any mismatch, trailing field, unknown reason, or non-canonical encoding is rejected.

type ContentRetrievalResult

type ContentRetrievalResult uint64

ContentRetrievalResult discriminates the two Kind 11 branches.

const (
	// ContentRetrievalUnavailable: the arbiter currently cannot deliver the
	// custodied content to this buyer.
	ContentRetrievalUnavailable ContentRetrievalResult = 0
	// ContentRetrievalAvailable: the arbiter completed the internal state
	// transition required for retrieval and attached the payloads.
	ContentRetrievalAvailable ContentRetrievalResult = 1
)

type ContentRetrievalUnavailableReason

type ContentRetrievalUnavailableReason uint64

ContentRetrievalUnavailableReason enumerates the three honest reasons a Kind 11 unavailable branch can carry.

const (
	// RetrievalSellerArbitrationNotReceived: no Kind 8 custody record exists
	// for this Claim ID.
	RetrievalSellerArbitrationNotReceived ContentRetrievalUnavailableReason = 0
	// RetrievalSellerArbitrationNotReady: the Kind 8 record exists and is
	// persisted, but the Kind 9 receipt has not been completed.
	RetrievalSellerArbitrationNotReady ContentRetrievalUnavailableReason = 1
	// RetrievalCustodyGone: a complete custody record existed but the content
	// was deleted under the public retention policy.
	RetrievalCustodyGone ContentRetrievalUnavailableReason = 2
)

type DecodedContentRetrievalResult

type DecodedContentRetrievalResult struct {
	// ContentRetrievalRequestID 必须等于 SHA-256(exact Kind 10 请求文档),绑定本应答对应的请求。
	ContentRetrievalRequestID protocol.ContentRetrievalRequestID
	// Result 是分支判别值:0 unavailable / 1 available;未知值在严格解码时拒绝。
	Result ContentRetrievalResult
	// UnavailableReason 仅 Result == unavailable 时有意义:
	// 0 seller_arbitration_not_received / 1 not_ready / 2 custody_gone。
	UnavailableReason ContentRetrievalUnavailableReason
	// ContentPayloadsID 仅 Result == available 时有意义:
	// SHA-256(exact content_payloads_cbor),逐字节绑定附件批次。
	ContentPayloadsID protocol.ContentPayloadsID
}

DecodedContentRetrievalResult is the typed view of a strictly decoded content_retrieval_result_cbor.

func DecodeContentRetrievalResultDocument

func DecodeContentRetrievalResultDocument(data []byte) (*DecodedContentRetrievalResult, error)

DecodeContentRetrievalResultDocument strictly decodes a content_retrieval_result_cbor. The discriminator is read before anything else; unknown results and wrong shapes are rejected without presence guessing.

type VerifiedContentRetrievalResult

type VerifiedContentRetrievalResult struct {
	// ContentRetrievalRequestID 是已验证绑定的请求 ID(等于买方请求文档哈希)。
	ContentRetrievalRequestID protocol.ContentRetrievalRequestID
	// Available 报告分支结果:true 为可交付;false 表示 unavailable 分支,
	// 此时 Payloads/PayloadsCBOR 均为空且不产生任何付款状态变化。valid
	// unavailable 是协议结果,不是 transport/parser error。
	Available bool
	// UnavailableReason 仅 Available == false 时有意义:仲裁方给出的诚实原因,
	// 应用据此决定生成新 nonce、等待或终止。
	UnavailableReason ContentRetrievalUnavailableReason
	// PayloadsCBOR 是 exact content_payloads_cbor 字节;仅 available 分支非空。
	PayloadsCBOR []byte
	// Payloads 是按授权顺序深拷贝的 payload 内容;仅 available 分支非空。
	Payloads [][]byte
}

VerifiedContentRetrievalResult is the deep-copied outcome of verifying one Kind 11 against the exact Kind 10 it answers.

func VerifyContentRetrievalResponse

func VerifyContentRetrievalResponse(request *ContentRetrievalRequest, arbiterPublicKey []byte, response *ContentRetrievalResponse) (*VerifiedContentRetrievalResult, error)

VerifyContentRetrievalResponse verifies one Kind 11 against the exact Kind 10 request it answers: the signed request ID must equal SHA-256(exact_request_cbor), the arbiter signature must verify through the unified helper over the exact result document, and the available branch must additionally bind its payload attachment through content_payloads_id. It performs no clock read and no payment state change. valid unavailable 作为 已验签协议结果返回(Available=false),绝不作为普通 error。

type VerifiedCustodiedContent

type VerifiedCustodiedContent struct {
	// ArbitrationClaimID 是重算并与回执比对一致的托管 Claim 身份。
	ArbitrationClaimID protocol.ArbitrationClaimID
	// PayloadsCBOR 是从托管 Kind 8 证据字节派生的唯一 payload 真值。
	PayloadsCBOR []byte
	// Payloads 是按授权顺序深拷贝的 payload 内容。
	Payloads [][]byte
	// Receipt 是已验证的 Kind 9 回执(Claim ID、正费用与交易签名绑定)。
	Receipt *ArbitrationReceipt
	// Request 是存储的 exact Kind 8 证据(深拷贝,只读使用)。
	Request *ArbitrationRequest
	// Response 是存储的 exact Kind 9 证据(深拷贝,只读使用)。
	Response *ArbitrationResponse
}

VerifiedCustodiedContent is the deep-copied result of fully verifying one stored custody record pair (Kind 8 + Kind 9). It is time-independent: expired deadlines or matured refunds never invalidate already signed custody evidence that is still inside its application retention window.

func VerifyCustodiedContent

func VerifyCustodiedContent(arbitrationRequest *ArbitrationRequest, arbitrationResponse *ArbitrationResponse) (*VerifiedCustodiedContent, error)

VerifyCustodiedContent performs the complete time-independent custody evidence verification over one stored record pair: strict decoding of both messages, Seller Claim signature, Buyer authorization signature, payload count, order, and hashes, Claim ID recomputation against the Receipt, Arbiter receipt signature, candidate rebuild with the Receipt fee, and Arbiter transaction signature. Applications use it while deciding which Kind 11 branch a stored record supports. It never reads the clock and never applies deadline or refund-maturity gates: those were enforced before Kind 9 was signed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL