Skip to content

feat(rfq): validate final settlement PSETs - #30

Merged
tvolk131 merged 1 commit into
codex/rfq-quote-enginefrom
codex/rfq-settlement-validator
Aug 19, 2026
Merged

feat(rfq): validate final settlement PSETs#30
tvolk131 merged 1 commit into
codex/rfq-quote-enginefrom
codex/rfq-settlement-validator

Conversation

@tvolk131

@tvolk131 tvolk131 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a provider-side validator for a complete blinded, taker-signed Liquid PSET before the irreversible signing transition
  • derive authority from the persisted firm quote, authenticated reservation, durable wallet targets, authoritative unspent prevouts, and provider-controlled output recovery
  • locate the RFQ leg inside a larger transaction through an injective symbolic layout without assuming fixed input or output indexes
  • verify canonical bounded PSET structure, finalized taker P2TR SIGHASH_ALL signatures, unsigned provider inputs, confidential disclosures and proofs, whole-transaction balance, provider receive/change recovery, and one exact policy-asset fee output
  • project the missing provider witnesses to derive regular and discounted size metrics, then enforce the quote's frozen fee and maximum-weight policy
  • make an opaque non-cloneable ValidatedSigningIntent the only production capability that can cross commit-before-sign
  • recognize exact committed and signed retries from durable state before live chain or wallet calls
  • document the initial one-provider/P2TR profile and the unavoidable availability risk from a taker conflict-spending its own input after the final chain observation

Why

PR #29 constructs and durably reserves an inventory-aware FirmQuote, but the provider still needed a concrete authority boundary for the complete transaction returned by the taker. This PR closes that boundary: detached caller assertions cannot choose the signing payload or fee facts, and the wallet/HSM can only be invoked after exact validated bytes have crossed the durable point of no return.

Validation itself remains reversible. The eventual service should validate and commit synchronously; the commit atomically rechecks provider identity, authenticated owner, quote commitment, exclusive deadline, fee policy, and every reserved allocation before it returns a durable signing job.

Safety properties

  • raw bytes are size-bounded before PSET decoding and only one strict canonical representation is accepted
  • every input is bound to an ordered authoritative unspent prevout from the provider's configured chain
  • every non-provider input must already carry a valid tree-less P2TR key-path explicit-SIGHASH_ALL signature over the complete transaction and all prevouts
  • every provider input must match its persisted quote/inventory/signing target and remain unsigned
  • issuance, peg-ins, nonfinal sequences, locktimes, mutable PSETs, unsupported metadata, duplicate inputs, and aliased role mappings fail closed
  • ordinary outputs require confidential commitments plus valid disclosure, range, and surjection proofs; the complete transaction must balance
  • provider payment and change outputs must resolve through durable wallet locators to the expected spend keys and confidential openings
  • the fee policy uses the projected final provider witnesses rather than an underweight pre-sign transaction
  • dropping a validated intent performs no mutation; cancellation or expiry can still win before commit
  • after commitment, only the exact canonical payload replays, including after restart or after its inputs have been spent

Deliberate V1 scope

The validator supports one interactive RFQ provider plus already-finalized tree-less P2TR wallet inputs. It does not yet execute Simplicity covenant witnesses or coordinate a second interactive RFQ signer. Those require a later authenticated venue/script-verification seam.

Concrete wallet/RPC/HSM adapters, signer/finalizer orchestration, authenticated networking, production pricing, relay, and chain reconciliation remain follow-up work.

Stack

This is intentionally stacked on #29 and targets codex/rfq-quote-engine. Once #29 merges, this PR can be retargeted to master.

Validation

  • nix develop .#default --command just ci-checks
    • generated-contract verification and formatting passed
    • strict workspace Clippy with warnings denied passed
    • 312 workspace tests passed; 6 intentionally skipped
    • all workspace documentation tests passed
    • WASM build check passed
  • all 79 deadcat-rfq-provider tests passed
  • 12 focused settlement tests cover the valid flow, real fee-policy rejection, cancellation/deadline races, cross-provider binding, committed/signed replay, output recovery, layout aliasing, and more than 30 fail-closed PSET/authority mutations

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@tvolk131
tvolk131 marked this pull request as ready for review August 19, 2026 00:29
@tvolk131
tvolk131 merged commit 31fe272 into codex/rfq-quote-engine Aug 19, 2026
2 checks passed
@tvolk131
tvolk131 deleted the codex/rfq-settlement-validator branch August 19, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant