BIP: ?
Layer: Consensus (soft fork)
Title: Hash-Before-Reveal Precommit Ordering
Authors: Cristóbal Rosa <sato@cuvex.io>
Status: Draft
Type: Informational
Assigned: ?
License: BSD-2-Clause
Version: 0.2.0
Abstract
Hash-Before-Reveal (HBR) proposes that a Bitcoin output can require a spend commitment to be ordered and mature before its public spending key is disclosed. A signer fixes the exact signed transaction offline. An auxiliary ordering layer records a digest and one opaque tag per protected input. At spend time every upgraded Bitcoin validator would check that the transaction owns the first eligible commitment for every tag in a Bitcoin-recognized history. A single reference might amortize main-chain overhead across inputs.
This candidate specifies the security question, a deterministic experiment and the conditions for a subsequent consensus specification. The public-counter construction by itself cannot authenticate the first reservation. Bitcoin has no HBR output or accepted HBR history today. This draft requests review of those two obstacles before proposing a witness version, consensus serialization or activation.
Motivation and scope
With a fresh hash-committed key, the public key can remain unknown until the signed spend reaches an online party. From that instant there may be time to derive the private scalar if a suitable fast quantum computer exists. Ten minutes is an average Bitcoin block interval, not a security threshold. A private relay learns the key too. Waiting for several auxiliary confirmations only helps if the reservation is already the rightful, irreversible-enough one by the time the signer releases the transaction.
The proposed output would opt in when funded. Every spend path, including any recovery path, would have to enforce the same condition. An ordinary P2WPKH output has no such condition. Existing coins can only move voluntarily under their existing rules, with the original spend's exposure. Reused or previously disclosed keys, previously exported extended public keys, P2PK, Taproot output keys, leaked cosigner policies and compromised signers have different exposures. A transaction that reveals a key for another still-funded output can endanger that other output even after confirmation. The initial experiment covers one fresh compressed secp256k1 key per protected output. Multisig, alternate leaves and aggregated signing are open extensions.
Security model
The wallet controls its offline signer and keeps child and ancestor spending public keys confidential until release. SHA-256 preimage and second-preimage resistance at the chosen security level, reliable key generation and normal Bitcoin consensus assumptions are required. The observer may read the entire ordering layer, influence inclusion and observe the signed transaction at the first connected recipient. Security must be evaluated even if the elliptic-curve secret becomes recoverable immediately after that observation. No assumption of an honest public indexer, integer supplied by a producer or wall clock may determine a block's validity.
Safety means that a conflicting Bitcoin transaction cannot use the same protected coin after a rightful reservation has matured on the selected history, within stated reorganization assumptions. Liveness means an honest owner can obtain, maintain and spend against a usable reservation under an explicit censorship, availability and fee model. A design that preserves funds by permanently freezing a coin fails the liveness objective. Concealment only delays disclosure. A complete PQ signature would make a different security claim.
Proposed validation predicates
- A distinct output program, committed at funding, hides the future spend key and binds its policy. Every allowed authorization must map a coin to the same effective reservation identity. In the experiment exactly one compressed key is accepted. A consensus version, signature algorithm binding and its script execution rules remain unassigned.
- Offline, the signer constructs and signs a transaction that fixes all inputs, prevouts, amounts as required by the signature algorithm, outputs, amounts, sequences, version and locktime. It retains the exact signed bytes. Any randomization of a signature or change in ordering after reservation changes the commitment.
- For each protected input it derives a tag from that outpoint and separate secret-until-reveal material. It sends only a set of tags and a transaction digest to the ordering layer. The commitment is computed over the signed transaction with its HBR proof removed. Neither txid (omits witness) nor final wtxid (includes the proof) suffices.
- Before revealing the transaction, the wallet checks admission, historical first eligibility for all tags, membership, common selected history, data availability, auxiliary maturity and Bitcoin anchor depth. A server saying “first” supplies none of these guarantees by itself.
- The upgraded Bitcoin validator independently performs ordinary spend and monetary checks and repeats the HBR predicates against the view determined by the candidate Bitcoin block's parent. Every protected outpoint must correspond to exactly one tag in the same winning record. Missing or extra tags, ambiguous authorization paths, invalid proofs, wrong network, different digest, insufficient maturity or a foreign history fail.
- In an implementation where validation data is still downloading, the node waits for data before accepting the block. Locally unavailable bytes are not proof that a peer's block violates consensus. In the research profile there is no mainnet validation or fallback. Activation requires a separate deployable specification.
Deterministic commitment experiment
The following encoding permits independent implementations to check mapping and ordering. It allocates no witness version, opcode, PSBT field or service bit. All byte counts are octets. Let T(label,x) = SHA256(SHA256(ASCII(label)) || SHA256(ASCII(label)) || x). All labels below start with the literal HBR/0.2/. G is the 32-byte genesis block hash in Bitcoin wire order, never displayed hex order. P is a valid, compressed 33-byte SEC1 point. U is funding txid in wire order followed by the four-byte little-endian vout. The test genesis of 32 zero octets is a fixture only.
program = T("HBR/0.2/program", G || P)
R = T("HBR/0.2/reveal", G || P)
S = T("HBR/0.2/spend", G || U || R)
D = T("HBR/0.2/tx", G || tx0)
record = 0x01 || G || D || byte(n) || sorted(S[0..n-1]) || LE64(nonce)
id = T("HBR/0.2/record", record)
The output commitment and reveal digest have different domains. Using the publicly visible funding program in place of R would let anyone calculate S from public information before the owner reserved. n is 1..64 in this experiment. Tags are distinct, ascending in unsigned bytewise order. Noncanonical order, duplicate tag, trailing octets, wrong lengths or unknown version fail. No counter is inside id. Nonce is an unsigned 64-bit producer-independent value, with no safety credit for unpredictability.
For the experiment all inputs are native, protected inputs with an empty scriptSig. Each witness of tx0 consists of exactly two items, a DER ECDSA signature with trailing SIGHASH_ALL (0x01) and P. The test signing profile uses the BIP143 digest layout with P2PKH scriptCode derived from P, the real previous amount and all-input/all-output semantics. The experiment is not a valid new output type on today's network. Validate curve point, canonical DER and low-S in this profile. Use canonical BIP144 witness serialization, without trailing bytes and with shortest CompactSize encodings. In the experimental final form only the first input gains a third item, the opaque proof. Removing that complete item and reserializing the whole witness transaction produces tx0. There are no alternative positions, annexes or proof-dependent signatures. tx0 can be recovered uniquely. Other input types or mixing funding policies require a later specified profile. The self-contained numeric example below exercises the hash boundary only.
Historical ordering and atomic multi-input reservation
For each auxiliary block, order candidate records by (lexicographically ordered tag list, D, numeric unsigned nonce). Lists compare element by element with shorter proper prefix first. Blocks are processed in parent order. Versions/network are fixed for the view. Duplicate retransmissions of the exact set and D are one claim regardless of nonce. For an identical claim in the same block the first ordered instance supplies the record id. Replays in a later block preserve that id.
On an empty intersection with occupied tags, atomically install (first id, D, tag set, height, position) for every tag. Its historical ordinal is 1 for every entry. If the identical full claim already owns all entries, return its existing receipt without mutation. Otherwise archive the record as a conflict if desired and install no new first entries, including for previously empty tags. This last rule is an explicit refinement of the earlier independent per-tag counter: a losing batch must not consume unrelated free tags. Subsequent conflict counts are diagnostics. They can neither invalidate nor promote an earlier historical ordinal. Comparing the current total to 1 would allow a later replay to invalidate the winner.
Inclusion of a leaf can prove presence. It cannot alone prove that the leaf was authorized, was first in a valid history or survived a reorganization. A state root commits bytes; its transitions must also be validated. An externally signed receipt is insufficient for Bitcoin consensus.
Owner binding and availability are open consensus problems
S is initially difficult to predict but becomes public in the ordering network. Ordering cannot distinguish the owner from a party presenting an observed tag with a different digest. Deterministic sorting does not establish entitlement. A competing first entry without a valid matching Bitcoin signature can lock a coin. This is a liveness failure even where Bitcoin signature checks still prevent theft. Auxiliary maturity only stabilizes the selected entry. An admission rule or a sealed owner-bound commitment must bind funding policy, transaction and all tags without revealing the spend key early, resist copying across transactions, preserve harmless exact replay, and be publicly verifiable. No such mechanism is specified or claimed here. A hash of public data, an ordinary signature disclosing P, reliance on a single operator and a timeout that reopens a coin after reveal fail at least one of these requirements.
An anchor design must allow any Bitcoin full node starting from genesis to select exactly one authenticated, available HBR prefix relative to a Bitcoin parent, even with multiple producers or conflicting candidate roots. It must specify producer election or work, fork choice and ties, root placement and uniqueness, incentives, validation data transport, maximum bytes/CPU/state per block, reconstructible proofs and pruning. It must resist withholding and state inflation under a stated model. Local clock, first packet arrival, assumed snapshot and querying a hosted indexer cannot choose the consensus result. An anchor disappearing in a Bitcoin reorg rolls back dependent HBR receipts. An auxiliary branch reorg changes only unanchored history; a conflicting descendant cannot rewrite a still-recognized anchored prefix.
For testing let K be the required number of auxiliary confirmations including the record block and A be Bitcoin confirmations of the anchor including its Bitcoin block, counted up to the parent of the evaluating Bitcoin block. Require both inequalities separately, descendant coverage and a record in that committed auxiliary prefix. A nominal five-second interval is a prototype setting; elapsed seconds prove no depth. Concrete K, A, genesis, activation, DA and fork choice are deliberately unallocated. A halt can freeze spending indefinitely if no secure alternative exists. Report this cost to users before funding.
Relay, miner policy, wallets and recovery
A wallet stores tx0, record id, its tag set, receipt and anchor evidence before reveal. Once it crosses to an online counterparty, treat the spending keys as disclosed even on timeout, rejection, private relay or subsequent reorg. Rebuild the same proof if the same winning claim survives. A proof change can change the wtxid while the txid and D stay fixed. If the winner disappears after reveal, automatic re-reservation under new assumptions is unsafe. Surface the loss of the original protection and preserve evidence. Back up exact signed bytes offline before committing: recreating a semantically identical ECDSA signature may produce a different D.
RBF that changes the signed transaction changes D. A later reservation cannot replace the original first under this profile. A newly precommitted fee replacement alone does not solve this. A CPFP child can raise effective package fees when there is a spendable output, adequate value, policy support and an acceptable new disclosure. A protected child may itself need HBR maturity. CPFP, package relay and confirmation are conditional. Evaluate fee estimation, no-change transactions, replacement of conflicting packages and bandwidth. Mining policy cannot enforce the rule on nonparticipating miners. The proposed property would require Bitcoin consensus enforcement by upgraded validators.
Cost and alternatives
The attraction is paying a main-chain reference once for a multi-input transaction and using Bitcoin's ordinary spend signatures. A designated full-node implementation would instead pay index, availability, history, bootstrapping and reorg costs. For n=1 and 5, the experiment's fixed record encoding is 106 and 234 bytes (74+32n). It excludes owner proofs, counters in the derived index, block framing, anchors, undo and redundancy. The June design's 48–160 indexed or 320–900 portable extra main-chain bytes per transaction are targets. They have not been achieved by a full construction. A budget of 100–200 database bytes/tag would mean 10–20 GB per 100 million tags in decimal units before history and replication.
Report stripped bytes, witness bytes, weight units (WU), vbytes and incremental Bitcoin anchor cost separately, amortized at stated occupancy. BIP141 weighs a base byte as 4 WU and a witness-only byte as 1 WU; there are 4,000,000 WU per block. A BIP340 signature is 64 bytes before an optional sighash byte. ML-DSA-44 uses a 2,420-byte signature and a 1,312-byte public key. If only a 64-byte witness item were replaced by 2,420 bytes, the payload difference would be 2,356 WU before item framing, keys and script changes. This conditional arithmetic does not predict actual network throughput. Compare against batching, aggregation where supported, compact hash-based signature research such as SHRINCS and proposals that address long-term exposure. Measure sigchecks, hash work, relay latency and handset/verifier costs alongside bytes.
Compatibility and migration
The HBR output would require a separately defined opt-in soft fork with mandatory proof on every spend. Legacy outputs retain existing rules. Unsupported wallets cannot advertise ability to receive, sign or recover these outputs. No mainnet address encoding, deployment height, miner threshold or fallback spend is requested. Old software may treat unassigned witness programs differently from upgraded validators; funding experimental programs on mainnet would be unsafe. For research use isolated, valueless chains with explicit capability markers. Wallet-side finite address bundles can ship today independently and only reduce exposure before broadcast.
Test vectors and review criteria
The bundled hbr-vectors.json provides exact hex for one signed illustrative witness, its proof-stripped hash, spend tag, record id and sample proof-item transport. The following acceptance cases are independent of any proposed production proof. A first admitted record must win for all fresh tags. An exact replay preserves its original id. A conflicting batch touching an occupied and a new tag must leave the new tag free. An alternative digest, invalid key encoding, incorrect network or missing tag must fail validation. A valid membership proof for the wrong fork must fail. K-1 and A-1 must fail independently. Disconnect then reconnect the same blocks and reproduce identical state. Nodes starting at genesis and from a verified checkpoint plus history must converge.
Before a Specification BIP: publish an owner-binding construction and analysis, fully specified Bitcoin-relative history/DA and bounds, two independent implementations with cross-language positive and negative vectors, IBD and reorg results, signer recovery and fee experiments, plus reproducible measurements at one, ten and one hundred million tags against a same-workload Bitcoin baseline. Include privacy linkage after reveal, censorship, rational producer incentives without a native token and a measurable abort criterion if owner binding or availability outweighs the saved witness bytes. Close these questions before selecting parameters or seeking activation.
Numeric example (hex)
All-zero example genesis, outpoint transaction-id bytes 00 through 1f in increasing wire order, vout 1 and record nonce 9. The one-input signed fixture pays 118,000 sat from 120,000 sat. The following three values are reproducible from hbr-vectors.json.
S = fbcae799333a8c3a40523269580adf569d05e9b29802aeabd7e9a657d980ca1d
D = fe8ee1f1e8c902dc5865250113c8fae5d249b9350a913a1f33141476b058a8a9
record id = cfdcd11f01809672e858f7c73baf9db0b7944c765f68c8b1589af28abe8173bb
The sample proof payload a001 is an opaque serialization fixture. It carries no authorization, membership or maturity evidence.
Prior work and references
Copyright
Copyright 2026 Cristóbal Rosa. Proposed license for this draft and its accompanying example: BSD-2-Clause, as reproduced in LICENSE-HBR.txt.