% ===================================================================================== % PQB (Post-Quantum Bitcoin) whitepaper. Build: ./build.sh (tectonic; see README.md) % % Numbers in this file trace to pqb's code, data and tests (paths relative to the % pqb/ package unless noted; "% src:" comments name them where useful). % % Layout: front matter and Overview; Part I (Sections 1-3) is the on-ramp and the % prior work; Part II (Sections 4-5) builds the construction in layers and argues security; % Part III (Sections 6-9) is cost, implementation, relay policy and limitations. Heavy material % (cost model, GPU table, rules, parameters, glossary, provenance) is in the appendices. % Figures are TikZ files in figures/, one per figure. % ===================================================================================== \documentclass[11pt,a4paper]{article} \usepackage{amsmath,amssymb} \usepackage{amsthm} \usepackage{microtype} \usepackage[margin=1in]{geometry} \usepackage{booktabs} \usepackage{tabularx} \usepackage{array} \usepackage{multirow} \usepackage{xcolor} \usepackage{tikz} \usetikzlibrary{positioning,arrows.meta,calc,decorations.pathreplacing,fit,patterns, backgrounds,shapes.geometric} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{enumitem} \usepackage{xspace} \usepackage{float} \usepackage{pifont} \usepackage[most]{tcolorbox} \usepackage[numbers,sort&compress]{natbib} \usepackage{graphicx} \usepackage{abstract} \usepackage{hyperref} % ------------------------------------------------------------------ palette % One palette for text and figures. Each colour also differs in lightness, and every figure % labels its parts in words, so the paper reads the same in grayscale. \definecolor{ink}{HTML}{1F2933} % text, outlines \definecolor{honest}{HTML}{1F5FA8} % the owner / honest spender (mid-dark blue) \definecolor{forger}{HTML}{A8322A} % the forger / attacks (dark brick) \definecolor{chain}{HTML}{D29A2A} % on-chain data / Bitcoin (light amber) \definecolor{good}{HTML}{2F7D4E} % checks that pass \definecolor{mute}{HTML}{6B7280} % secondary text \definecolor{paper}{HTML}{F5F3EE} % box backgrounds \newcommand{\pending}[1]{\textcolor{red}{\textbf{#1}}} % a mainnet fact not yet on chain % Older names used by figure files. \colorlet{accent}{honest} \colorlet{bad}{forger} \colorlet{navy}{ink} % Shared TikZ styles for every figure in figures/. \tikzset{ every picture/.append style={font=\sffamily\footnotesize}, box/.style={draw=ink, line width=0.6pt, rounded corners=2pt, align=center, inner sep=4pt}, hbox/.style={box, fill=honest!13}, % the owner's side fbox/.style={box, fill=forger!9, dashed}, % the forger's side (dashed in grayscale too) cbox/.style={box, fill=chain!25}, % on-chain data nbox/.style={box, fill=black!5}, % neutral gbox/.style={box, fill=good!14}, % success arr/.style={-{Stealth[length=2.2mm]}, line width=0.8pt, draw=ink}, farr/.style={-{Stealth[length=2.2mm]}, line width=0.8pt, draw=forger, dashed}, lab/.style={font=\sffamily\scriptsize, text=mute, align=center}, ttl/.style={font=\sffamily\small\bfseries, text=ink}, } \hypersetup{colorlinks=true, linkcolor=blue!70!black, citecolor=blue!70!black, urlcolor=blue!70!black, pdftitle={PQB: Efficient Post-Quantum Bitcoin Transactions Without Softforks}, pdfauthor={Oren Yomtov}} \setlength{\emergencystretch}{3em} \setcounter{topnumber}{3} \renewcommand{\topfraction}{0.85} \renewcommand{\textfraction}{0.12} \renewcommand{\floatpagefraction}{0.75} % FindAndDelete in typewriter, breakable at word boundaries. \newcommand{\fad}{\texttt{Find\-And\-Delete}\xspace} % ------------------------------------------------------------------ names (rename here only) % The public name: PQB, long form "Post-Quantum Bitcoin". \newcommand{\scheme}{PQB\xspace} \newcommand{\schemelong}{Post-Quantum Bitcoin\xspace} % The configuration tag in pqb (src/pqb/configs.py DEFAULT = 'PQB'). pqb ships one % configuration, in numbered construction versions (src/pqb/versions.py); this paper describes % the latest, v1. \cfg and \scheme name the same thing; \cfg is kept where the sentence is % about the configuration rather than the scheme. \newcommand{\cfg}{PQB\xspace} \newcommand{\qsb}{QSB\xspace} \newcommand{\binohash}{Binohash\xspace} % ------------------------------------------------------------------ headline numbers % src: pqb/src/pqb/data/published.json, versions.v1.security.grover_bits = 64.054 \newcommand{\grover}{64.05\xspace} % src: published.json versions.v1.security.sec_bits = 128.108 \newcommand{\secbits}{128.11\xspace} % src: published.json versions.v1.exposure.second_broadcast_grover = 44.94 \newcommand{\secondwit}{44.94\xspace} % src: fleet.expected_hours(fleet.stage_models(lock)) = 7.977 (tests/test_cloud.py TestPlan) \newcommand{\hoursall}{8.0\xspace} % ------------------------------------------------------------------ helpers \newcommand{\op}[1]{\texttt{OP\_#1}} \newcommand{\flag}[1]{\textsf{#1}} \newcommand{\txid}[1]{\texttt{\detokenize{#1}}} \newcommand{\Rec}{\mathrm{Rec}} \newcommand{\Der}{\mathcal{D}} \newcommand{\cmark}{\textcolor{good}{\ding{51}}} \newcommand{\xmark}{\textcolor{forger}{\ding{55}}} % ------------------------------------------------------------------ callout boxes \tcbset{pqbox/.style={enhanced, breakable=false, boxrule=0pt, arc=1.5pt, left=8pt, right=8pt, top=5pt, bottom=5pt, colback=paper, before skip=8pt, after skip=8pt}} \newcommand{\boxtitle}[2]{\small{\bfseries\color{#1}#2}\ } \newtcolorbox{plainwords}{pqbox, borderline west={2.5pt}{0pt}{honest}, before upper={\boxtitle{honest!85!black}{In plain words.}}} \newtcolorbox{whymatters}{pqbox, borderline west={2.5pt}{0pt}{chain}, before upper={\boxtitle{chain!60!black}{Why this matters.}}} \newtcolorbox{attack}[1][]{pqbox, borderline west={2.5pt}{0pt}{forger}, colback=forger!5, before upper={\boxtitle{forger}{Attack this stops#1.}}} \newtcolorbox{openattack}{pqbox, borderline west={2.5pt}{0pt}{forger}, colback=white, borderline={0.4pt}{0pt}{forger!50, dashed}, before upper={\boxtitle{forger}{Attack still open.}}} \newtcolorbox{example}{pqbox, borderline west={2.5pt}{0pt}{good}, colback=good!5, before upper={\boxtitle{good!80!black}{Worked example.}}} % "What this means" line under a key table. \newcommand{\whatmeans}[1]{\par\smallskip\begin{minipage}{0.92\linewidth}\small \textbf{What this means:} #1\end{minipage}\par} \newtheorem{claim}{Claim} \title{\textbf{PQB: Ef\/ficient \schemelong Transactions Without Softforks}\\[0.4em] {\large Building on \binohash and \qsb}} \author{Oren Yomtov\footnote{\texttt{oyomtov@fireblocks.com}, socials: \texttt{@orenyomtov}}\\Fireblocks} \date{1 December 2026} \begin{document} \maketitle \thispagestyle{plain} \begin{abstract} \noindent Bitcoin's signatures break if a quantum computer can run Shor's algorithm. \scheme (\schemelong) protects bitcoin with hashes instead, using only the consensus rules already running on mainnet. The locking script holds hashes of one-time secrets; the spending transaction reveals some of them and proves, through three GPU-solved hash puzzles, that they authorize this exact transaction. An ordinary ECDSA co-signature is required as well, which makes it a hybrid signature scheme. The binding uses the \fad quirk in legacy \op{CHECKMULTISIG}, as \binohash does, with proof-of-work signature grinding. The opcode deletes the dummy signatures of the revealed secrets, so the choice of secrets changes the transaction digest. Each puzzle recovers the public key that a fixed signature and the digest determine, and hashes it; the puzzle passes only when that hash is shaped like a Bitcoin signature, about once in $2^{45.4}$ tries. The owner solves the puzzles one after another. Someone who copies the revealed secrets has to change the transaction, which reshuffles all three, so they must pass together: $2^{\secbits}$ classical tries, $2^{\grover}$ with Grover's algorithm, meeting NIST PQC Level~1. The ECDSA co-signature keeps an attacker without a quantum computer at about $2^{128}$, however many hash-based witnesses are public. \scheme builds on Robin Linus's \binohash and StarkWare's \qsb. Two changes cut cost. A menu of fixed signatures and several encodings of each recovered key give many more puzzle attempts per elliptic-curve operation, so grinding is about an order of magnitude faster. One table of commitments, opened at two hash depths across both rounds, halves the locking script to 4{,}696 bytes. Producing a spending transaction takes \hoursall expected RTX~4090-hours, about \$3 of rented GPU time. The spending transaction is consensus-valid but breaks four relay policy rules, so it goes to a miner directly. The implementation is open source. \end{abstract} % ===================================================================================== \newpage \section*{Overview} \addcontentsline{toc}{section}{Overview} \paragraph{Problem.} Bitcoin's signatures (ECDSA and Schnorr) fall to Shor's algorithm: a large enough quantum computer turns a visible public key into its private key. About 6.26 million BTC, roughly 30\% of the supply, already sits behind a key that is on chain~\cite{chaincode2025}. The soft fork that would add post-quantum signatures is still a draft. \paragraph{How a spending transaction works.} \begin{enumerate}[leftmargin=*, itemsep=2pt, topsep=4pt] \item \textbf{Locking script.} Publish a table of hash commitments, menus of fixed signatures and the hash of an ECDSA co-signing key. \item \textbf{Pin the transaction.} Vary \texttt{nLockTime} and \texttt{nSequence} until the first hash puzzle passes. \item \textbf{Open 8 entries.} \fad in legacy \op{CHECKMULTISIG} deletes the dummy signatures of the 8 chosen secrets, so the choice changes the digest. Search over choices until the second puzzle passes: the hash of the recovered key must be shaped like a signature, about 1 try in $2^{45.4}$. \item \textbf{Open 9 more.} The same search over 9 of the remaining entries, for the third puzzle. \item \textbf{Co-sign.} Sign the finished transaction with the ECDSA co-signing key. \end{enumerate} The opened secrets work only for that transaction. Changing it reshuffles all three puzzles, so a forger needs them to pass together. \paragraph{Results} \begin{itemize}[leftmargin=*, itemsep=2pt, topsep=4pt] \item Security after one spending transaction: $2^{\secbits}$ classical, $2^{\grover}$ Grover queries. \item Locking script: 4{,}696 bytes. Spending transaction: about 1{,}510~vB. \item Expected cost: \hoursall RTX~4090-hours, about \$3 of rented GPU time, typically 10--30 minutes. \end{itemize} \newpage \setcounter{tocdepth}{1} \tableofcontents \newpage % ===================================================================================== \section{Why quantum computers threaten Bitcoin} \label{sec:threat} \subsection{Two quantum algorithms, two very different threats} The first kind of cryptography Bitcoin uses is \emph{signatures}. A private key is a secret number $d$; the public key is the curve point $P = dG$. Going from $d$ to $P$ is easy. Going back, the \emph{discrete logarithm} problem, would take a classical computer longer than the age of the universe. Shor's algorithm~\cite{shor1997} solves it efficiently on a large quantum computer, so for signatures the threat is total: whoever runs it learns $d$ and can sign anything. The second kind is \emph{hash functions}: SHA-256, RIPEMD-160 and the like. The best known quantum attack on them is Grover's algorithm~\cite{grover1996}, which finds a preimage in about $\sqrt{N}$ steps instead of $N$. It halves the exponent and no more: a search that takes $2^{128}$ steps classically still takes $2^{64}$ sequential quantum steps, and Grover parallelises poorly. \begin{figure}[htbp] \centering \input{figures/threat.tex} \caption{The two threats. Shor's algorithm breaks discrete-log signatures outright; Grover's only takes a square root off a hash search ($2^{128}$ becomes $2^{64}$). \scheme puts all of a locking script's security on the bottom row.} \label{fig:threat} \end{figure} \subsection{Which outputs are exposed} An output is at risk once its public key is known. Some output types put the key on chain at rest: pay-to-public-key (P2PK), bare multisig, and Taproot (whose 32-byte output \emph{is} a public key). Others hide it behind a hash until spent, and an address that has been spent from and still holds funds keeps its key exposed. Public estimates put about 6.26 million BTC, roughly 30\% of the supply, behind keys that are already visible~\cite{chaincode2025}. A hidden key is exposed the moment its output is spent. Every output type on mainnet today reveals a secp256k1 key when spent, and a fast enough attacker can compute the private key while the transaction waits to be mined and redirect the funds first. \subsection{Why the real fix is slow} The clean fix is a soft fork that adds post-quantum signatures, or at least an output type with no key path. Proposals exist: BIP~360 (P2MR) removes Taproot's key path~\cite{bip360}, and BIP~361 proposes a migration and the eventual sunset of legacy signatures~\cite{bip361}. Both are drafts. A consensus change needs agreement among developers, miners, exchanges and users, then code, review, activation and wallet support; past soft forks took years from proposal to wide use. \subsection{The question, and our answer} A narrower question can be answered today: \begin{quote}\itshape Using only the consensus rules already live on mainnet, can we lock new bitcoin so that spending it stays hard for a quantum computer? \end{quote} Two recent works answer yes: \binohash~\cite{linus2026binohash} and \qsb~\cite{levy2026qsb} (Section~\ref{sec:prior}). \scheme builds on both. Starting from \qsb's design, we searched for the cheapest configuration that reaches NIST Category~1~\cite{nist2016cfp}. Our contributions: \begin{enumerate}[leftmargin=*] \item \textbf{A construction} (Section~\ref{sec:construction}) that keeps the \binohash/\qsb skeleton and adds levers that help the honest spender but not a forger: committed menus of fixed signatures, several recovery points and key encodings, one hash table shared by both rounds, and a 61-bit pinning nonce. \item \textbf{A hybrid signature} (Section~\ref{sec:hybrid}): a 4-opcode ECDSA co-signature ANDed with the hash-based one, so that locking script reuse, a leaked witness or a flaw in the hash-based half does not hand the funds to a classical forger. \item \textbf{A security analysis} (Section~\ref{sec:security}) against classical and quantum forgers: $2^{\secbits}$ classical and $2^{\grover}$ Grover after one spending transaction, and the price of extra disclosure: a second witness (Grover \secondwit), one extra secret (60.81) or a disclosed menu (58.26), none of which helps a classical forger past the co-signature (Section~\ref{sec:compose}). % src: published.json PQB exposure {second_broadcast_grover 44.94, one_extra_preimage_grover 60.808, menu_disclosed_grover 58.261} \item \textbf{Script-level details} (Section~\ref{sec:gaps}) that decide whether a script enforces the design: entry selection, table encoding, hashtypes. \item \textbf{A measured cost} (Section~\ref{sec:cost}): a CUDA grinder, measured rates on 19 GPU models, and a value-priced mixed-GPU fleet. \item \textbf{A relay policy analysis} (Section~\ref{sec:deploy}): the four rules a spending transaction breaks, and how it gets mined anyway. \end{enumerate} \paragraph{Words we use} The \emph{transaction digest} is the 32-byte value a signature check verifies, a hash of the spending transaction (BIP~143~\cite{bip143} and BIP~341~\cite{bip341} call it the signature message); \emph{legacy sighash} names only the pre-segwit algorithm that computes it. \emph{Secrets} are the hash preimages a spending transaction reveals. A \emph{stage} is one of the three puzzles in a spending transaction: the pin, Round~1 and Round~2. Rounds are numbered from 1 here; the code calls them \texttt{round0} and \texttt{round1}. A ``4090-hour'' is one hour of a real NVIDIA RTX~4090. Appendix~\ref{app:glossary} has a glossary. % ===================================================================================== \section{The building blocks} \label{sec:blocks} \scheme is assembled from five pieces: one-time hash signatures, and four quirks of Bitcoin's original (``legacy'') script system. None of them is new. Three kinds of signature appear in the script, with different jobs. A \emph{dummy} is deleted so the transaction digest changes. A \emph{fixed signature} is paired with that digest to recover a public key; the script checks the signature and never asks the key to sign. A \emph{puzzle string} is the hash of that key, and it only has to look like a DER signature. \subsection{Signatures from hashes: Lamport and HORS} \label{sec:hors} In 1979 Lamport showed how to sign with nothing but a hash function~\cite{lamport1979}. Pick random secrets, publish their hashes as the public key, and sign a message by revealing the secrets that the message's bits point to. Anyone can check a revealed secret by hashing it; nobody can produce an unrevealed one without inverting the hash. Each key signs once, because every signature gives away secrets. HORS~\cite{reyzin2002better} is a compact variant. The public key is a table of $n$ hash commitments $C_i = H(s_i)$. A signature reveals $t$ of the secrets, and the message decides which $t$. A forger who has seen one signature holds those $t$ secrets and nothing else, so he can only sign a message whose selection is (a subset of) the same indices. \begin{figure}[htbp] \centering \input{figures/hors.tex} \caption{The HORS idea. The locking script holds only hashes, and a spending transaction reveals the secrets of a few entries. A forger who copies them cannot open any other entry without running a hash backwards.} \label{fig:hors} \end{figure} \binohash, \qsb and \scheme add a twist. Script cannot compute ``which indices does this transaction select?'' (Section~\ref{sec:fad}), so the \emph{spender} chooses the indices, and the choice itself changes the transaction digest. Hash puzzles then make most choices useless. \subsection{Bitcoin Script: consensus rules versus relay policy rules} \label{sec:policy} A legacy output's locking script (\texttt{scriptPubKey}) runs after the spender's unlocking script (\texttt{scriptSig}). Consensus limits a script to 10{,}000 bytes, 201 counted opcodes (opcodes above \op{16}, plus the key count of every executed \op{CHECKMULTISIG}), 1{,}000 stack items and 520-byte pushes. There is no opcode that cuts bytes out of a string (\op{CAT}, \op{SUBSTR} and \op{LEFT} are disabled), and arithmetic accepts only 4-byte numbers. Two rule sets matter throughout. \emph{Consensus rules} decide whether a block is valid. Every node enforces them, so a transaction that breaks one can never be mined. \emph{Relay policy rules} decide whether a node will hold a transaction in its mempool and forward it to its peers. They are tighter than consensus, no node is obliged to apply them, and a miner may ignore them without putting its block at risk. Several properties one might assume are consensus are relay policy only: \begin{itemize}[leftmargin=*] \item \flag{STRICTENC}: public keys must be compressed or uncompressed, and the hashtype byte must be a defined one; \item \flag{NULLFAIL}: a failed signature check must have an empty signature; \item \flag{CLEANSTACK}: exactly one stack item is left at the end; \item \flag{CONST\_SCRIPTCODE}: no signature may be found in, and deleted from, the script code; \item whether a bare (non-template) script counts as a payment template at all. \end{itemize} The consensus flag set is \flag{P2SH DERSIG NULLDUMMY CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY WITNESS TAPROOT}. Of these, \flag{DERSIG} (BIP~66~\cite{bip66}) matters most here: every signature handed to a signature opcode must be strictly DER-encoded, or the whole script fails. \begin{whymatters} \scheme obeys every consensus rule and breaks several relay policy rules. That costs a spending transaction only its ride over the peer-to-peer network, so it goes to a miner directly (Section~\ref{sec:deploy}). A forger can do the same, so we price his attack at consensus. \end{whymatters} \subsection{The transaction digest and FindAndDelete} \label{sec:fad} When a legacy script checks a signature, it verifies it against a digest $z$: the double SHA-256 of a copy of the spending transaction in which the input being checked carries the locking script (the ``script code''). Before hashing, the interpreter runs \fad: it removes from the script code every push that equals the signature being checked (for \op{CHECKMULTISIG}, each signature in turn). The match is byte-exact against the minimal push encoding. This quirk drives the whole family. Put $n$ dummy signatures in the locking script and let the spender feed $t$ of them to \op{CHECKMULTISIG}. Each chosen dummy is deleted from the hashed copy, so the digest depends on \emph{which} $t$ were chosen. The choice is a nonce of $\log_2\binom{n}{t}$ bits that moves $z$ without touching any transaction field. \fad exists only for legacy inputs; BIP~143 removed it from segwit. Since Bitcoin Core 0.16.1 the \flag{CONST\_SCRIPTCODE} relay policy flag rejects any transaction in which it deletes something, which is why no \scheme transaction can travel through the public mempool. \subsection{A fixed signature plus a transaction yields a public key} \label{sec:recovery} Normally a script holds a public key and the spender supplies a signature. Turn that around: the script holds a fixed signature $(r,s)$ and the spender supplies the key that makes it verify. ECDSA allows \emph{public-key recovery}: given a signature and the digest it signs, anyone can compute the key it verifies under, \begin{equation} P \;=\; r^{-1}\,(sR - zG), \qquad R \in \{\, \mathrm{lift}_x(r),\ \mathrm{lift}_x(r+n) \,\}\ \text{(each with two $y$ parities)}, \label{eq:recovery} \end{equation} where $n$ is the group order and $\mathrm{lift}_x$ turns an $x$-coordinate into a curve point. There are two candidate points $R$, or four when $r+n$ is also a valid $x$-coordinate, which holds for very small $r$. \begin{figure}[htbp] \centering \input{figures/keyrecovery.tex} \caption{The script fixes $(r,s)$ and the transaction fixes the digest $z$; together they determine the key $P$ (up to two or four candidates). Change one output and $P$ becomes an unrelated point.} \label{fig:keyrec} \end{figure} So if a script hard-codes $(r,s)$ and checks it with \op{CHECKSIGVERIFY} against a key the spender supplies, that key is forced: it must be one of the few points determined by $z$. Nobody chooses it, and nobody knows its discrete logarithm. A quantum computer could compute it, but that would not help, because the script never asks for a signature under $P$. The key is a public function of the transaction, and its only job is to put something that depends on $z$ on the stack for the next opcode to hash. Bitcoin's consensus rules accept three serialisations of each point: compressed (33~bytes), uncompressed (65~bytes) and hybrid-encoded (65~bytes, prefix \texttt{06} or \texttt{07}). All three hash differently, which matters for cost (Section~\ref{sec:layer5}). \subsection{The hash-to-signature puzzle} \label{sec:puzzle} Hash the recovered key with SHA-256 and hand the 32-byte result, the puzzle string, to a signature check. It signs nothing, but it has to look like a signature. A DER signature has a rigid layout: a header byte \texttt{30}, a length, two integers $r$ and $s$ each with its own tag and length, and a hashtype byte. The probability that a random 32-byte string parses as a strict-DER signature at consensus (any hashtype byte allowed) is \begin{equation} p \;=\; 2^{-45.4259}\ \approx\ \text{1 in 47 trillion}. \label{eq:p} \end{equation} % arithmetic: 2^45.4259 = 4.73e13 Six bytes must take exact values and two sign bits are constrained, summed over the 24 admissible splits between the lengths of $r$ and $s$~\cite{linus2026sha2ecdsa,levy2026qsb}. If the signature must also yield a recoverable key (as it must when checked by a \texttt{VERIFY} opcode), the probability drops to $2^{-46.011}$. \begin{figure}[htbp] \centering \input{figures/lottery.tex} \caption{The hash-to-DER puzzle as a lottery. The layout shown is one of the 24 allowed: six bytes are fixed and the first bytes of $r$ and $s$ must be below \texttt{0x80}. About one try in $2^{45.4}$ wins.} \label{fig:lottery} \end{figure} This is a \emph{hash-to-signature puzzle}~\cite{levy2026qsb}. Under \flag{DERSIG}, handing \op{CHECKSIG} a signature that is not strict DER makes the whole script fail. The DER grammar fixes the odds; there is no difficulty knob. \begin{example} One RTX~4090 tests about 4.7 to 6.4 billion candidates a second, depending on the stage. At 1 in 47 trillion, a winning ticket takes about two to three and a half hours on average. \end{example} % src: gpus.py MEASURED RTX 4090 (5.93 / 6.37 / 4.70 G/s); Table tab:hours below (2.06-2.79 h per solution) \begin{whymatters} The puzzle uses only a hash, so a quantum computer can speed up the search with Grover but cannot skip it. \qsb introduced this step in place of \binohash's quantum-breakable puzzle. \end{whymatters} % ===================================================================================== \section{Prior work: from Lamport in Script to QSB} \label{sec:prior} \begin{figure}[htbp] \centering \input{figures/timeline.tex} \caption{How we got here. Dates are publication or block dates.} \label{fig:timeline} \end{figure} \paragraph{Lamport signatures in Script} Heilman~\cite{heilman2024lamport} showed in 2024 how to sign a Bitcoin transaction with a Lamport signature and no soft fork, using the \emph{size} of an ECDSA signature as a transaction-bound value: with a fixed nonce giving a 21-byte $r$, short signatures are rare, so their size carries information. That rests on nobody finding a smaller $r$, which a discrete-log oracle does. \paragraph{\binohash (February 2026)} \binohash~\cite{linus2026binohash} combined three primitives in a bare legacy script: (i)~a \emph{signature-size} proof of work: with the smallest known $r$, whose discrete log is public, a signature of $60-k$ bytes proves about $8k+2$ bits of work; (ii)~the \fad nonce space of $\binom{n}{t}$ dummy signatures, made transaction-independent by the legacy \texttt{SIGHASH\_SINGLE} bug~\cite{todd2013single}; (iii)~a HORS-style signature on the chosen indices. A \emph{pinning} stage fixes the transaction, then two rounds of selection produce a digest of about 80 bits. Built for transaction introspection in BitVM bridges, it needs about $2^{44.6}$ honest work and gives about $2^{84}$ collision resistance. It was not designed to be post-quantum: Shor finds a point with a tiny $r$, which defeats the size puzzle at no cost~\cite{levy2026qsb}. \paragraph{sha2-ecdsa (March 2026)} Linus also showed, on mainnet, that a SHA-256 output can itself be a valid ECDSA signature~\cite{linus2026sha2ecdsa}: the hash-to-signature puzzle of Section~\ref{sec:puzzle}. \paragraph{\qsb (April 2026)} \qsb~\cite{levy2026qsb}, from StarkWare, keeps \binohash's skeleton and replaces the size puzzle with a hash-to-signature puzzle. The script hard-codes a signature $\sigma_{\text{nonce}}$ with \texttt{SIGHASH\_ALL}. The spender supplies $\mathit{key}_{\text{nonce}}$, which \op{CHECKSIGVERIFY} forces to be $\Rec(\sigma_{\text{nonce}},z)$; the script hashes it and checks the result as a signature under a spender-supplied key, which succeeds only if the hash is valid DER. The puzzle check must come before the round's \op{CHECKMULTISIG}, or the dependency is circular. Because $p$ is fixed and $\binom{n}{t}$ must exceed about $2^{46}$ for a solution to exist, \qsb adds \emph{bonus keys}: selections that take part in \fad but skip the HORS check, so a forger may choose them freely (about 20.5 bits of security). Its recommended ``Config~A'' ($n=150$, $t=8{+}1\mathrm{b},\,7{+}2\mathrm{b}$, 201 opcodes, 9{,}923 bytes) targets $2^{118}$ second-preimage resistance (Grover about 59) and an off-chain cost of about \$75--150 per spending transaction. Because every step of the search is public, \qsb can outsource it to untrusted GPUs; only the HORS secrets stay on the signing device. \paragraph{\qsb on mainnet (August 2026)} A \qsb spending transaction mined in block 964{,}199 on 26~August 2026 was the first post-quantum construction of this kind spent on mainnet~\cite{starkware2026mainnet}; a second followed in block 969{,}183. StarkWare also published a web app and SDK~\cite{qsbapp} and, with partners, ran a public GPU grinding contest~\cite{qsbchallenge}. \begin{table}[htbp] \centering\small \caption{What each work contributed.} \label{tab:lineage} \begin{tabularx}{\textwidth}{@{}l>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}X@{}} \toprule work & what it added & what it left open for post-quantum use \\ \midrule Lamport, HORS & signatures from hashes only & nothing to bind them to a Bitcoin transaction \\ Heilman 2024 & Lamport in Script; signature size as a transaction-bound value & size puzzle falls to Shor \\ \binohash & \fad selection as a digest nonce; HORS on the choice; pin then two rounds & size puzzle falls to Shor \\ \qsb & hash-to-signature puzzle on a recovered key; first mainnet spending transaction & Grover about 59; a 9.9~kB script \\ \scheme (this paper) & menus, shared table, ECDSA co-signature (a hybrid signature); Grover 64.05 & see Section~\ref{sec:limits} \\ \bottomrule \end{tabularx} \whatmeans{\scheme's hash-based mechanism is \binohash's and \qsb's. Our changes are about cost, reaching Category~1, and pairing it with an ECDSA co-signature.} \end{table} % ===================================================================================== \section{The construction, built up in layers} \label{sec:construction} We build \scheme from a toy, one layer at a time, each closing an attack the previous one allowed. Figure~\ref{fig:lockspend} shows the result: what goes on chain in the locking transaction and what appears in the spending transaction. \begin{figure}[htbp] \centering \input{figures/lockspend.tex} \caption{The locking transaction and the spending transaction, as they appear on chain. While the output is locked, the chain holds only hashes and fixed signatures. The spending transaction reveals 20 secrets, three keys recovered from the transaction, and the owner's ECDSA co-signature.} \label{fig:lockspend} \end{figure} \subsection{Layer 0: a hash lock} The simplest hash-based locking script is \texttt{OP\_SHA256 OP\_EQUAL}: whoever reveals $s$ may spend. Grover cannot find $s$ in any useful time. But the locking script says nothing about \emph{where} the funds go: whoever sees the spending transaction can copy $s$ into his own transaction paying himself. The secret must be bound to the transaction. \subsection{Layer 1: many secrets, chosen by the transaction} HORS (Section~\ref{sec:hors}) suggests the cure: hold $n$ commitments and let the transaction decide which $t$ secrets to reveal, so a forger with a different transaction would need secrets he does not have. Script cannot compute ``which $t$ entries does this transaction select?'', because it cannot cut bits out of a hash. So we turn the logic around with \fad (Section~\ref{sec:fad}): each table entry also carries a dummy signature. The spender \emph{chooses} $t$ entries, reveals their secrets, and the script deletes their dummy signatures before computing the transaction digest, so every choice leads to a different digest. \subsection{Layer 2: make most digests useless} \label{sec:layer2} The script must reject almost every digest. A signature hard-coded in the script and checked with \op{CHECKSIGVERIFY} forces the spender to put the recovered key $P = \Rec(\sigma, z)$ on the stack (Section~\ref{sec:recovery}). The script then hashes $P$ and requires the hash to parse as DER (Section~\ref{sec:puzzle}). Only about one digest in $2^{45.4}$ passes. The honest spender searches over choices of $t$ entries until one gives a passing digest. A forger who copied the secrets holds no others, so he cannot change the choice; he searches over \emph{transactions} instead, tweaking his own outputs until his digest passes. That search is as hard as the honest one (about $2^{45.4}$ tries, a few GPU-hours, and only $2^{22.7}$ with Grover), so forging costs the same as spending. \subsection{Layer 3: the forger must win every puzzle at once} \label{sec:layer3} The fix is to stack puzzles that the honest spender can solve \emph{one at a time} but a forger must solve \emph{together}. A \scheme spending transaction has three stages: \begin{enumerate}[leftmargin=*] \item \textbf{The pin.} A puzzle on the digest of the transaction alone (nothing deleted). The honest spender varies two harmless transaction fields, \texttt{nLockTime} and \texttt{nSequence}, until it passes. That fixes the transaction. \item \textbf{Round~1.} With the transaction fixed, he varies the choice of 8 table entries. Deleting their dummies changes the digest $z_1$; he searches until $z_1$'s puzzle passes. \item \textbf{Round~2.} The same, choosing 9 of the remaining entries, with digest $z_2$. \end{enumerate} Each stage has its own dial, so the honest searches \emph{add}: about $2^{45.4}$ per puzzle, one after another. The forger has the secrets for exactly one choice per round. His only dial is the transaction, and every tweak to it changes all three digests at once, so the chances that all three pass together \emph{multiply} to $2^{-136.3}$. The script accepts several forms of each key, and the forger may use those too; dividing by $6\cdot12\cdot4$ leaves $2^{128.1}$ (Equation~\ref{eq:sec}). The menu in Section~\ref{sec:layer5} adds tries for the owner only. \begin{figure}[htbp] \centering \input{figures/addmul.tex} \caption{The owner turns three dials in turn, so the three searches add. A forger who copied the secrets has one dial, the transaction, so the three chances multiply. His $2^{128.1}$ is that product divided by the key forms $6$, $12$ and $4$, which both sides may use; the owner's menu is not in that division.} \label{fig:addmul} \end{figure} Why not more than three? Each round costs about 90 of the 201 opcodes consensus allows, so two rounds plus the pin is what fits (Section~\ref{sec:full}). % src: `pqb inspect PQB` sections (10 / 86 / 97 ops of 199) \subsection{Layer 4: one table for both rounds} \label{sec:table} \qsb gives each round its own table; \scheme shares one. The table stores, for each index $i<109$, a 20-byte commitment \[C_i=\mathrm{RIPEMD160}(\mathrm{SHA256}(s_i))=\mathrm{HASH160}(s_i)\] and a 9-byte dummy signature \texttt{30 06 02 01 01 02 01 01}. Each dummy signature is pushed directly before its commitment, over a one-byte floor marker, and nothing else sits in the table; every depth the script uses is independent of which entries are chosen (Section~\ref{sec:gaps} explains the selection). % src: `pqb inspect PQB --disasm --section "shared chained table"` (sentinel 01, then dummy 300602010102010101..., commitment, ...) Round~1 opens an entry with the secret itself, checked with \op{HASH160}. Round~2 opens an entry with $\mathrm{SHA256}(s_i)$, checked with \op{RIPEMD160} (Figure~\ref{fig:table}). Both rounds compare against the same 20 bytes, so one table serves both at no extra opcode cost. \begin{figure}[htbp] \centering \input{figures/table.tex} \caption{One table entry opens at two rungs of $\mathrm{HASH160}=\mathrm{RIPEMD160}\circ \mathrm{SHA256}$. A forger who learns $s_i$ from Round~1 can compute $\mathrm{SHA256}(s_i)$, but Round~1 has already consumed that entry's dummy signature, so naming it again hands \op{CHECKMULTISIG} a neighbouring commitment, which is not a DER signature. The 9 values revealed for Round~2 cannot open anything in Round~1, since hashes do not run backwards.} \label{fig:table} \end{figure} \begin{attack}[: cross-round reuse] A forger walks down the hash chain, never up, and counting forces every value into one place. Round~1 needs 8 values that hash to commitments under \op{HASH160}; the forger has exactly the 8 that Round~1 revealed. Round~2 needs 9 values for entries still on the stack; he has exactly the 9 that Round~2 revealed, plus SHA-256 images of Round~1's secrets, whose entries are gone. \end{attack} Sharing removes the second table, which roughly halves the script. Each selection costs 7 counted opcodes: \[ \texttt{ ROLL}\ \ \texttt{DUP PICK}\ \ \texttt{ ROLL}\ \ \texttt{HASH160}\ \ \texttt{EQUALVERIFY}\ \ \texttt{ROLL} \] (fetch the index, copy the commitment it names, fetch the secret, check it against the copy, then consume the dummy signature under the commitment); Round~2 uses \op{RIPEMD160}. Why the \op{PICK} is safe is in Section~\ref{sec:gaps}. \qsb's signed selection costs 9. \subsection{Layer 5: a cheaper search for the owner alone} \label{sec:layer5} Layers 0--4 give security. The next two levers lower the honest spender's cost, under one rule: \emph{any freedom a revealed secret does not pin down is freedom the forger has too.} \paragraph{Committed menus} For each stage the locking script commits to a menu of $K$ fixed signatures, all with the same small $r$ and independent secret scalars $s_j\in[2^{250},2^{251})$, storing only $\mathrm{SHA1}(\sigma_j)$. The owner knows every entry and gets $K$ tries per digest; a forger who saw one spending transaction knows one entry and gets one. Because every entry shares $R$, \begin{equation} P_j \;=\; \underbrace{(r^{-1}s_j)\,R}_{A_j,\ \text{fixed}} \;+\; \underbrace{(n-r^{-1}z)\,G}_{B_z,\ \text{one per digest}}, \label{eq:menu} \end{equation} one curve multiplication per digest yields all $K$ keys, at one point addition each. The script checks the revealed entry with \texttt{ ROLL MIN ROLL ROLL TUCK SHA1 EQUALVERIFY}, then uses it as the stage's fixed signature. % src: docs/OUTSOURCING.md "Menu as points" Menu commitments use SHA-1 because no HORS rung (\op{RIPEMD160}, \op{HASH160}) produces a SHA-1 digest, so a selection index cannot be aimed at an unopened menu commitment. The scalars must be independent: any two revealed entries of an arithmetic progression would publish all of it. \paragraph{Key multiplicity} Every recovery point and serialisation the script accepts hashes differently, so each is another try. Let $m$ be the number of (recovery point, encoding) pairs a stage accepts. The two rounds use a 1-byte menu $r$, chosen so that $\mathrm{lift}_x(r+n)$ is on the curve and four recovery points exist. The pin uses $r=1$: $x=1$ is on the curve and $1+n$ is not, so it has exactly the two parities of $\mathrm{lift}_x(1)$, as a wide $r$ would, and its DER integer is one byte instead of 32, which takes 32 bytes off the \texttt{scriptSig}. Nobody knows the discrete logarithm of that point any more than of a random one, and the menu's unforgeability rests on the secret $s_j$, not on $r$. The 9-byte dummy signatures also have $r=1$, but a menu entry sits only in the \texttt{scriptSig}, never in the script code, and is never byte-identical to a dummy, so \fad cannot confuse the two. \cfg sets \[ m_{\text{pin}} = 2\times3 = 6,\qquad m_{1} = 4\times3 = 12,\qquad m_{2} = 4\times1 = 4, \] where Round~2 adds \texttt{OP\_SIZE <33> OP\_EQUALVERIFY} to accept compressed keys only. % src: published.json PQB stages m=[6,12,4]; grind.py Stage.n_points/encodings; `pqb inspect PQB --disasm --section "round 1"` (m-guard r1) Unlike the menu, $m$ helps both sides: the forger may use any form the script accepts, so $m$ enters his odds exactly as it enters the owner's (Section~\ref{sec:security}). It cannot go below 2: both $(x,y)$ and $(x,-y)$ are valid and no opcode tells them apart. Per elliptic-curve multiplication the honest spender gets $m\cdot K$ puzzle tries: $6\cdot12=72$ at the pin, $12\cdot16=192$ in Round~1 and $4\cdot16=64$ in Round~2. For comparison, \qsb gets 6. % src: published.json menu_K=[12,16,16]; computed with fleet.stage_models: tries/z 72, 192, 64; docs/HOW-IT-WORKS.md (192 per curve operation on round 0 against QSB's 6) \subsection{Layer 6: closing the gaps} \label{sec:gaps} A script can match the design on paper and still fail to enforce it. Three details decide that. \begin{attack}[: one secret, many selections] Every dummy signature is fetched with \op{ROLL}, which consumes it, so $t$ revealed secrets force exactly one deletion set. An \op{PICK} that fetched a signature would copy it, and since Core accepts a repeated signature against a repeated key, it would hand a forger $2^t$ deletion sets. \op{PICK} appears only in the selection \texttt{ OP\_ROLL OP\_DUP OP\_PICK OP\_ROLL OP\_EQUALVERIFY OP\_ROLL}: it copies the commitment $C_i$, which \op{EQUALVERIFY} binds to the revealed secret at once, and the final \op{ROLL}, at the same index, consumes the item one deeper, the dummy signature directly under $C_i$. The copied commitment stays on the stack, so a forger can name it again; the \op{ROLL} then hands \op{CHECKMULTISIG} whatever now sits under it, a neighbouring 20-byte commitment or the floor marker. That is safe exactly when none of those parses as a strict-DER signature: \flag{DERSIG} then fails the spending transaction, and ``\fad removed $t$ entries'' still means $t$ \emph{distinct} openings. A uniform 20-byte string passes Core's \texttt{IsValidSignatureEncoding} with probability about $2^{-40}$. The generator refuses any script in which one does, and \texttt{pqb check} checks every locking script again. This layout needs no one-byte filler per entry, which a consuming fetch of the commitment would need (109 bytes); with no sentinel under the three menu commitment tables either, the peak stack is 307 items. A red-team planted a DER-parsable commitment: the forgery then verifies in Bitcoin Core, and it fails against every script the generator accepts. % src: l1gen.py gadget pick2, der_screen, DERCollisionError; rules.py _r2_roll_not_pick, _pick_problems; tests/test_rules.py TestPick2DERScreen (E1 forgery, Core-verified) The script also starts with \texttt{OP\_DEPTH <62> OP\_EQUALVERIFY}, which fixes the number of \texttt{scriptSig} items, so a forger cannot pad the stack to shift indices onto items he controls. \end{attack} \begin{attack}[: a table that binds nothing] \fad matches only the exact minimal push encoding. A table pushed any other way is never deleted, the digest stops depending on the choice, and the script \emph{still verifies}. The number of deletions Core actually makes must therefore be exactly $t$ per round. \end{attack} \begin{attack}[: hashtype tricks] Every signature the script verifies ends in hashtype \texttt{0x01} (\texttt{SIGHASH\_ALL}). The script fixes that byte for the hard-coded ones; for the co-signature, the one signature the spender produces, no opcode is left to check it, so the signer must (Section~\ref{sec:hybrid}). A \texttt{SINGLE}-class hashtype is a replay when the input index is past the number of outputs: the legacy sighash is the constant 1, and the same unlocking script pays a different transaction. The rule is therefore: no \texttt{SINGLE}-class hashtype on any signature whose sighash is computed and whose check result matters. \cfg has neither ingredient: one input, one output, and \texttt{SIGHASH\_ALL} signatures. One puzzle digest in 32 lands in the \texttt{SINGLE} family, and \cfg keeps such a solution. Every \cfg puzzle is DER-only: its digest goes to \op{CHECKSIG} with an empty (\texttt{OP\_0}) public key, and the result is dropped or never read. Core's \texttt{CheckECDSASignature} rejects the empty key before it reads the hashtype byte or computes a sighash, so that byte selects nothing; \flag{DERSIG}, which is consensus, still checks the encoding first. A stage that verified its digest against a real key would discard \texttt{SINGLE}-class solutions, at a cost of 0.0459 bits of search. \cfg has none, and \texttt{pqb check} confirms that against the script bytes. \end{attack} \subsection{Layer 7: a hybrid signature} \label{sec:hybrid} The six layers above are a hash-based one-time signature, designed for one witness. Three things can publish more: paying the same locking script twice (each payment is a separate output, spent with its own witness), a broadcast that a miner refuses after the secrets have left the machine, and a flaw in the construction itself. Against a quantum forger nothing can repair the first two (Section~\ref{sec:exposure}). Against a classical one, an ordinary signature can. So the script opens, right after the depth guard, with a pay-to-public-key-hash check: \begin{center} \texttt{OP\_DUP OP\_HASH160 <20-byte hash> OP\_EQUALVERIFY OP\_CHECKSIGVERIFY} \end{center} The key is derived from the vault seed under its own label, independent of every hash-based secret, and only its HASH160 is in the locking script. The last two \texttt{scriptSig} items are the signature and the key, so the check consumes them first and no later stack depth moves. Everything after it is ANDed with it: a spending transaction needs a valid ECDSA signature over the whole transaction \emph{and} the hash-based witness: a \emph{hybrid signature} in the usual post-quantum sense, a classical and a post-quantum signature that must both verify. It costs 4 opcodes, 25 script bytes and about 107 bytes of \texttt{scriptSig}, and nothing in the search: the co-signature is made after the grind, on the owner's machine, over the transaction the grind fixed. % src: `pqb inspect PQB` co-signature section (4..28, 25 B, 4 ops); published.json cosig {form p2pkh, offset 4, hashtype SIGHASH_ALL} Two details decide whether the check enforces anything: \begin{itemize}[leftmargin=*] \item \textbf{The \op{DUP} is load-bearing.} Without it, the key is pushed twice and the hash check and the signature check run on different copies: a forger supplies the owner's key for one and his own key and signature for the other. Bitcoin Core accepts that forgery. \item \textbf{The signer pins the hashtype.} Every hashtype byte is valid at consensus, and the opcode budget leaves nothing to restrict it in Script. A \texttt{SIGHASH\_SINGLE} co-signature on an input with no matching output signs the constant 1 and would be valid for every output locked by the same script. The signer uses \texttt{SIGHASH\_ALL}, low-$s$ and RFC~6979 nonces, and refuses anything else. \end{itemize} The co-signature signs the same digest as the pin (which deletes nothing from the script code), under an unrelated key, so neither reveals anything about the other. Its security is ECDSA's: about $2^{128}$ classically, and nothing against Shor once the key has appeared in a spending transaction. \subsection{The full picture} \label{sec:full} Put together, a \scheme locking script is one bare legacy script with four parts (Figure~\ref{fig:script}): the ECDSA co-signature, a pinning stage, a shared table of $n=109$ entries, and two rounds that select $t_1=8$ and $t_2=9$ entries of it. Each hash-based stage contains a menu and ends in a hash-to-signature puzzle on a recovered key. % src: published.json PQB {n:109, t:[8,9], rounds:2} \begin{figure}[htbp] \centering \input{figures/script.tex} \caption{Layout of the 4{,}696-byte \cfg locking script, to scale. The shared table is most of the bytes and none of the opcodes. Opcode counts include the key counts charged by the two multisigs; the total is 199 of the 201 allowed. Round~2's \op{CHECKMULTISIG} is the last byte.} % src: `pqb inspect PQB` (sections table); published.json script.opcodes 199 \label{fig:script} \end{figure} \begin{figure}[htbp] \centering \resizebox{\textwidth}{!}{\input{figures/pipeline.tex}} \caption{The pipeline that builds a \cfg spending transaction. The pin searches transaction fields; each round searches subsets of the shared table, each subset once, about $2^{45.4}$ tries per stage. A round's finite space may hold no solution, and once all of it has been searched the spender re-pins. Hours are expected hours per solution on one RTX~4090 (Table~\ref{tab:hours}).} \label{fig:pipeline} \end{figure} % src (pipeline numbers): fleet.stage_models (spaces, P(solution) 0.786 / 0.941); Table tab:hours (2.21 / 2.06 / 2.79 h) \paragraph{One stage, precisely} Let $\mathsf{ser}_e(P)$ be encoding $e$ of point $P$ and $\Der$ the set of strings that parse as strict DER signatures. Stage $i$ with revealed menu entry $\sigma=(r,s)$ accepts a key $Q$ iff \begin{equation} Q=\mathsf{ser}_e(P),\ \ P=\Rec_v(\sigma,z_i)\ \text{for some recovery point } v,\ e \text{ allowed, and}\ \ \mathrm{SHA256}(Q)\in\Der . \label{eq:stage} \end{equation} \begin{figure}[htbp] \centering \resizebox{\textwidth}{!}{\input{figures/stage.tex}} \caption{One puzzle stage. The transaction (and, in a round, the deleted table entries) fixes $z_i$; the revealed menu entry and $z_i$ fix the key, accepted in any of $m$ forms, whose SHA-256 must be strict DER.} \label{fig:stage} \end{figure} In Script (Figure~\ref{fig:stage}): \begin{itemize}[leftmargin=*] \item \textbf{Pin} (10 opcodes):\\ \hspace*{1em}\texttt{2DUP CHECKSIGVERIFY\ \ SHA256 0 CHECKSIG\ \ }\\ \op{CHECKSIGVERIFY} checks $\sigma$ against the spender's key at $z_0$. Nothing in the script code matches a signature, so \fad removes nothing and $z_0$ depends only on the transaction. \op{2DUP} sets up the check, the menu check binds $\sigma$ to its commitment last, and the puzzle's \texttt{false} stays on the stack unread. \item \textbf{Round $k$} (86 and 97 opcodes): $t_k$ selections, the menu check, the $t_k$ dummy public keys and the round key, then\\ \hspace*{1em}\texttt{DUP SHA256 0 CHECKSIG DROP\ \ CHECKMULTISIGVERIFY}\\ The multisig checks the $t_k$ dummy signatures and $\sigma$ against the $t_k+1$ keys, after \fad has removed the $t_k$ selected dummies (and, in Round~2, also Round~1's) from the script code, so $z_k$ depends on the selection. Round~2 ends the script, in \op{CHECKMULTISIG} rather than \op{CHECKMULTISIGVERIFY} \texttt{OP\_1}: a bare script succeeds only if its final stack item is true, and that item is the multisig's result, so both forms accept exactly the same spending transactions and the last one is a byte shorter. This is not \qsb's unread-multisig defect, where a round's \op{CHECKMULTISIG} result ends up buried under later items that nothing reads: here nothing comes after it. \end{itemize} % src: `pqb inspect PQB --disasm` sections pinning / round 0 / round 1; inspect section table (10 / 86 / 97 ops); published.json find_and_delete_nfound [0,8,9] The dummy signatures carry hashtype \texttt{0x01}, and the spender recovers their public keys at the round's digest (a 9-byte signature has a recoverable key at any $z$). So \scheme needs no \texttt{SIGHASH\_SINGLE} filler input, and a spending transaction is a plain 1-input, 1-output transaction. \paragraph{The DER-only puzzle} The puzzle's public key is empty: the script pushes \texttt{OP\_0} where a key would go, and nothing reads the result. \flag{DERSIG}, a consensus rule, is checked on the signature before the public key is looked at, and makes a non-DER signature fail the whole script, while a DER-valid one that fails verification just pushes \texttt{false}; with an empty key every verification fails. So the predicate is ``valid DER'', probability $p=2^{-45.43}$, not ``valid DER with a recoverable key'' ($2^{-46.01}$), which saves 0.585 bits per stage. It depends on \flag{NULLFAIL} staying relay policy, and it is why \scheme spending transactions fail \flag{NULLFAIL} (Section~\ref{sec:deploy}). Leaving the result on the stack likewise relies on \flag{CLEANSTACK} being relay policy only. Earlier builds pushed a valid 33-byte key there, the generator $G$, so that the check would pass \flag{STRICTENC}'s public-key rule. It never did buy \flag{STRICTENC}: Bitcoin Core checks the signature's encoding, hashtype byte included, before the key's (\texttt{CheckSignatureEncoding} before \texttt{CheckPubKeyEncoding}), and the last byte of a ground digest is a random hashtype byte that is almost never a defined one, so the spending transaction already fails \flag{STRICTENC} there (Section~\ref{sec:deploy}), as do \qsb's. \texttt{OP\_0} saves 33 bytes per stage, 99 in all, and the relay policy flags a spending transaction fails stay the same four: \flag{STRICTENC}, \flag{NULLFAIL}, \flag{CLEANSTACK} and \flag{CONST\_SCRIPTCODE}. % src: l1gen.py der_pk33 CORRECTION (R14); Bitcoin Core interpreter.cpp EvalChecksigPreTapscript (CheckSignatureEncoding, then CheckPubKeyEncoding); versions.py v1 der_pk33=False; published.json 4,908 -> 4,809 B (then -1 B for tail_cms: 4,808 B; -109 B pick2 table, -3 B no menu sentinels: 4,696 B) \paragraph{The pinning nonce} The pin needs enough \emph{solutions}, not just tries: with 72 tries per nonce and $p\cdot\frac{31}{32}$ per try, the $2^{32}$ values of \texttt{nLockTime} alone hold only 0.0064 expected solutions. PQB uses the same two fields as \qsb's mainnet spending transaction, \begin{align*} \texttt{nLockTime} &= 500{,}000{,}000 + (\nu \bmod 1{,}200{,}000{,}000), \\ \texttt{nSequence} &= \texttt{0x80000000} + \lfloor \nu / 1{,}200{,}000{,}000 \rfloor, \end{align*} a space of about $2^{61.16}$ nonces $\nu$ (about $3.8\times10^{6}$ expected solutions). % src: grind.py PIN_LT_MIN/END, PIN_SEQ_MIN/MAX, PIN_NONCE_SPACE (~2^61.16); docs/OUTSOURCING.md (3.8e6 at 2^61.2) Every \texttt{nLockTime} is a past timestamp (1985--2023), so the transaction is always final; bit 31 of \texttt{nSequence} disables BIP~68 relative locks. Both fields sit after the script code in the legacy serialisation, so a grinder rehashes only a short tail per nonce. \paragraph{Spending, step by step} The owner fixes the outputs and the fee, then: \begin{enumerate}[leftmargin=*] \item exports a public \emph{packet} per stage: the script, the transaction template, the nonce range, and the menu as curve points $A_j$ (never the scalars); \item has the pin searched, on any hardware, for a nonce passing~\eqref{eq:stage}; \item has Round~1 searched over the $\binom{109}{8}\approx2^{38.47}$ subsets, then Round~2 over the $\binom{101}{9}\approx2^{40.93}$ subsets of the remaining entries, each subset once, going back to step~2 only when a round's whole space has been searched without a solution; % src: fleet.stage_models space = comb(109,8), comb(101,9); log2 computed 38.467, 40.925 \item re-derives every solution on the signing device from its own secrets; \item signs the transaction with the ECDSA co-signing key, assembles the 62-item \texttt{scriptSig} (Table~\ref{tab:witness}) and checks it with Bitcoin Core's \texttt{VerifyScript}; \item submits it once, directly to a miner. \end{enumerate} \begin{table}[htbp] \centering\small \caption{The 62 \texttt{scriptSig} items of a \cfg spending transaction. The total is 1{,}426 bytes for the reference spending transaction when all three recovered keys come out compressed, and 32 bytes more for each that does not; the 17 selection indices are 1--3-byte pushes, so it moves by a few bytes with the chosen subset.} % src: `pqb inspect PQB --witness`; published.json versions.v1 scriptsig_bytes 1426, scriptsig_items 62; over 300 random subsets the mean is 2.5 B below the stride-3 layout's, the maximum equal \label{tab:witness} \begin{tabular}{@{}lrl@{}} \toprule item & count & role \\ \midrule recovered stage keys & 3 & pin key, Round~1 key, Round~2 key \\ dummy public keys & 17 & recovered from the selected 9-byte dummy signatures \\ HORS secrets & 17 & 8 values $s_i$ of 160 bits (Round~1), 9 values $\mathrm{SHA256}(s_i)$ (Round~2) \\ selection indices & 17 & which table entry each selection fetches \\ menu entries and indices & 6 & one revealed signature and its index per stage \\ co-signature & 2 & the owner's ECDSA signature (\texttt{SIGHASH\_ALL}) and public key \\ \midrule total & 62 & 20 of them are secret until broadcast \\ \bottomrule \end{tabular} \whatmeans{a spending transaction publishes 20 secrets (17 HORS secrets and 3 menu entries). Everything else is recovered from the transaction, an index, or the co-signature.} \end{table} \subsection{What \scheme inherits, and what is new} \label{sec:delta} Table~\ref{tab:delta} separates what \scheme takes from \binohash and \qsb from what is new. \begin{table}[H] \centering\small \caption{Where each component comes from.} \label{tab:delta} \begin{tabularx}{\textwidth}{@{}>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}p{4.1cm}@{}} \toprule component & origin \\ \midrule \fad selection as a digest nonce; HORS on the chosen indices; pin then two rounds; \op{ROLL}-based selection; bare legacy script; miner-direct submission & \binohash~\cite{linus2026binohash} \\ hash-to-signature puzzle on a key recovered from a hard-coded \texttt{SIGHASH\_ALL} signature; puzzle before the round's multisig; outsourcing the public search; \texttt{nSequence}$\times$\texttt{nLockTime} pinning nonce & \qsb~\cite{levy2026qsb} and its mainnet spending transaction; DER probability from~\cite{linus2026sha2ecdsa} \\ \midrule committed menus of $K$ signatures sharing $r$ ($K$ keys per multiplication) & new \\ $m$ as a dial: 4 recovery points via a 1-byte $r$, 3 encodings, \texttt{OP\_SIZE} guard; $r=1$ at the pin (2 points, a 1-byte integer) & new \\ one table for both rounds through the \op{HASH160}/\op{RIPEMD160} rungs; no bonus keys & new \\ 7-opcode selection; \texttt{OP\_DEPTH} guard instead of per-selection clamps & new \\ DER-only puzzle against an empty key, \texttt{OP\_0} (0.585 bits and 33 bytes per stage) & new \\ dummy signatures with hashtype \texttt{0x01} and recovered keys; no filler input & new \\ the script-level details of Section~\ref{sec:gaps}; exposure analysis & new \\ pin checks first and binds its menu last; the pin puzzle's result left on the stack; 160-bit HORS secrets & new \\ an ECDSA co-signature ANDed with the hash-based signature (a hybrid signature) & new \\ \bottomrule \end{tabularx} \whatmeans{the mechanism is theirs. The asymmetric levers, the table sharing and the hybrid signature are ours.} \end{table} % ===================================================================================== \section{Security} \label{sec:security} \subsection{Goal and threat model} \label{sec:model} \paragraph{Goal} A UTXO $U$ is locked by a script $L$. The owner holds a seed from which every secret in $L$ and the ECDSA co-signing key are derived. An adversary who sees everything public, including one valid transaction spending $U$ (while it waits at a miner, or after a reorg), should not be able to produce a \emph{different} valid transaction spending $U$ at a cost below the security level. \paragraph{Adversaries} \begin{itemize}[leftmargin=*] \item $\mathcal{A}_{\mathrm{cl}}$, \emph{classical}: a large GPU budget, no quantum computer. \item $\mathcal{A}_{\mathrm{q}}$, \emph{quantum}: everything $\mathcal{A}_{\mathrm{cl}}$ has, plus an oracle that returns the discrete logarithm of any secp256k1 point (Shor), plus Grover search over any efficiently computable predicate~\cite{grover1996}. \end{itemize} Both are \emph{miner-direct}: they can get any consensus-valid transaction mined, so relay policy does not bind them. \paragraph{Security measure} We report SEC, the base-2 log of the expected number of transaction-digest evaluations (each one a legacy sighash, a key recovery and a hash) that the cheapest known forgery needs, and $\mathrm{Grover}=\mathrm{SEC}/2$, the log of the number of Grover queries. We take NIST Category~1, ``at least as hard as key search on AES-128''~\cite{nist2016cfp}, to mean $\mathrm{Grover}\ge 64$. \paragraph{Assumptions} \begin{enumerate}[label=(A\arabic*), leftmargin=*] \item \emph{Hash functions.} SHA-256, RIPEMD-160 and SHA-1 are preimage resistant, up to generic (Grover) attacks. No security claim uses collision resistance. The 20-byte commitments face a multi-target second-preimage search that sits above Grover 76. \item \emph{Random behaviour.} On inputs a forger cannot control, the legacy sighash, ECDSA key recovery and SHA-256 together behave like a random function, so each new digest is an independent trial of the DER predicate with probability $p$. Independence between re-pins was checked on 600k real re-pins. \item \emph{Consensus is unchanged.} \fad, legacy ECDSA verification with recovered keys, undefined hashtype bytes, hybrid-encoded and empty public keys and a discarded failing signature check all stay consensus-valid, and \flag{NULLFAIL} stays relay policy (the DER-only puzzle depends on it). \item \emph{Secrets stay secret} until the spending transaction reveals them, and only one witness is ever revealed (Section~\ref{sec:exposure}). \item \emph{The menu stays secret}: no adversary with a discrete-log oracle learns the menu's curve points, which holds unless outsourced packets reach $\mathcal{A}_{\mathrm{q}}$ (Section~\ref{sec:exposure}). \item \emph{ECDSA holds classically.} Without a discrete-log oracle, forging an ECDSA signature on secp256k1 under a key one does not hold costs about $2^{128}$, whether or not the key is public. The co-signing key is derived from the seed and used for nothing else. \end{enumerate} \subsection{The forger's game} Fix a locking script $L$ and one published spending transaction $\mathit{tx}$ with witness $W$. The forger knows everything in $W$: 8 Round~1 secrets, 9 Round~2 values, and one menu entry per stage. He wants a valid spending transaction $\mathit{tx}'\ne\mathit{tx}$ with different outputs. \begin{itemize}[leftmargin=*] \item \textbf{Round choices are fixed.} \op{ROLL} consumption, the \texttt{OP\_DEPTH} guard and the chained table leave him exactly the honest selections, up to reordering, and reorderings give a byte-identical digest. \item \textbf{Menu choices are fixed.} Opening another menu entry needs a SHA-1 preimage. \item \textbf{Keys are fixed.} Each key is $\Rec_v(\sigma,z)$ in one of $m$ accepted forms. \item \textbf{What remains} is the choice of $\mathit{tx}'$ (outputs, and the pinning fields), which determines $z_0$ and, with the fixed selections, $z_1$ and $z_2$. \end{itemize} So each candidate $\mathit{tx}'$ passes the pin with probability $m_{\text{pin}}\,p$; a pinned $\mathit{tx}'$ then passes both rounds with probability $m_1p\cdot m_2p$, with no further freedom. The expected number of digest evaluations is $\bigl(m_{\text{pin}}m_1m_2\,p^3\bigr)^{-1}$: \begin{equation} \begin{aligned} \mathrm{SEC} &\;=\; \sum_{i\in\{\text{pin},1,2\}} \bigl(\log_2 \tfrac1p - \log_2 m_i\bigr)\\ &\;=\; 3\times45.4259 - \log_2(6\cdot12\cdot4) \;=\; 136.278 - 8.170 \;=\; 128.108 . \end{aligned} \label{eq:sec} \end{equation} The menu widths $K$ do not appear: the forger knows one entry per stage, so they change only the owner's search, unless the menu leaks (Table~\ref{tab:exposure}). Nor do $n$ and $t$, which only have to leave each round's search space with a solution in it (Figure~\ref{fig:pipeline}). \eqref{eq:sec} prices the forger at consensus; \flag{STRICTENC} and the rest of relay policy bind the honest spending transaction only, as would a \texttt{SIGHASH\_SINGLE} filter, which no \cfg stage needs. With Grover search over $\mathit{tx}'$ the cost is $2^{\mathrm{SEC}/2}=2^{\grover}$ queries. Every $\mathit{tx}'$ also needs an ECDSA co-signature under the owner's key, and a signature over $\mathit{tx}$ is not one over $\mathit{tx}'$. $\mathcal{A}_{\mathrm{cl}}$ has to forge it, about $2^{128}$ by (A6), on top of \eqref{eq:sec}. $\mathcal{A}_{\mathrm{q}}$ reads the key from $W$ and computes its logarithm, so for him the co-signature is free and \eqref{eq:sec} is the whole bound. \begin{claim} Under assumptions (A1)--(A6), a forger in either model who has seen one \cfg spending transaction needs about $2^{128.1}$ classical digest evaluations or $2^{64.05}$ Grover queries to spend the same UTXO differently, and a classical forger must in addition forge an ECDSA signature. \end{claim} \noindent The probability $p$, the multiplicities $m=6/12/4$, and the factorisation $\text{accepted}=\text{HORS}\times\text{menu}\times\text{selector}$ were checked against Bitcoin Core's interpreter (276{,}456 verifications, no deviation). \begin{figure}[htbp] \centering \input{figures/attackcost.tex} \caption{Honest spender versus forger, on a log scale. The owner's three searches add up to about $2^{47}$ tries. A forger who saw one spending transaction needs $2^{128.1}$ classical digest evaluations or $2^{64.05}$ Grover queries; one who saw two needs $2^{44.94}$ Grover queries. The ECDSA co-signature keeps a classical forger at about $2^{128}$ however many witnesses are public. \qsb's Config~A is at about $2^{59}$ Grover queries.} \label{fig:attackcost} \end{figure} \subsection{Shor recovers keys that sign nothing} \label{sec:dlog} $\mathcal{A}_{\mathrm{q}}$ can compute the discrete logarithm of every public key in sight. The co-signing key is the one key that belongs to someone, and Shor takes it as soon as it appears in a spending transaction, which is why the co-signature is only a classical safeguard. Apart from it, no check in the script uses a key the spender chooses: every hash-based key is the output of~\eqref{eq:recovery} on a hard-coded or committed signature and a digest the spender does not control beyond $\mathit{tx}'$. Knowing $\log P$ does not change $P$, nor $\mathrm{SHA256}(P)$, nor whether it parses as DER. The puzzle's public key is empty, so there is no key to forge a signature under, and the puzzle's verification result is discarded anyway. The only secret a discrete-log oracle could reach is a menu scalar $s_j$, from its point $A_j=(r^{-1}s_j)R$; the honest spender never publishes those points except in outsourced work packets (Section~\ref{sec:exposure}). \subsection{Grover, and NIST Category 1} The best known quantum attack is Grover search over $\mathit{tx}'$ for the joint predicate of the three stages: $2^{64.05}$ sequential queries. Each query includes a legacy sighash over a multi-kilobyte preimage, a secp256k1 scalar multiplication and SHA-256, so as a circuit it costs far more than an AES-128 evaluation, and Grover parallelises only as $\sqrt{k}$ over $k$ machines. In the oracle-query convention \cfg clears Category~1 with 0.05 bits to spare. The family's ceiling with two rounds and no trusted setup is $3\times(46.840-1)=137.52$ SEC, Grover 68.76; we chose the cheapest configuration at Category~1 rather than the most secure one. \subsection{Exposure: what extra disclosure costs} \label{sec:exposure} Table~\ref{tab:exposure} gives the security when the forger learns more than one witness reveals. \begin{table}[htbp] \centering\small \caption{\cfg security under extra disclosure (Grover bits). Category~1 is 64.} \label{tab:exposure} % src: published.json PQB exposure; docs/OPERATING-RULES.md O1/O5 tables; docs/OUTSOURCING.md "Disclosure cost" \begin{tabular}{@{}lrl@{}} \toprule what the forger knows & Grover & why \\ \midrule one witness (the design point) & \textbf{64.05} & \\ one witness + one extra HORS secret & 60.81 & 6.49 SEC bits, $\log_2(9\cdot10)$ \\ one witness + the menu points (outsourced search) & 58.26 & full menu width for the forger \\ two different witnesses & \textbf{44.94} & a second set of secrets per round \\ \bottomrule \end{tabular} \whatmeans{publish one spending transaction per locking script, ever. A small leak costs a few bits; a second witness costs about 19.} \end{table} \paragraph{One witness, ever} A second witness reveals a second set of secrets, and the forger's reachable selections grow by roughly $\binom{2t}{t}$ per round. No two-round configuration of this family survives a second witness at any price: the family's whole exposure budget is 9.52 SEC bits, and the HORS channel alone costs far more. Rebroadcasting the \emph{same} bytes, or a reordered \texttt{scriptSig}, costs 0.00 bits. PQB enforces this with an append-only journal and no override flag. The co-signature does not relax the rule: the forger who profits from a second witness is $\mathcal{A}_{\mathrm{q}}$, who has the co-signing key from the first. \paragraph{Outsourcing} A rented GPU needs the menu \emph{points} $A_j$ but never the scalars, and a classical grinder learns nothing useful from them. A grinder who later gains a discrete-log oracle \emph{and} sees the spending transaction could compute every $s_j$ and use the whole menu, which costs 5.79 Grover bits (58.26). Exporting one menu point per stage avoids this but makes the search 98$\times$ slower. PQB exports all points by default and says so. \subsection{Composition: what the hybrid signature buys} \label{sec:compose} A spending transaction verifies only if both halves do, so a forger pays for both (Table~\ref{tab:compose}). Paying one locking script twice, a refused broadcast whose secrets leaked, or a flaw in the hash-based half all move the middle column, but none of them helps a classical forger. \begin{table}[htbp] \centering\small \caption{The two halves of \cfg's hybrid signature against each adversary. Hash-based figures are SEC (classical) and Grover bits; ECDSA is the classical bound of (A6).} \label{tab:compose} % src: published.json PQB security (sec_bits 128.108, grover_bits 64.054), exposure (second_broadcast_grover 44.94), cosig (classical_bits 128) \begin{tabular}{@{}llll@{}} \toprule forger, and what is public & ECDSA co-signature & hash-based half & the spending transaction \\ \midrule $\mathcal{A}_{\mathrm{cl}}$, one witness & $\approx2^{128}$ & $2^{128.1}$ & $\approx2^{128}$ \\ $\mathcal{A}_{\mathrm{cl}}$, several witnesses, or a flaw & $\approx2^{128}$ & lower & $\approx2^{128}$ \\ $\mathcal{A}_{\mathrm{q}}$, one witness & free (Shor) & Grover 64.05 & Grover 64.05 \\ $\mathcal{A}_{\mathrm{q}}$, two witnesses & free (Shor) & Grover 44.94 & Grover 44.94 \\ \bottomrule \end{tabular} \whatmeans{without a quantum computer, a \cfg output is at least as hard to steal as an ordinary Bitcoin output, whatever has gone wrong with its hash-based half. With one, it is exactly as hard as the hash-based half.} \end{table} % ===================================================================================== \section{Cost} \label{sec:cost} \subsection{Work per stage} Each stage is a hunt for one success at probability $p$ per try, with $\tau$ tries per elliptic-curve multiplication: $\tau_{\text{pin}}=72$, $\tau_1=192$, $\tau_2=64$. The pin's space is effectively unlimited. The rounds search a \emph{finite} space. Round~1's $\binom{109}{8}$ subsets times 192 tries hold a solution with probability $1-e^{-\lambda_1}$, where $\lambda_1=\binom{109}{8}\cdot192\cdot p\approx1.54$, that is 0.786; Round~2's hold one with probability 0.941. (No stage pays the $\frac{31}{32}$ \texttt{SIGHASH\_SINGLE} filter: every \cfg puzzle is an \texttt{OP\_0} DER-only tail, Section~\ref{sec:gaps}.) The rounds are searched by enumeration, not sampling: the subsets are ranked in lexicographic order, the ranks are split into chunks, and the controller hands the chunks to the cards, so every subset is tried exactly once. A round with a solution costs on average a fraction $1/(K+1)$ of its space, where $K$ is the number of solutions in it; a round without one is known to be empty once its whole space has been searched, and only then does the spender re-pin. For a given pin, Round~1's space is empty with probability 21.4\% and Round~2's with 5.9\%. Appendix~\ref{app:costmodel} gives the procedure and the expected-cost formula. \subsection{Expected hours} \label{sec:cost-hours} At measured single-card RTX~4090 rates (Appendix~\ref{app:gpus}), the model gives \textbf{\hoursall 4090-hours} per spending transaction. Sampling subsets at random, with a cost-optimal point at which to give up on a round, costs 11.6, so enumeration saves 31\%. A grinder that refused hybrid-encoded keys, which consensus accepts and \flag{STRICTENC} rejects, would need 1.45$\times$ as long. % src: tests/test_cloud.py TestPlan (7.98; 11.57 with hybrid keys refused; 8.31 with the SINGLE filter forced on); random sampling at cost-optimal cutoffs 11.55 (16.98 hybrid refused), same model as the 12.11/17.85 it replaces; fleet.stage_models p_empty 0.214 / 0.059 \begin{table}[htbp] \centering\small \caption{Expected RTX~4090-hours per \cfg spending transaction (cost model at measured single-card rates; spread from 40{,}000 simulated spending transactions).} % src: fleet.expected_hours 7.977; fleet.simulate(n=40000): median 6.51, p90 15.40, p99 28.6 \label{tab:hours} \begin{tabular}{@{}rrrrrr@{}} \toprule \multicolumn{3}{c}{hours per solution} & \multicolumn{3}{c}{hours per spending transaction} \\ \cmidrule(lr){1-3}\cmidrule(lr){4-6} pin & round 1 & round 2 & expected & median & 90th pct. \\ \midrule 2.21 & 2.06 & 2.79 & \hoursall & 6.5 & 15.4 \\ \bottomrule \end{tabular} \whatmeans{a typical spending transaction takes about six and a half hours on one RTX~4090, or minutes on a rented fleet. One spending transaction in ten takes more than twice the median.} \end{table} \begin{figure}[htbp] \centering \input{figures/costbreak.tex} \caption{What a \cfg spending transaction costs. Top: hours on one RTX~4090. Bottom: dollars. The search is about \$3, and the chain fees about \$5 at 1~sat/vB.} \label{fig:costbreak} \end{figure} % src (figure): Table tab:hours; ยง6.4 ($3.1 = 8.0 h x $0.35 + $0.37 start-up); published.json versions.v1 cost.chain_vb 6,303; 6,303 sats at 1 sat/vB x $85,000/BTC = $5.36 \paragraph{No precomputation} Every digest commits to the spending transaction's own outpoint, so no table can be built before the UTXO exists. Fixed-base comb tables, the only precomputable part, are worth at most about 1.15$\times$. \subsection{Grinder speed} The pin's search is memoryless: its space is so large that every card draws its own nonces and needs no coordination. A round's cards work through the chunks of ranks the controller hands them, which it credits only once their hits are in, so no subset is searched twice. The search is bound by 32-bit integer throughput, so data-centre cards lose per dollar: an H100 runs at a little over half an RTX~4090's speed. Appendix~\ref{app:gpus} lists steady-state rates for 19 models. \subsection{Dollars: a value-priced fleet} PQB prices each rental offer per 4090-hour of work it delivers (its \$/h divided by its speed in 4090-equivalents, weighted by the stage mix), takes the cheapest work first, and mixes models. A spending transaction costs about \$3 (\hoursall RTX~4090-hours); five measured runs on the default fleet (vast.ai, November 2026) cost \$1.06--\$3.79, mean \$1.98, in 8.5 to 30 minutes. % src: user-supplied fleet measurements, Nov 2026 (five default-fleet runs: $1.84, $2.01, $1.06, $1.19, $3.79) The fleet is sized so that its expected cost stays within a margin (50\% by default) of the cheapest single box; larger margins buy wall-clock time. Every box receives only public data: the legacy-sighash preimage, the menu points and a 24-bit DER prefix to report (\texttt{30 1D 02}, the fixed start of a 32-byte strict-DER signature). It streams back prefix hits (about $2^{21}$ per full solution), and the controller re-derives every one. A box whose hits do not reproduce, whose hit count does not match its claimed work, or which runs slow is destroyed. % src: docs/OUTSOURCING.md "On a GPU" (30 1D 02 prefix, ~2^21 per solution); fleet.py docstring \subsection{On-chain cost} \label{sec:chaincost} The locking transaction is about 4.8~kvB (about 4{,}786~vB for a sweep with one segwit input) and the spending transaction about 1.51~kvB (1{,}510~vB with all recovered keys compressed; each key that is not compressed adds 32 bytes). The published model puts both at 6{,}303~vB, about 6{,}303 sats at 1~sat/vB. % src: published.json versions.v1 cost.chain_vb 6303; spend = scriptSig 1,426 B + 84 B of transaction (Spend.assemble, one P2WPKH output; legacy, so vB = B); sweep = the pre-v1 regtest 4,998 vB less the measured 99-byte script reduction, the 1-byte tail_cms reduction and the 112-byte pick2 + no-menu-sentinel reduction \subsection{Comparison with \qsb} \begin{table}[htbp] \centering\small \caption{\scheme and \qsb side by side. \qsb figures are from its paper, its mainnet transactions and the public grinding contest; we did not re-measure \qsb's search.} \label{tab:compare} \begin{tabular}{@{}lll@{}} \toprule & \qsb (Config A) & \scheme \\ \midrule works under today's consensus rules & \cmark & \cmark \\ spent on mainnet & \cmark{} blocks 964{,}199, 969{,}183 & \cmark{} block 975{,}838 \\ Grover & $\approx$59 & 64.05 \\ reaches Category~1 (Grover $\ge 64$) & \xmark & \cmark{} (by 0.05) \\ one-input, one-output spending transaction & \xmark{} 2-in/1-out & \cmark \\ passes \flag{NULLFAIL} relay policy & \cmark & \xmark{} DER-only puzzle \\ relayable through the public mempool & \xmark & \xmark \\ hybrid signature (ECDSA co-signature) & \xmark & \cmark \\ \midrule locking script & 9{,}923 B, 201/201 ops & 4{,}696 B, 199/201 ops \\ spending transaction size & 1{,}403 B & $\approx$1{,}510 vB \\ HORS tables & 2 $\times$ 150 + bonus keys & 1 $\times$ 109, shared \\ search cost, published & \$75--150 & -- \\ search cost, current & \$60 & \$3 \\ \bottomrule \end{tabular} \whatmeans{building on \qsb, \scheme halves the locking script and brings the expected search to \textasciitilde\$3, 20$\times$ cheaper than \qsb's \$60 grind, reaches Category~1 and adds an ECDSA co-signature. \qsb's spending transactions pass \flag{NULLFAIL}; \scheme's do not.} \end{table} % QSB "as specified": its paper's 2^118 halves to 59. Much of \scheme's advantage in search cost comes from asymmetries the forger does not share (the menu, the encodings), and from spreading each elliptic-curve multiplication over $mK$ tries. The contest's faster elliptic-curve kernels help \qsb about $4.8\times$ and would help us only about $1.1$--$1.4\times$. % ===================================================================================== \section{Implementation} \label{sec:impl} \subsection{The reference implementation} The reference implementation, PQB~\cite{pqb}, is a Python command-line tool and library, with a byte-identical TypeScript port of the core. A vault is created from a 32-byte seed (random, or a BIP-85 child of a wallet) that determines the locking script script and every secret in it. \texttt{grind export} binds work packets to the exact outputs and fee; \texttt{cloud grind} runs the fleet of Section~\ref{sec:cost} and re-derives every hit locally. \texttt{sign} builds the witness and adds the ECDSA co-signature (\texttt{SIGHASH\_ALL}, low-$s$, RFC~6979, after checking the derived key's HASH160 against the locking script). \texttt{verify} runs the spending transaction through Bitcoin Core's \texttt{VerifyScript} under consensus flags and then under each relay policy flag separately, plus the script-level checks of Section~\ref{sec:gaps}. \texttt{broadcast} records the vault in an append-only journal before submitting once to a miner; only identical bytes can be resubmitted. % src: pqb --help; SECURITY.md; OPERATING-RULES O1 Several details keep the script and the search small. Each DER-only puzzle pushes an empty key (\texttt{OP\_0}), since nothing ever verifies against it; the pinning menu uses $r=1$; the script ends in \op{CHECKMULTISIG}, whose result is the final stack top \texttt{VerifyScript} reads; and the table is selected with \op{PICK} and \op{ROLL} under a strict-DER screen, with no sentinel under the menu commitment tables. The locking script is 4{,}696 bytes and the reference \texttt{scriptSig} 1{,}426. The search enumerates the rounds instead of sampling them, and the \texttt{SIGHASH\_SINGLE} filter applies only to a stage that verifies its digest against a real key, which no \cfg stage does: the expected search is \hoursall RTX~4090-hours. A vault's seed is bound to this script and to its network (BIP-85), so one wallet index never yields the same one-time secrets under two scripts. % src: pqb/src/pqb/versions.py (VERSIONS, LATEST = 'v1'); bip85.vault_seed; git HEAD published.json (pre-v1: 4,908 B, peak 417, scriptsig 1,461) vs versions.v1 (4,696 B, 307, 1,426); per-change bytes by toggling der_pk33 / pin_r1 / tail_cms / gadget / no_msent in l1gen.build (4,908 -> 4,809 -> 4,809 [scriptSig 1,461 -> 1,429] -> 4,808 -> 4,699 -> 4,696); tests/test_cloud.py TestPlan (12.11 sampled with the filter, 8.31 enumerated with it, 7.98 now) We ran 32 full-scale research scripts through Core's \texttt{VerifyScript}; the generator's opcode, byte and stack model matched Core exactly, and the test suite re-checks \cfg's own figures against Core. Test spending transactions of \cfg, with the puzzle stages stubbed at identical size, are funded and spent on regtest with byte-flip negative controls, and Core rejects forged, re-targeted and wrong-hashtype co-signatures. \scheme has been locked and spent on mainnet, with real puzzles at full scale. A vault (a 4{,}696-byte script) was locked in \texttt{7bad128d\ldots} in block 975{,}813 and spent in \texttt{0b2b0ea1\ldots} in block 975{,}838: a 1{,}508~vB spending transaction with a 1{,}424-byte scriptSig, ground on rented GPUs. % src: the vault journal (cloud-start 17:18:46Z, cloud-end 17:46:30Z, spent_usd 2.6286); mempool.space; v1 round: mempool.space 7bad128d (block 975,813, fee 14,361) and 0b2b0ea1 (block 975,838, 1,508 vB, fee 4,743) \subsection{The grinder} The CUDA grinder has one template per stage shape. Per digest it computes the transaction digest from a cached midstate (only the tail after the varied field is rehashed), one fixed-base scalar multiplication $B_z$, then $mK$ point additions with batched affine conversion, fused with the SHA-256 of each serialised key. In a round it walks the ranges of subset ranks it is given and records each range it finishes. It runs at about 82--92\% of its operation-count floor on an RTX~4090: hashing is at the integer-pipe limit, and the round's legacy-sighash work (a 24-block tail per subset) is inherent. \subsection{PQB Explorer} PQB Explorer~\cite{pqbexplorer} (\url{https://pqbexplorer.com}) indexes mainnet from block 949{,}973 (the first known \qsb transaction), recognises \scheme locking scripts by skeleton templates exported from PQB, decodes \qsb structurally, and re-executes every post-quantum spending transaction with an in-browser legacy interpreter that passes Core's script and sighash test vectors. Locking scripts are named by a non-payable bech32m lookup address (\texttt{pqb1q\ldots} for \scheme), derived from the SHA-256 of the script. % ===================================================================================== \section{Relay policy} \label{sec:deploy} \subsection{The spending transaction cannot use the public mempool} Nothing about a \scheme locking script is consensus-invalid, but relay policy keeps it out of the public mempool. Relay policy rejects transactions that create or spend bare scripts. More importantly, \fad is how the construction works, and every mempool path in Bitcoin Core checks legacy inputs under \flag{CONST\_SCRIPTCODE}, even with \texttt{-acceptnonstdtxn}; Libre Relay keeps the flag too. So the locking transaction and the spending transaction both go to a miner directly. The one post-quantum design we found that conforms to relay policy (single-input P2WSH) costs about \$269k per spending transaction. Four relay policy flags fail on a \cfg spending transaction, all in the hash-based half; the ECDSA co-signature passes every one. Table~\ref{tab:policy} runs Core's \texttt{VerifyScript} with each relay policy flag added to the consensus set, one at a time. \begin{table}[htbp] \centering\small \caption{Which relay policy flags a spending transaction fails (Core's \texttt{VerifyScript}, each flag on top of consensus). For \flag{STRICTENC} the reason is given.} \label{tab:policy} \setlength{\tabcolsep}{4.5pt} \begin{tabular}{@{}lccccc@{}} \toprule spending transaction & consensus & \flag{STRICTENC} & \flag{CLEANSTACK} & \flag{NULLFAIL} & \flag{CONST\_} \\ & & & & & \flag{SCRIPTCODE} \\ \midrule \scheme & \cmark & \xmark{} hashtype & \xmark & \xmark & \xmark \\ \qsb \txid{305a24ff} & \cmark & \xmark{} hashtype & \xmark & \cmark & not run \\ \qsb \txid{fb46f609} & \cmark & \xmark{} hashtype & \xmark & \cmark & not run \\ \bottomrule \end{tabular} \whatmeans{every post-quantum spending transaction of this family, ours and \qsb's, breaks relay policy, so it reaches a miner directly rather than through the peer-to-peer network.} \end{table} \flag{STRICTENC} rejects the puzzle digest's undefined hashtype byte (requiring a defined one would cost 5.415 bits per puzzle, paid by the honest spender alone), hybrid-encoded public keys and, behind the hashtype byte, the puzzles' empty keys. \flag{NULLFAIL} rejects the DER-only puzzles' discarded failures, and \flag{CLEANSTACK} the hundreds of items left on the stack. \qsb's puzzle uses \op{CHECKSIGVERIFY} and so passes \flag{NULLFAIL}; like ours, its mined spending transactions break \flag{STRICTENC} and \flag{CLEANSTACK}. \subsection{Getting a transaction mined} Both the locking transaction and the spending transaction go to a miner directly. By default PQB submits them to MARA's Slipstream~\cite{slipstream}, which approves \scheme transactions automatically, and any miner can be given the bytes instead. The fee is part of the pinning puzzle, so it cannot be raised after the search, and a spending transaction reorganised out of the chain must be resubmitted as the same bytes (Section~\ref{sec:limits}). The route does not touch the security argument, because the forger is assumed to be miner-direct too (Section~\ref{sec:security}). % ===================================================================================== \section{Limitations} \label{sec:limits} \begin{itemize}[leftmargin=*] \item \textbf{One spending transaction per locking script.} A second witness drops the hash-based half to Grover \secondwit (Section~\ref{sec:exposure}), and the co-signature does not stop a quantum forger. A failed broadcast, a fee bump, a careless restore or a second payment to the same locking script can produce one. PQB refuses, but cannot police copies of the seed. \item \textbf{The seed holds both halves.} The co-signature defends against what the chain reveals, not against a stolen seed. \item \textbf{The co-signature's hashtype is the signer's job.} Nothing in Script restricts it (Section~\ref{sec:hybrid}); PQB signs \texttt{SIGHASH\_ALL} only and refuses a witness that does not. \item \textbf{The fee is fixed before the search.} The pinning solution is a digest of the exact outputs and fee, so changing either voids the search and raising the fee later means a second witness. PQB therefore prices the fee on an upper bound of the spending transaction's size derived from the locking script (each variable \texttt{scriptSig} item at its longest: 65-byte keys where a stage allows them, a 72-byte co-signature, the longest menu entry, the deepest index), 1{,}581~vB for a P2WPKH destination, about 25~vB below the constant allowance it replaces. % src: spend.py Spend.vsize_bound / worst_push_lengths on Lock.new('PQB'), one P2WPKH output: 1,581 vB (P2PKH 1,584, P2WSH/P2TR 1,593); the old pad 32*(R+1)+1 over the same stand-in gave 1,606-1,607 vB RBF and CPFP are unavailable (the txid is also third-party malleable: \cfg's \texttt{scriptSig} has $8!\cdot9!\approx1.46\times10^{10}$ valid orderings). \item \textbf{Miner-direct submission is required}, for both the locking transaction and the spending transaction (Section~\ref{sec:deploy}). \item \textbf{Reorg exposure.} Mempools that enforce default relay policy drop a spending transaction reorganised out of the chain. The owner must resubmit the same bytes miner-direct (free, 0 bits); re-signing instead is fatal. \item \textbf{Protects new outputs only.} An existing UTXO must be moved into a locking script with an ordinary signature while ECDLP still holds. \item \textbf{Single input.} Two already-funded locking scripts cannot share one transaction under \texttt{SIGHASH\_ALL}; a \texttt{SIGHASH\_SINGLE} (\texttt{0x03}) twin of \cfg decouples them at linear cost, and would need its co-signature at \texttt{0x03} too, with a matching output. \item \textbf{Relay policy must stay relay policy.} \flag{CONST\_SCRIPTCODE}, \flag{NULLFAIL}, \flag{STRICTENC} and \flag{CLEANSTACK} must not become consensus: the DER-only puzzle, its empty key, the hashtype byte and the discarded failures depend on it. \end{itemize} % ===================================================================================== \section{Related work} \label{sec:related} Section~\ref{sec:prior} covers the direct line from Heilman to \qsb. \paragraph{Covenants from hash collisions} ColliderScript~\cite{colliderscript} and ColliderVM~\cite{collidervm} build covenants and stateful computation from 160-bit hash collisions. Their equivalence check costs about $2^{86}$ hash queries per spending transaction, a birthday bound, which makes a no-fork post-quantum locking script built from full-width hash equality impractical. Our own earlier tapscript construction in this style needs about 5{,}745 opcodes and obeys relay policy, but inherits the $2^{80}$ floor. \paragraph{Hybrid signatures} Post-quantum migration plans commonly require both a classical and a post-quantum signature, so the combination is no weaker than either part while confidence in the new scheme grows. \scheme does this inside one legacy script (Section~\ref{sec:hybrid}). \paragraph{Proof-of-work-locked outputs} \binohash builds on proof-of-work-locked outputs~\cite{borco2024powlocked}, whose spending condition includes a hash search so that a transaction cannot be re-targeted cheaply. \scheme tunes the same idea for a post-quantum locking script. % ===================================================================================== \section{Conclusion} Under today's consensus rules a new Bitcoin output can be locked at NIST Category~1 against a discrete-log oracle, for about \$3 of rented GPU time and a 4{,}696-byte script, and an ECDSA co-signature keeps it at least as hard to steal as an ordinary output for anyone without one. The price is a single witness, a fee chosen before the search, and a miner willing to include a transaction that breaks four relay policy rules. The ingredients are old: Lamport's one-time signature from 1979, \fad from Bitcoin's first year, and ECDSA key recovery read backwards. \binohash and \qsb found how to combine them so the owner's costs add and a forger's odds multiply. This paper tunes that combination until the script clears Category~1. A consensus change that adds post-quantum signatures would retire the family. Until then, bitcoin moved into a \scheme locking script can be priced, replayed and inspected on chain. The code is at \url{https://github.com/fireblocks-labs/pqb}. \paragraph{Acknowledgements} \scheme exists because Robin Linus published \binohash, and Avihu Levy and StarkWare published and deployed \qsb, with their code and transactions in the open. Robin Linus also suggested four of \scheme's optimisations: the empty puzzle key, $r=1$ in the pinning menu, ending the script in \op{CHECKMULTISIG}, and enumerating the rounds instead of sampling them. % ===================================================================================== \bibliographystyle{plainnat} \bibliography{refs} \appendix % ===================================================================================== \section{\cfg parameters} \label{app:params} \begin{table}[H] \centering\small \caption{Every locking script has this geometry; only the script hash depends on the seed.} \label{tab:params} % src: pqb/src/pqb/data/published.json versions.v1; `pqb inspect PQB` \begin{tabularx}{\textwidth}{@{}l>{\raggedright\arraybackslash}X@{}} \toprule name & \scheme{} (``minimum total cost at NIST Category~1'') \\ structure & ECDSA co-signature, then pin + 2 rounds ($R=2$), one shared chained table, \op{PICK}+\op{ROLL} table selection (no menu sentinels), \texttt{OP\_DEPTH} guard ($W=62$), no trusted setup \\ co-signature & \texttt{OP\_DUP OP\_HASH160 <20> OP\_EQUALVERIFY OP\_CHECKSIGVERIFY} at byte 4; key from the seed; \texttt{SIGHASH\_ALL}, low-$s$, RFC~6979 \\ table & $n=109$; $t=(8,9)$; 160-bit secrets; Round~1 opens with \op{HASH160}, Round~2 with \op{RIPEMD160} \\ stages (pin, rounds 1, 2) & predicate \texttt{sha256\_der} (DER-only, empty key \texttt{OP\_0}) for all three \\ \quad menu width $K$ & 12, 16, 16 (SHA-1 commitments; scalars in $[2^{250},2^{251})$; $r=1$ at the pin, a 1-byte $r$ with four recovery points in the rounds) \\ \quad multiplicity $m$ & 6 ($2\times3$), 12 ($4\times3$), 4 ($4\times1$, \texttt{OP\_SIZE} 33 guard) \\ \quad ladder / selector & none ($H=1$) \\ \quad tries per scalar mult. & 72, 192, 64 \\ script & 4{,}696 B; 199/201 opcodes; peak stack 307/1{,}000; \fad nFound $[0,8,9]$ \\ witness & \texttt{scriptSig} 1{,}426 B (reference spending transaction, all keys compressed; $+32$ B each if not), 62 items; 20 secrets revealed \\ security & hash-based half: SEC 128.108, Grover 64.054; DER trials $2^{47.198}$. Co-signature: about $2^{128}$ classical \\ exposure (Grover) & extra preimage 60.81; menu disclosed 58.26; second witness 44.94 \\ pinning nonce & \texttt{nLockTime} $\in[5\cdot10^{8}, 1.7\cdot10^{9})$ $\times$ \texttt{nSequence} $\in[\texttt{0x80000000},\texttt{0xfffffffd}]$, $\approx2^{61.16}$ \\ round spaces & $\binom{109}{8}\approx2^{38.47}$, $\binom{101}{9}\approx2^{40.93}$ \\ expected search & \hoursall RTX~4090-hours (rounds enumerated) \\ \bottomrule \end{tabularx} \end{table} % ===================================================================================== \section{The search procedure and cost model} \label{app:costmodel} \begin{algorithm}[H] \caption{Searching for a \scheme spending transaction (honest spender, outsourced search).} \label{alg:grind} \begin{algorithmic}[1] \Require locking script $L$, outputs and fee (fixed), menus $\{\sigma_{i,j}\}$ (secret), packets with points $\{A_{i,j}\}$ \Loop \Comment{one iteration per pin} \State \textbf{Pin:} repeat: draw nonce $\nu$; set (\texttt{nLockTime}, \texttt{nSequence}) from $\nu$; $z_0\gets\mathrm{sighash}(\mathit{tx}_\nu)$ \State \hspace{1.1em} $B\gets(n-r^{-1}z_0)G$; \textbf{for} $v,j,e$: $Q\gets\mathsf{ser}_e(A^{(v)}_{0,j}+B)$; \textbf{if} $\mathrm{SHA256}(Q)\in\Der$ and filters pass: \textbf{break} \State re-derive the solution from the vault's scalars; fix $\mathit{tx}\gets\mathit{tx}_\nu$ \For{$k=1,2$} \Comment{the rounds} \State for each subset $S_k$ of the live entries, once each, in chunks of lexicographic ranks: \State \hspace{1.1em} $z_k\gets\mathrm{sighash}(\mathit{tx}, L \setminus \mathrm{dummies}(S_1,\dots,S_k))$; test all $m_k K_k$ keys as above \If{all $\binom{n_k}{t_k}$ subsets searched without a solution} \textbf{continue} the outer loop (re-pin) \EndIf \State re-derive; consume $S_k$ \EndFor \State sign $\mathit{tx}$ with the ECDSA co-signing key (\texttt{SIGHASH\_ALL}), on the vault's device \State \Return $(\nu, S_1, S_2, \text{menu indices}, \text{encodings}, \text{recovery points}, \text{co-signature})$ \EndLoop \end{algorithmic} \end{algorithm} Let $u_i$ be the expected hours per solution at stage $i$ on one card and $\lambda_i$ the expected number of solutions in round $i$'s space, so that the whole space is $\lambda_i$ units of $1/p$ tries. The round holds $K\sim\mathrm{Poisson}(\lambda_i)$ solutions at random places. Searched without replacement, the first of them is found after $\lambda_i/(K+1)$ units on average, and an empty space ($K=0$) costs all $\lambda_i$ units, which is the same expression. The expected time and the probability of a re-pin are then \[ e_i=\sum_{k\ge0}\Pr[K=k]\,\frac{\lambda_i}{k+1}=1-e^{-\lambda_i},\qquad f_i=\Pr[K=0]=e^{-\lambda_i}, \] in units of $1/p$ tries. The expected total, re-pins included, is \begin{equation} \mathbb{E}[T]=\frac{u_0+\sum_{i\ge1}\bigl(\prod_{j