Universal Transaction Security Gateway · Monorepo · Phase 0–7
Pilot 1 — based on
Au et al., ESORICS 2020
— replaces plaintext settlement payloads with
SHA-256 commitment + 32-byte opening proof.
Auditors re-open the payload via Shamir 2-of-3 key shares. DBAs / log shippers / DB snapshots
see only opaque commitments. Code shipped, migration
0039 applied to live DB on 192.168.198.202
(2026-09-09), and the commitment micro-benchmark landed well within acceptance. Files:
packages/settlement-types,
services/execution-service/authorization,
services/reconciliation-service/workers/settlement-commitment.ts.
Migration 0039_pgc_settlement_commitment_envelope.sql +
ADR-0014.
All values above are measured per
PILOT_01
§4 (re-derived 2026-09-09 after
make bench-commit-pgc). The original §4 projections were
Pedersen + Bulletproofs-derived (5–12 ms / 80 B); the chosen SHA-256 primitive is ~1000× faster
and 20 % smaller. ADR-0014 documents the SHA-256 vs Pedersen trade-off (no zk-opening, but
DBAs are outside the trust boundary by design — see §3).
settlement_commitment, opening_proof,
envelope_mode), CHECK constraints, indexes,
triggers (settlement_commitment_immutable_trigger,
settlement_audit_committee_insert_trigger), and
AUDIT_COMMITTEE_* enum values.
make bench-commit-pgc — PASSED.
100k iterations: commit 0.008 ms p50 / 0.011 ms p95, verify
0.0001 ms, full envelope 0.010 ms p50 / 0.014 ms p95. Hard budget
<12 ms p95 cleared with >800× headroom. Raw output at
tests/bench/results/bench-commit-pgc.2026-09-09.json.
# literal
from ^[0-9a-f]{64}$; the original pattern would have rejected every commitment INSERT.AUDIT_COMMITTEE_VERIFIED
and AUDIT_COMMITTEE_OPENED to audit_action_enum in a separate transaction
(PostgreSQL forbids using a freshly added enum value in the same transaction).PERFORM COUNT(*) into an actual RAISE EXCEPTION that aborts the
migration if any pre-existing row violates the new constraints.0x11b); the previous code could not
compute the inverse of 2 and silently returned all-zeros on reconstruction..YYYYYY) to match the audit-chain format from migration 0032.AuditAction with the two new pilot actions
so the application and DB stay in sync.
Pilot 2 introduces a test-only 2-of-2 additive Schnorr foundation that splits a single
signing key into two party-local surfaces, with a local coordinator that combines only public nonce points and partial scalar
metadata. This is NOT threshold ECDSA and NOT BIP-340; it is a reviewable
bounded implementation that hardens the package API boundary without enabling production threshold signing. The production
single path is unchanged. Migration
0040 applied to live DB on 192.168.198.202
(2026-09-10). Files:
packages/kms/src/threshold.ts,
packages/kms/src/signing-mode.ts,
infra/migrations/0040_kms_shares.sql.
ADR-0015 + pilot-1-on-pilot-2.md.
threshold with typed error
All values above are measured per
PILOT_02
§5 (re-derived 2026-09-10 after three independent bench runs). Raw artifacts at
tests/bench/results/bench-kms-threshold.{2026-09-10}.json,
bench-kms-threshold-amortized.2026-09-10.json,
bench-kms-threshold-concurrency.2026-09-10.json.
The amortized bench captures long-tail jitter (stddev 0.47 ms); the concurrency bench is a logical stress
only — local coordinators share a process and are not a proof of multi-party HSM isolation. Production
HSM adapter isolation remains a promotion gate per ADR-0015 §Promotion gates.
kms_shares
table, 5 CHECK constraints (kms_shares_*_check), 3 indexes
(PK + 2 lookup), tenant FK, 5 triggers
(kms_shares_rotation_timestamp_trigger,
kms_shares_immutable_columns_trigger,
kms_shares_no_delete_trigger,
kms_shares_audit_insert_trigger,
kms_shares_audit_update_trigger),
kms_party_role_enum + kms_share_status_enum,
audit enum extended with
KMS_SHARE_* + THRESHOLD_SIGN_*.
make bench-kms-threshold — PASSED 2000 iters: p50 2.75 ms / p95 3.32 ms;make bench-kms-threshold-amortized — PASSED 5000 iters: mean 4.67 ms / stddev 0.47 ms / p99 5.20 ms;make bench-kms-threshold-concurrency — PASSED 8 workers × 400 iters: p50 7.95 ms / p95 12.13 ms / 733 ops/sec.
All raw artifacts in tests/bench/results/bench-kms-threshold*.2026-09-10.json.
settlement_commands evidence, reconciliation verifier,
threat-model A7 exfiltration tests, Pilot 1 plaintext-blocker closure.
d = d_A + d_B, Q = Q_A + Q_B, with message-/public-share-/aux-bound nonces using ShieldTrade-specific tagged-hash domains (SHIELDTRADE_THRESHOLD_SCHNORR_V1/nonce, SHIELDTRADE_THRESHOLD_SCHNORR_V1/challenge). NOT BIP-340. NOT threshold ECDSA.ThresholdPartySurface per party; the local coordinator never receives the other party's secret share through one general function.kms_shares table stores public-only metadata (33-byte compressed-point commitments + verifier key + lifecycle status). Secret shares remain in independently operated HSM/party processes.resolveSigningConfiguration is server-owned and defaults to single. threshold throws SigningModeError with code SIGNING_MODE_THRESHOLD_DISABLED. No caller-provided flag bypasses the resolver.AUDIT_COMMITTEE_* (Pilot 1) plus 5 new actions — KMS_SHARE_REGISTERED, KMS_SHARE_REVOKED, KMS_SHARE_ROTATED, THRESHOLD_SIGN_VERIFIED, THRESHOLD_SIGN_FAILED.DROP TRIGGER IF EXISTS + CREATE TRIGGER on every trigger function; verified fresh + re-run on a live DB.Worker dispatcher.ts polls ACCEPTED rows, acquires per-row leases, calls rail adapters (EVM/PSP/X402), transitions ACCEPTED → SUBMITTED with idempotency key. Retry budget + lease expiry + FOR UPDATE SKIP LOCKED prevent double-dispatch.
DB enum extended with Phase 5 names (CONFIRMED_EXECUTED, CONFIRMED_NOT_EXECUTED, RECONCILIATION_FAILED). Phase 3 names preserved for historical rows. State-machine trigger allows both Phase 3 and Phase 5 transitions.
Complete lifecycle implemented: NOT_STARTED → CLAIMED → SUBMISSION_STARTED → COMPLETED/EXECUTION_FAILED. Migration 0025 adds terminal states + state-machine trigger. Reconciliation worker writes final status atomically with settlement outcome.
Pre-flight check in dispatcher.ts: when parent_correlation_id is set and parent reconciliation_results.status = 'CONFIRMED_EXECUTED', successor dispatch is REJECTED with DOUBLE_EXECUTION_DETECTED. Adapter never called. Migration 0026 adds parent_correlation_id column + partial index.
New disputes table, dispute state machine (NONE → FINANCIALLY_CONTESTED → UNDER_REVIEW → RESOLVED_*), HTTP routes for contest/reopen/resolve. Outbox events DISPUTE_OPENED / DISPUTE_RESOLVED. Spec §3.1 + Invariant 8.
New financial_scope_guards table, hold state (CLEAR/ACTIVE), HTTP route to place hold. Dispatcher checks guard before dispatch. Operator places hold → new transactions BLOCK per Hard Gate Stage 1.
Operator endpoint: POST /v1/transactions/:correlation_id/force-release. MFA + maker-checker + mandatory review creation. Transitions HOLD → CLEAR. Triggers FINANCIAL_REVIEW_HOLD_FORCE_RELEASED outbox event.
tsc -b project references| IDs | Phase | Status | Description |
|---|---|---|---|
| 0001–0006 | 0–1 | applied | Enums, domain tables, execution/reconciliation |
| 0007–0018 | 3–4 | applied | Evaluation sessions, stage evidence, outbox, challenge/review |
| 0019–0021 | 5 | applied | Outbox tables, Phase 4 challenge/review |
| 0022 | 5 | applied | reconciliation_status_phase5 (enum mismatch fix) |
| 0023 | 5 | applied | reconciliation_state_machine_phase5 |
| 0024 | 6 | applied | settlement_dispatch_metadata (Phase 6 settlement dispatcher) |
| 0025 | 6 | applied | execution_status terminal states + state-machine trigger |
| 0026 | 7 | applied | double_execution_guard: parent_correlation_id + DOUBLE_EXECUTION_DETECTED |
| 0027 | 7 | applied | disputes domain: state machine + reason codes + audit triggers |
| 0028 | 7 | applied | financial_scope_guards + holds table + state machine |
| 0029–0038 | H+ | applied | execution idempotency, transactions state machine, admin RBAC, per-tenant JWT keys, audit pipeline |
| 0039 | Pilot 1 | applied | pgc_settlement_commitment_envelope (PGC Envelope — ADR-0014; regex + enum fixes 2026-09-09) |
| 0040 | Pilot 2 | applied | kms_shares (public-only 2-of-2 share registry — ADR-0015; idempotent DDL + lifecycle + audit triggers) |
| 0041 | Pilot 1 B2 | applied | auditor_shares (durable Shamir-1 store, replaces InMemoryAuditorShareStore — append-only + audit triggers) |
| 0042 | Pilot 1 B3 | applied | pgc_settlement_migration_idempotency_fix (guards all 0039 ADD CONSTRAINT with pg_constraint check) |
| 0043 | Pilot 2 | applied | threshold_settlement_evidence (4 cols + CHECK + immutable trigger + audit — ADR-0016.3 / THR-PR-3) |
| 0044 | Pilot 3 | applied | tenant_verification_keys (append-only registry + lifecycle + audit — ADR-0017 / VES pre-foundation) |
| 0045 | Pilot 3 | applied | operator_signing_keys (append-only registry + lifecycle + audit — ADR-0018 / VES pre-foundation) |
All four blockers called out in docs/reports/impact/pilot-1-on-pilot-2.md §2.2 are now closed.
Pilot 2 promotion gate 7 ("Pilot 1 confidentiality gaps resolved or explicitly accepted") is now MET.
ADR-0016 designs the two missing production wiring boundaries and sequences the activation as 8 reviewable PRs. No production code lands in this commit — the design is the contract that production PRs (THR-PR-1 … THR-PR-8) will satisfy. §6 invariants preserved: §4.3 server-owned capability, §4.5 unknown≠blind retry, §4.7 signing material isolated, §4.8 CONFIRMED_EXECUTED immutable, §4.10 audit traceability.
KmsThresholdAdapter + KmsThresholdParty + KmsThresholdSign{Request,Result} stub interface + 8 contract tests:
46/46 passing.
settlement_commands +4 columns: threshold_signature BYTEA(65),
threshold_public_key BYTEA(33), threshold_quorum_hash TEXT(hex64),
threshold_signing_envelope_mode TEXT. CHECK constraints on byte-lengths,
hex format, mode ↔ column consistency. Immutable-fields trigger forbids UPDATE;
none → threshold | local is the only allowed mode transition.
Audit trigger emits AUDIT_THRESHOLD_VERIFIED on threshold-bearing INSERT.
Idempotent (ADD COLUMN IF NOT EXISTS, guarded CHECKs).
computeActiveQuorumHash, hexToThresholdSignature,
hexToDigest. DB functions: getThresholdEvidence,
getActiveQuorumRowsByPublicKey. Orchestration: runThresholdVerification
emits discriminated outcomes (SKIPPED / VERIFIED / QUORUM_HASH_MISMATCH /
SIGNATURE_INVALID / QUORUM_NOT_FOUND / MALFORMED_EVIDENCE). Hard-stop outcomes emit
outbox THRESHOLD_TAMPER_DETECTED + audit AUDIT_THRESHOLD_FAILED,
mark row RECONCILIATION_FAILED, NEVER retry settlement (AGENTS.md §4.5).
Wired into reconciliation.ts immediately after commitment verification.
33 unit tests passing.
ADR-0016.3 implements THR-PR-3 (durable evidence columns)
and THR-PR-4 (reconciliation verifier). The four columns are bound to settlement_commands
by an immutable-fields trigger; the verifier recomputes the quorum hash from kms_shares
rows and rejects any settlement whose stored evidence does not match a registered quorum.
Per AGENTS.md §4.5, every verification failure is a hard stop — no blind retry.
none → threshold | local; no reversal (immutable evidence)AUDIT_THRESHOLD_VERIFIED, AUDIT_THRESHOLD_FAILEDinfra/migrations/0043_threshold_settlement_evidence.sql — idempotent, all CHECKs
guarded, pre-flight scan refuses bad data. New enum values added in their own transaction
(PostgreSQL constraint).
services/reconciliation-service/src/workers/threshold-verify.ts — pure helpers
+ DB readers + orchestration. Wired into reconciliation.ts after commitment
verification and before rail-level checks.
THRESHOLD_TAMPER_DETECTED + audit
AUDIT_THRESHOLD_FAILED + RECONCILIATION_FAILED with one of four
reason codes. Never retries settlement (AGENTS.md §4.5).
Pilot 3 (RECON-VES-003) needs two public-only key registries as preconditions: tenant_verification_keys (custodies the tenant-side decryption key, never stored) and operator_signing_keys (custodies the operator-side signing key, never stored). Both follow the ADR-0010 / 0040 / 0041 append-only pattern with server-derived lifecycle timestamps, immutable identity / binding / custody columns, lifecycle triggers, and audit emission.
infra/migrations/0044_tenant_verification_keys.sql — append-only with 3 CHECKs,
lifecycle trigger, immutable-columns trigger, no-delete trigger, 3 audit actions
(REGISTERED / ROTATED / REVOKED). Partial unique index enforces at-most-one ACTIVE row per tenant.
infra/migrations/0045_operator_signing_keys.sql — composite primary key on
(tenant_id, actor, key_id), partial unique index for at-most-one ACTIVE per (tenant, actor),
3 audit actions, last_used_at server-derived.
TenantVerificationKey, OperatorSigningKey, OperatorVES,
OperatorMarkExecutedPayload, ResolveReconciliationFailedRequest.
11 type tests passing.
signing.mode = single | threshold resolver; threshold fails closed with typed SigningModeErrorKMS_SHARE_REGISTERED / KMS_SHARE_REVOKED / KMS_SHARE_ROTATED + THRESHOLD_SIGN_VERIFIED / THRESHOLD_SIGN_FAILED to AuditAction