arbiter

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: 12 Imported by: 0

Documentation

Overview

Package arbiter 是 007/008 的 Arbiter 角色 API:持有固定受约束 Signer, 完成"先完整验证并持久化托管证据、再独立重建交易与 digest 后签名"的 Prepare-before-Sign 编排,以及时间无关的 008 取回鉴权/托管验证与 Kind 11 两分支构造。它不拥有存储、网络、节点或业务最新状态;应用负责在 Prepare 与 Sign 之间先持久化 exact 托管证据。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreparedArbitration

type PreparedArbitration struct {
	// contains filtered or unexported fields
}

PreparedArbitration 是 PrepareArbitration 的不透明结果:完整验证通过但尚未 签名的托管证据。所有导出访问都经防御性复制 getter,调用方可以安全地把证据 持久化,却拿不到可变引用去篡改签名输入。它不是 wire 报文,也不携带任何 WireVersion 字段;跨进程恢复必须走 RestorePreparedArbitration 从 exact bytes 全量重验。

func RestorePreparedArbitration

func RestorePreparedArbitration(rawKind8 []byte, fee protocol.Satoshis) (*PreparedArbitration, error)

RestorePreparedArbitration 从应用持久化的 exact 托管证据(exact Kind 8 bytes + 冻结仲裁费)恢复 PreparedArbitration:重新执行完整时间无关证据链 (Claim 结构、买卖双方签名、逐 payload 哈希、按冻结费用独立重建 candidate、 Claim ID/授权 ID/证据承诺全部重算),绝不信任任何持久化派生字段。

与 PrepareArbitration 的差别只有两点:本入口不读取任何事实——deadline 与 refund 门禁在 Prepare 时已执行,SignPreparedArbitration 会用新 Facts 再查 deadline;恢复后的值与 Prepare 产物在相同输入下逐字段一致。

func (*PreparedArbitration) ArbiterPublicKey

func (prepared *PreparedArbitration) ArbiterPublicKey() []byte

ArbiterPublicKey 返回 Claim 锁定脚本中恢复的仲裁方压缩公钥副本。

func (*PreparedArbitration) ArbitrationClaimID

func (prepared *PreparedArbitration) ArbitrationClaimID() protocol.ArbitrationClaimID

ArbitrationClaimID 返回 SHA-256(exact_claim_cbor),Kind 8 文档 typed ID。

func (*PreparedArbitration) Claim

Claim 返回深拷贝的已解码 Claim 证据。

func (*PreparedArbitration) ContentPayloads

func (prepared *PreparedArbitration) ContentPayloads() [][]byte

ContentPayloads 返回按授权顺序深拷贝的 payload 内容。

func (*PreparedArbitration) ContentPayloadsCBOR

func (prepared *PreparedArbitration) ContentPayloadsCBOR() []byte

ContentPayloadsCBOR 返回 exact content_payloads_cbor attachment 字节副本。

func (*PreparedArbitration) DeadlineUnixSeconds

func (prepared *PreparedArbitration) DeadlineUnixSeconds() content.UnixSeconds

DeadlineUnixSeconds 返回买方授权携带的交付截止时间(UTC Unix 秒);是否 已经过期由调用方用自己的显式事实判断。

func (*PreparedArbitration) FeeSatoshis

func (prepared *PreparedArbitration) FeeSatoshis() protocol.Satoshis

FeeSatoshis 返回冻结的绝对仲裁费(output[2] 金额);成功路径恒为正数。

func (*PreparedArbitration) PaymentAuthorizationID

func (prepared *PreparedArbitration) PaymentAuthorizationID() protocol.PaymentAuthorizationID

PaymentAuthorizationID 返回被托管付款授权的 SHA-256 typed ID。

func (*PreparedArbitration) PreparedBelongsTo

func (prepared *PreparedArbitration) PreparedBelongsTo(arbiterPublicKey []byte) bool

PreparedBelongsTo 报告 prepared 托管记录是否归属指定仲裁方压缩公钥。

func (*PreparedArbitration) RefundTemplateTxID

func (prepared *PreparedArbitration) RefundTemplateTxID() []byte

RefundTemplateTxID 返回从退款模板派生的费用池统一关联 ID 副本。

func (*PreparedArbitration) Request

func (prepared *PreparedArbitration) Request() *arbitration.ArbitrationRequest

Request 返回深拷贝的 exact Kind 8 托管请求(含 Claim、卖方签名与 payload attachment)。应用必须先持久化它的 canonical 编码再调用 SignPreparedArbitration。

func (*PreparedArbitration) RequestCBOR

func (prepared *PreparedArbitration) RequestCBOR() ([]byte, error)

RequestCBOR 返回 exact Kind 8 的 canonical wire 字节;发送与持久化都用它。 (PreparedAt 之类的观测元数据由应用连同其 Facts 来源自行保存,不属于可 验证协议证据,因此不在本值上。)

type Workflow

type Workflow struct {
	// contains filtered or unexported fields
}

Workflow 是持有 Arbiter 签名能力的 007/008 角色编排。除固定的 Signer 公钥 外它不持有任何状态;没有持久化、网络、节点或时钟注入点。所有时间/高度 判断使用调用方显式传入的 Facts。

func NewWorkflow

func NewWorkflow(signer protocol.Signer) (*Workflow, error)

NewWorkflow 固定并验证 Signer 公钥后返回角色编排。Signer 公钥在生命周期内 不得变化;后续任何签名返回都会针对该公钥自验。

func (*Workflow) AuthenticateRetrieval

func (workflow *Workflow) AuthenticateRetrieval(rawKind10 []byte, storedKind8 []byte) error

AuthenticateRetrieval 仅完成 Buyer 鉴权,用于 not_ready / gone 分支: 时间无关,不需要 Kind 9 存在。rawKind10 与 storedKind8 都是 exact bytes; 鉴权失败返回 invalid_signature/unauthorized/invalid_evidence 分类错误。

func (*Workflow) BuildAvailableRetrieval

func (workflow *Workflow) BuildAvailableRetrieval(ctx context.Context, requestID protocol.ContentRetrievalRequestID, verifiedCustody *arbitration.VerifiedCustodiedContent) (wire.Artifact, error)

BuildAvailableRetrieval 构造并签署 valid Kind 11 available Artifact,直接 附带经 content_payloads_id 绑定的 verified exact payloads。available 分支 不产生也不携带任何付款凭证。

func (*Workflow) BuildUnavailableRetrieval

func (workflow *Workflow) BuildUnavailableRetrieval(ctx context.Context, requestID protocol.ContentRetrievalRequestID, reason arbitration.ContentRetrievalUnavailableReason) (wire.Artifact, error)

BuildUnavailableRetrieval 构造并签署 valid Kind 11 unavailable Artifact: 只携带结构合法的 request ID 与诚实 reason,无 Claim、无角色公钥、无记录元数据。

func (*Workflow) PrepareArbitration

func (workflow *Workflow) PrepareArbitration(facts protocol.Facts, rawKind8 []byte, fee protocol.Satoshis) (*PreparedArbitration, error)

PrepareArbitration 对 exact Kind 8 托管请求做完整证据验证但绝不签名: Claim 结构、买方授权签名、卖方 Claim 签名、逐 payload 哈希、按显式正仲裁费 独立重建 candidate、Claim 归属本 Arbiter、交付截止未过(Facts.Now)、退款 模板尚未到期(只读取锁定类型对应的事实)。本步骤不签名也无长计算,因此不 接收 context。应用必须在调用 SignPreparedArbitration 之前先持久化 exact 托管证据(PreparedArbitration.RequestCBOR、Claim ID、费用与 payload bundle)。

func (*Workflow) PublicKey

func (workflow *Workflow) PublicKey() []byte

PublicKey 返回本角色的固定压缩公钥副本。

func (*Workflow) SignPreparedArbitration

func (workflow *Workflow) SignPreparedArbitration(ctx context.Context, facts protocol.Facts, prepared *PreparedArbitration) (wire.Artifact, error)

SignPreparedArbitration 是先持久化后的签名步骤:从冻结的 exact Kind 8 字节 独立重建交易与 digest,重新比较 Claim ID、费用、角色、deadline(用本次 显式 Facts.Now)与 candidate,然后按固定顺序签名——先仲裁交易签名,再编码 回执,最后生成并自验统一回执消息签名。绝不信任缓存的 mutable candidate。

func (*Workflow) VerifyRetrievableCustody

func (workflow *Workflow) VerifyRetrievableCustody(rawKind10 []byte, storedKind8 []byte, storedKind9 []byte) (*arbitration.VerifiedCustodiedContent, error)

VerifyRetrievableCustody 对完整托管证据(exact Kind 8 + exact Kind 9)做 时间无关全量验证,再鉴权 exact Kind 10,最后返回 verified custody/payload。 过期的 deadline 或已到期的退款锁定不会拒绝仍在保留窗口内的已签托管证据。

Jump to

Keyboard shortcuts

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