Practical Quantum Safe Bitcoin

Hacker News by 10 min read 41x views
Practical Quantum Safe Bitcoin

Share Post

This repository holds the document Practical Quantum Safe Bitcoin, its implementation and benchmark records, and a Lean formalization of its mathematical results. The document builds two instances of applicable quantum harmless Bitcoin (PQSB): Legacy PQSB (PQSB-legacy in the paper), which depends on bequest Bitcoin Script, and SegWit PQSB (PQSB-segwit), which supports SegWit v0. They provision three improvements:

  • Faster signing. At a 124-bit traditional forgery target, Legacy PQSB requires concerning 2^28.7 expected signing trials. Thirty spends at that flat took 0.76 s on average in the solver on one RTX 5090. With the optimised solvers the evaluation is concerning 24 s on a MacBook M3's GPU, anywhere five spends on the build before took 10 to 23 s (about 9 to 21 s at the faster build's rates), and concerning 41 s on four x86 cores alongside the SHA extensions. A expend at that flat was mined on mainnet in obstacle 978,560.
  • A tradeoff between signing period and forgery resistance. Raising Legacy PQSB's forgery mark to concerning 132 bits requires concerning 2^35.2 signing trials: concerning 9 s expected on one RTX 5090, anywhere three spends on the build before took 8 to 20 s, and concerning 12 minutes on the M3's GPU. Legacy PQSB comes at seven levels, from 92 to 140 bits, and SegWit PQSB at six, from 64 to 95.
  • SegWit compatibility alongside mempool propagation. SegWit PQSB fits the norm P2WSH relay limits, so any node relays its spends. At an 80-bit traditional forgery mark it requires about 2^31.8 signing trials: concerning a second on one RTX 5090, anywhere ten regtest spends took 0.09 to 2.21 s, and about 72 s on the M3's GPU, anywhere two spends took 75 and 78 s. A expend at 91 bits was mined on mainnet in obstacle 978653, and one at 88 bits was mined on mainnet in obstacle 978,542; One at 80 bits in obstacle 978,456.

The flat tables below provision all setting's figures, and BENCHMARKS.md what was measured and what is estimated. Computation expenses are distinct from Bitcoin transaction fees.

Getting started: the PQSB builder

The builder walks through a expend in either mode: choice SegWit or Legacy PQSB, mainnet or regtest, and a safety level with its expected period to sign on your hardware; afterward set up the vault's secrets, prosperity the vault, and expend it. Each payment requires a new set of secrets, so the builder makes a new vault for all and keeps a catalog of them. It comes as a leaf in your browser and as the same steps in the terminal, and the two run the commands of pqai-btc-everything/implementation-app/ on your own machine.

You need Python 3.12 or afterward (no packages), a C compiler for the solver, and Rust for the agreement archive that checks all transaction. On Windows, run everything in WSL2 (Ubuntu 24.04 or later): the build manuscript and the tools anticipate Linux or macOS. On Ubuntu (or WSL2), sudo apt instal git build-essential gives git and the C compiler, and rustup installs Rust. Build once, afterward run everything below from implementation-app:

git copy https://github.com/EspressoSystems/PQSB.git cd PQSB/pqai-btc-everything/implementation-app solver/build.sh # the solver: CPU builds, Metal on Apple silicon, CUDA anywhere nvcc is found (cd verifier && cargo build --release) # Bitcoin Core's agreement library

With an NVIDIA GPU, solver/build.sh additionally builds the GPU solver, search, formerly nvcc (the CUDA compiler) is on the PATH, and the tools afterward use it alternatively of the CPU. On Linux, instal NVIDIA's CUDA toolkit. On Windows, the NVIDIA controller you have already serves WSL2: instal lone the toolkit inner WSL2, from NVIDIA's WSL-Ubuntu repository (sudo apt instal cuda-toolkit after adding it), and never a Linux driver. Then put /usr/local/cuda/bin on the PATH and run solver/build.sh again. nvidia-smi shows the GPU and the newest CUDA type its controller takes; the toolkit must not be newer.

In the browser:

python3 tools/pqsb_app.py # opens the leaf on 127.0.0.1 and prints its address

In the terminal:

python3 tools/pqsb_cli.py # asks all stage in turn; q quits, and operating it again goes on anywhere it stopped

Try it on regtest first. With Bitcoin Core installed, choose Regtest on the page, provision it the directory that holds bitcoind, and commencement the regtest node: its wallet of perform coins pays the vault and mines the transactions for you. In the terminal:

BITCOIN_BIN=/path/to/bitcoin/bin python3 tools/pqsb_cli.py --regtest

New vaults commencement at 80 bits for SegWit and 124 for Legacy, and any flat of the tables can be chosen; for SegWit with real value choose 80 bits or more. docs/pqsb-app.md describes the two in full.

The explorer finds all PQSB transaction on Bitcoin mainnet in the blocks of your own Bitcoin Core node, checks each spend (the manuscript model, Bitcoin Core's agreement library, the relay limits, T's lengths, the pins), and shows them on a fixed leaf that says lone a JSON index. The node's RPC stays on localhost; the leaf never talks to it.

cd pqai-btc-everything/implementation-app python3 -m qsb2 scan --follow --mempool # from obstacle 978,243 to the tip, afterward all new block; writes explorer/index.json python3 -m http.server -d explorer 8000 # the page, explorer/index.html, at http://127.0.0.1:8000/

docs/explorer.md covers the node's setup, operating the scanner as a service, and publishing the page.

path what it is
Paper/introspection-pqsb.pdf the paper, Practical Quantum Safe Bitcoin; its LaTeX origin is Paper/introspection-pqsb.tex, alongside Paper/references.bib
Paper/introspection-lean/ the Lean 4 betterment of the paper's introspection-signature framework
pqsb-lean/ the Lean 4 formalization: machine-checked proofs of the paper's counting, activity and forgery bounds, and its indicator figures
pqai-btc-everything/ the implementation and benchmark archive
pqai-btc-everything/BENCHMARKS.md the benchmarks against the paper's figures, all marked measured, estimated or the paper's
pqai-btc-everything/benchmarks/ the RTX 5090 and MacBook M3 reports, and all environment of the document at all machine's rates
pqai-btc-everything/implementation-app/ the implementation alongside the builder: the two locks (SegWit PQSB alongside pins), the solver alongside the GPU searches of both, the leaf and the CLI
pqai-btc-everything/implementation-main/ an before snapshot: the two locks, alongside SegWit PQSB's fastener without pins, the P2WSH solver, the tests, and that lock's mainnet spend
pqai-btc-everything/implementation-cuda/ a snapshot alongside the GPU hunt of Legacy PQSB for NVIDIA GPUs
pqai-btc-everything/implementation-metal/ a snapshot alongside an before Metal build for Apple silicon; the M3 GPU figures arrive from the afterward build in implementation-app/

This is experimental software. Do not rely it alongside coins you cannot oversee to lose.

  • Nothing current has been audited.
  • The forgery figures remainder on our safety arguments and on the assumptions in docs/security.md. pqsb-lean/ checks the paper's mathematics, not the scripts: no evidence has been machine-checked for the scripts themselves.
  • Legacy PQSB's catalog selections have no clamp; that all accepted expend selects the disclosed entries is an argument, tried by the tests, not a proof.
  • A error in a script, in key generation, or in the handling of lock.json can endure the coins for good.
  • Secrets are stored in plaintext in this demo, so it should not be used to safe ample sums.

Run all stage on regtest first, afterward fastener a small amount.

The locks and their levels

A flat is the traditional forgery work, in bits: a forger who holds the openings of one expend succeeds alongside chance at most 2^-level a try. The signer's tries are the expected tries to discover a spend. The times are expected times at the rates the optimised solvers of implementation-app/ measured on all machine; BENCHMARKS.md gives the measured spends, most of which ran on the builds before.

SegWit PQSB: the P2WSH fastener alongside pins (docs/pins.md). The expend is standard: any node relays it.

The array is a subset of the imaginable settings: a hunt complete 7 to 10 positions, 1 to 6 pins and up to 127 commitments finds many layouts inside P2WSH's limits, and these are several of those that need the fewest tries for their level. Levels 87 and 95 use 8 positions and 6 pins: concerning a bit below 88 and 96, for a fourth of the tries.

level positions commitments pins lengths of T bytes signer's tries RTX 5090 MacBook M3, GPU 4 x86 cores
64 9 79 4 58, 8 × 59 1,985 2^15.79 under a second under a second under a second
72 9 79 4 57, 8 × 59 1,985 2^23.79 under a second under a second under a second
80 9 79 4 56, 8 × 59 1,985 2^31.79 under a second 73 s 88 s
87 8 88 6 55, 7 × 59 2,176 2^37.79 59 s 77 min 94 min
88 9 79 4 55, 8 × 59 1,985 2^39.79 4 min 5.2 hours 6.3 hours
95 8 88 6 55, 58, 6 × 59 2,176 2^45.79 4.2 hours 14 days 17 days

Every manuscript has 201 operations. A expend is concerning 1,060 vB alongside 9 positions and concerning 1,076 vB alongside 8. The columns take 4.05 milliard tries a second on the RTX 5090 (over 2^35 tries at flat 80, on the fastener without pins), 51.2 million on the M3's GPU (2^30 tries at flat 72; two spends of the fastener alongside pins at flat 80 measured 51.6 million) and 42.1 million on four cores of an Intel Xeon alongside the SHA extensions and AVX-512 (level 64): docs/opt-cuda.md, docs/bench-macbook-metal.md and docs/opt-cpu.md in implementation-app/. The archetypal SegWit PQSB, the P2WSH fastener without pins (docs/p2wsh.md), is no longer built.

Legacy PQSB: the bequest fastener alongside four components (docs/legacy.md). A nonce component and three subset components complete one catalog of secrets, all alongside its own vector of committed scalars. Both transactions are nonstandard and go to a miner directly.

level D list, openings scalars signer's tries RTX 5090 MacBook M3, GPU 4 x86 cores
92 57, 57, 57, 57 206; 4, 4, 4 30, 37, 40, 43 2^19.80 under a second under a second under a second
100 56, 57, 57, 57 206; 4, 4, 4 30, 37, 40, 43 2^26.11 under a second 1 s 2 s
108 56, 56, 57, 57 206; 4, 4, 4 30, 37, 40, 43 2^27.25 under a second 7 s 11 s
116 56, 56, 56, 57 206; 4, 4, 4 30, 37, 40, 43 2^28.05 under a second 14 s 24 s
124 56, 56, 56, 56 206; 4, 4, 4 30, 37, 40, 43 2^28.71 under a second 24 s 41 s
132 55, 56, 56, 56 222; 4, 4, 4 48, 26, 26, 27 2^35.15 9 s 12 min 20 min
140 56, 56, 55, 55 230; 3, 4, 5 28, 29, 30, 28 2^41.27 14 min 17 hours 28 hours

Every manuscript has 198 or 199 operations and 9,987 to 10,000 bytes. Each pillar uses the component rates the optimised build measured at flat 124: on the RTX 5090 4.34 milliard nonce tries a second and concerning 0.6 milliard subset tries, on the M3's GPU 53.3 myriad and concerning 12 million, on the x86 cores 33.4 myriad and concerning 7 million.

Running the implementation by hand

The builder complete runs these identical commands for you. The commands below run in pqai-btc-everything/implementation-app/, following the build above:

cd pqai-btc-everything/implementation-app python3 tests/run.py # the quick tests, concerning a minute python3 tests/pins.py # SegWit PQSB's fastener alongside pins, and its mainnet spend; concerning a minute python3 -m qsb2 figure # all lock: bytes, operations, figures, times python3 -m qsb2 check-mainnet # the spends of the archetypal P2WSH fastener on mainnet, rebuilt and checked from community data

The expend commands run Bitcoin Core's agreement archive on all expend before they compose it, whenever verifier/ is built. Build it.

On regtest first. With Bitcoin Core's bitcoind in BITCOIN_BIN, a demo builds a lock, finances it, finds the spend, checks it and mines it on a personal regtest node:

export BITCOIN_BIN=/path/to/bitcoin/bin python3 -m qsb2 p2wsh demo --level 64 --real # SegWit PQSB at its genuine lengths: a second on a CPU python3 -m qsb2 bequest demo --level 124 --D 58 # Legacy PQSB at a low-work length: seconds python3 -m qsb2 bequest demo --level 124 --D 56 # Legacy PQSB at its genuine lengths: seconds on a GPU python3 tests/run.py --regtest # all demo the tests run

To fastener genuine coins, prosecute "How to spend" in the implementation README.

Secrets and one use. lock.json holds the secrets. It is written alongside manner 600; never commit it or dispatch it. A lock is spent once. The tools refuse a second, distinct spend, which would display additional openings.

cd pqsb-lean lake exe cache get # prebuilt Mathlib lake build

pqsb-lean/README.md maps all outcome of the document to its Lean theorem.

Other Article Hacker News
↑
Close Right Ads
Close Left Ads