Bitcoin time beacon
Purpose
The paper's Layer 2 gives each Firebreak Guarantee Module (FGM) two clocks: a local monotonic counter driven by an oscillator inside the enclosure (checked against a second, physically different oscillator), and the Bitcoin header chain. This module is the FGM-side logic for both and for the outage rule of Layer 1:
- a header-chain verifier that extends a trusted checkpoint with real Bitcoin
headers, enforcing proof of work, Bitcoin's retarget rule, the median-time-past
rule and the license's difficulty floor
d_min = difficulty(h) / k(licenseFloor,licenseFloorFactor), and accumulating chainwork; - most-work tip selection among competing branches (
beaconState,submitBranch): the FGM stores the tip with the most cumulative work, not the greatest height, and refuses any header chain that would move it backward; - the license clock (
checkOscillators,licenseClock): at mostlambdaof local time on the faster of the two oscillators, a clock anomaly when they diverge beyond tolerance, and a second expiry when the chain passesH_to, which can end a license early but never extend it; - two-sided time bounds
[tLo, tHi]from the chain and the oscillators, and a pace check that turns header withholding into a visible "stale" state; - outage evidence (
verifyOutageEvidence): every full block of the outage window, each checked against its header's Merkle root, with no epoch anchor among them.
Formats
- Header: the 80-byte Bitcoin wire format (version i32, prevHash 32, merkleRoot
32, time u32, nBits u32, nonce u32, all little-endian). Hashes are double SHA-256
(
@noble/hashes) kept in internal byte order;displayHashgives explorer order. - Checkpoint (what a license carries):
{ height, hash, bits }. When the checkpoint is not the first block of a difficulty period, the license must also carry that period's first timestamp (periodStartTime), or the verifier cannot check the next retarget and refuses to cross it. - ChainAnchor (FGM state): tip height, hash, nBits, cumulative chainwork, the last 11 timestamps, the largest timestamp seen, and the period's first timestamp.
- Fixture
fixtures/mainnet-headers.json: real mainnet headers 973717..975844 (k = 483: 11 headers of MTP context, the full period starting at the checkpoint 973728 = 2016 x 483, the retarget at 975744 and 100 headers after it), the genesis header, the checkpoint, and six hashes cross-checked against mempool.space. Fetched byscripts/fetch-headers.tswith the Electrum methodblockchain.block.headersover TLS from electrum.blockstream.info:50002. - Full blocks (outage evidence only): Bitcoin's block serialization, transactions
in legacy or BIP144 extended form. A txid is the double SHA-256 of the non-witness
serialization. The Merkle root follows Bitcoin Core's
ComputeMerkleRoot: odd levels duplicate their last hash, and two equal neighbours mark the tree as mutated. - Anchor: an OP_RETURN output whose pushed data contains the ledger's 36-byte
payload
"FBK1" || epochCommitment(src/ledger). Pushes are concatenated, so a payload split across pushes still counts. - Fixture
fixtures/mainnet-small-blocks.json: raw mainnet blocks 170 (490 bytes) and 100000 (957 bytes, four transactions) from mempool.space, each block hash checked against blockstream.info byscripts/fetch-small-blocks.ts.
Flow
license: checkpoint h (height, hash, bits) [+ periodStartTime], H_from, H_to, lambda
floor target = target(h) x k, k = 4^(1 + max(0, ceil(lambda / T) - 1)) (d_min = difficulty(h) / k)
|
history headers ending at the checkpoint --anchorFromHistory--> ChainAnchor
|
new headers --verifyHeaders--> for each header, in order:
80 bytes? -> prevHash == tip? -> nBits valid (not negative, no overflow, <= powLimit)?
-> nBits == tip's (inside a period) or == retarget(tip, periodStart) (at height % 2016 == 0)?
-> hash <= target? -> target <= floor? -> time > median(last 11)?
-> chainwork += 2^256 / (target + 1)
|
submitBranch(state, headers): the first header must build on a block in state.recent
(the last `depth` blocks of the FGM's chain, default 144); every header must verify;
the branch becomes the tip only with strictly more chainwork than the stored tip
(a taller branch with less work is refused); the abandoned branch is forgotten
|
licenseClock: anomaly if |a - b| / max(a, b) > tolerance (a, b: the two oscillators)
expired-local if max(a, b) >= lambda (headers cannot change this)
expired-height if tip height > H_to (headers can only shorten)
before-window if tip height < H_from
licensed otherwise
|
timeBounds: tLo = maxTimestamp - 7200 (or MTP - 7200)
tHi = tSyncHi + (1 + eps) x oscillatorElapsed
consistent = tLo <= tHi
checkPace: stale if P[Poisson(rate x elapsed / (1+eps) / 600) <= headers] < 1e-6
ahead if P[Poisson(elapsed x (1+eps) / 600) >= headers] < 1e-6Outage evidence (verifyOutageEvidence), checked against the FGM's own verified tip:
headers of the window (>= windowBlocks, consecutive, last one hashes to the stored tip)
for each header i: block i present and its first 80 bytes == header i else "gap"
block parses exactly (no truncation, no trailing bytes) else "parse"
no 64-byte transaction else "tx-64-bytes"
Merkle tree not mutated (CVE-2012-2459) else "merkle-mutated"
Merkle root of txids == header's merkleRoot else "merkle"
no OP_RETURN carrying a (valid) FBK1 anchor else "anchor-present"
accept -> the FGM may enter outage grace (inference only, at most g r)Because the window ends at a tip whose headers the FGM verified one by one, and each header commits to its parent, the shown headers are the FGM's own chain; because each block's transactions hash to that header's Merkle root, no transaction can be left out.
Retarget rule (Bitcoin Core CalculateNextWorkRequired): at height h with
h % 2016 == 0, span = time(h-1) - time(h-2016), clamped to [T/4, 4T] with
T = 1,209,600 s; new target = target(h-1) x span / T, capped at powLimit, then
rounded through the compact encoding. The span covers 2015 intervals, not 2016:
this off-by-one is Bitcoin's, it is reproduced exactly, and it is what makes the
timewarp attack possible on Bitcoin.
Security properties and the tests that check them
| Property | Test (test/beacon/) |
|---|---|
Genesis header hashes to 000000000019d6...e26f and meets its own target; its work is 0x100010001 |
verify.test.ts "genesis" |
| The whole real fixture verifies under mainnet rules with the checkpoint floor, ending at the cross-checked hash | "verifies end to end ..." |
| The real retarget at 975744 is reproduced bit for bit; using the wrong first block gives a different result | "crosses a real retarget ..." |
| A single-bit flip in any of the 80 bytes of any of the 2116 verified headers is rejected (169,280 cases) | "rejects a single-bit flip ..." |
| Any bit flip in the checkpoint history is rejected | "rejects a bit flip in any byte of the checkpoint history" |
A missing header breaks the chain (link) |
"rejects a broken link" |
A wrong nBits at the boundary is rejected (retarget) |
"rejects a wrong retarget at the boundary" |
A floor above the real difficulty rejects the real chain (floor) |
"rejects the fixture when the floor is raised" |
| Crossing a boundary without the period's first timestamp is refused | "needs the period's first timestamp" |
| A regtest-difficulty chain (0x207fffff, mined in JS) passes structural checks but is rejected by the mainnet floor and by mainnet powLimit | "regtest-difficulty chain" block |
| Median-time-past rule enforced | "enforces the median-time-past rule" |
| Tip only moves to strictly more work | "keeps the most-work tip ..." |
| A branch longer by height but with less work loses; the heavier branch reorgs a taller one that arrived first; equal work does not move the tip; a bad header rejects the whole branch; forks deeper than remembered are refused | branch.test.ts "most-work tip selection" |
k is 4 up to two weeks and 4x per extra retarget period; d_min = difficulty(h) / 4 for a two-week license, and every real header across the 975744 retarget meets it |
branch.test.ts "difficulty floor" |
Expiry at lambda on the faster oscillator; height expiry once the chain passes H_to (not at it); divergence is a clock anomaly |
branch.test.ts "license clock" |
Property: licensed only while both oscillators are under lambda and agree; more headers never revive an expired license |
branch.test.ts "property: ..." |
| Real blocks 170 and 100000: txids equal bitcoinjs-lib's, Merkle root equals the header's, each is valid evidence for a one-block window | outage.test.ts "full-block parsing ..." |
Outage evidence: a full anchor-free window passes; a withheld block fails (gap); an altered transaction fails (merkle); an FBK1 anchor fails (anchor-present), also when split over two pushes; not ending at the tip, too short or non-consecutive fails; 64-byte transactions, mutated Merkle trees and truncated blocks fail |
outage.test.ts "outage evidence" |
| The same checks on blocks bitcoind mined (segwit coinbase and wallet transactions): window with the anchor refused, anchor-free window accepted, withheld block and tampered transaction refused | test/regtest/bond.test.ts "anchors a ledger epoch root ..." |
| nBits decoding and encoding match Bitcoin Core's vectors; negative and overflowing nBits rejected | "compact nBits" block |
| tLo never decreases as headers are accepted; tHi is monotone in elapsed time and eps (property tests) | time.test.ts "property: ..." |
| Contradiction between chain and oscillator is flagged | "flags inconsistency ..." |
Conservative expiry at (1+eps) lambda and height expiry at H_to |
"expires by oscillator ..." |
| Poisson tails accurate deep in the tail; stale detector flags withholding, not ordinary gaps | time.test.ts "Poisson tails", "withholding detector" |
Interpretations
- Interpretation: the floor factor k. The paper sets
d_min"a small factor below the difficulty at the license's block h, within the range Bitcoin's own retargeting allows over a license period". One adjustment can land just after h and lower difficulty by up to 4x; each later one lowers it only if its period took longer thanT(two weeks), so at mostceil(lambda / T) - 1more. We takek = 4^(1 + max(0, ceil(lambda / T) - 1)): 4 for any license up to two weeks, 16 up to four weeks. Every counterfeit header then costs at least1/kof an honest block's work. The bound is conservative (a real chain cannot reach it), which is the safe side for liveness and the costly side for counterfeit resistance. - Interpretation: the reorg window. The FGM keeps the chain states of its last
depthblocks (default 144, about a day) so it can judge a heavier fork that does not build on its exact tip. A branch is all or nothing. - Interpretation: the two oscillators. Elapsed local time is the larger of the two
counts, so a slowed oscillator cannot stretch a license; relative divergence above the
tolerance, after the first second, is a clock anomaly.
timeBoundsshould be fedcheckOscillators(...).elapsed. - Interpretation: "passes H_to" means tip height
> H_to; a tip belowH_fromis reported asbefore-window(the license is not yet usable). - Interpretation: the outage window is counted in blocks ending at the FGM's tip.
The paper counts it in epochs; the caller converts. By default any well-formed FBK1
payload in an OP_RETURN counts as an anchor;
isValidAnchorcan narrow this. - Interpretation: 64-byte transactions are refused in outage evidence. A 64-byte transaction has the same shape as an inner Merkle node, so a forged "block" could replace a subtree (holding an anchor) with one fake transaction. BIP54 would make such transactions invalid; mainnet does not yet. Mutated (duplicated-leaf) trees are refused as Bitcoin Core does.
- Interpretation: tLo = newest timestamp - 7200 s, because nodes reject blocks
more than two hours ahead of their clock (
MAX_FUTURE_BLOCK_TIME). Amedian-time-pastrule is offered as an option (see open questions). - Interpretation: tSyncHi is an input: the upper bound on real time at the last sync point, carried in FGM state from the previous sync or from provisioning.
- Interpretation: expiry is judged by tHi (the latest time it could be), so a
license never runs past its expiry; the height expiry
H_tocan only end it early. - Interpretation: the pace check is the paper's "cumulative work consistent with
the local time elapsed", done on header counts (equivalent while difficulty is
constant). "stale" uses the slowest plausible elapsed time, "ahead" the fastest,
both at p < 1e-6.
minRateFactorandmaxRateFactor(default 1) allow for hashrate swings between retargets. - Not checked: block version and soft-fork activation rules. They cost an attacker nothing, so they add no security to a header-only verifier.
Open questions for the paper authors
- Which timestamp sets the lower bound? With "newest timestamp - 2 h", one header mined at floor difficulty with a far-future timestamp pushes tLo forward, which can make the FGM think a license has expired or flag a contradiction (a bricking attack costing about a quarter of a block's work). Using median-time-past costs the attacker six such headers. The paper should pick one.
- The floor factor and lambda. The paper should state
kas a function of lambda (ours:4^(1 + max(0, ceil(lambda / T) - 1))). For licenses longer than two weeks it grows fast (16, 64, ...), so a counterfeit header becomes cheap; this argues for lambda of at most two weeks. - Reorg window size. "Store the most-work tip" needs a window of recent chain states so the FGM can accept a heavier fork that does not extend its exact tip. The paper should give the depth (ours: 144 blocks).
- What makes an anchor "valid" for the outage rule? If any FBK1-shaped OP_RETURN counts, anyone can block outage grace for the whole world by publishing one cheap OP_RETURN per window; if only anchors that extend the known epoch chain count, the FGM must hold that chain's state. The paper should define validity (for example, a payload whose epoch record links to the last root the FGM saw, or a spend from a key the Council publishes).
- The outage window's unit and the evidence's size. The paper counts the window in epochs; the FGM needs it in blocks. Full blocks are up to about 4 MB each, so a day-long window is about 600 MB the FGM must hash; the paper should size the window with that cost in mind.
- Who keeps blocks below a reorg? Outage evidence is only as good as the FGM's tip: an operator who controls the FGM's header feed can stop it at an old tip, but then the pace check reports "stale", so the outage rule should require a non-stale pace before accepting evidence. The paper does not say how the two interact.
- Hashrate drops. The plain Poisson(T/600) stale test fires falsely if hashrate
falls sharply before a retarget. The paper should say how much slack the Grace state
allows (our
minRateFactor). - Where tSyncHi comes from at first boot (provisioning) is not specified.
- Timewarp. Mainnet still permits timewarp (the BIP54 consensus cleanup is not active). The floor bounds what a private timewarp chain can gain, which is why the floor matters; the paper should state this dependency.