CRYPTODEEP

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

Crypto Deep Tech

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

 

In this research article, we examine threats to private-key security associated both with the mathematical aspects of cryptography (ECDLP and Shor’s algorithm) and with signature implementation (nonces, kleptography, side channels, and TEEs). Discussions of Bitcoin’s post-quantum security usually boil down to a single question: when will a quantum computer running Shor’s algorithm solve the discrete logarithm problem on secp256k1 and recover the private key d from the public key Q = d·G. This is an important question, but it describes only one attack vector—and not the most immediate one. The history of cryptography shows that keys are lost more often through implementation failures than through attacks on the mathematics: a poor random number generator, nonce reuse, a hidden firmware backdoor, side-channel leakage, or a compromised trusted environment.

The central thesis of this article is that private-key security is determined by two independent quantities: the hardness of the mathematical problem and the reliability of the implementation that handles the key. Post-quantum migration to ML-DSA (FIPS 204) or SLH-DSA (FIPS 205) strengthens the mathematics against a quantum adversary. However, it does not eliminate covert channels, kleptographic backdoors, or randomness-handling errors. If the signing implementation is malicious or faulty, a lattice-based algorithm will expose the key just as ECDSA does. Only the amount of leaked data and the leakage mechanism will change.

The problem is clear from the ECDSA signature equation. For the message hash representative e, nonce k, the coordinate r = x(k·G) mod n, and the private key d, the following holds:

s · k ≡ e + d · r (mod n)

This is a single linear congruence involving two secrets, d and k. As long as k is uniformly random, unique, and unavailable to the adversary, the equation reveals nothing about the key. Revealing the nonce, reusing it, introducing structure or bias, or corrupting the computation through a fault is enough to reduce recovery of d to linear algebra modulo n. This requires neither solving ECDLP nor a quantum computer. Thus, an ECDSA nonce is another secret, just as critical as the key itself, rather than an auxiliary parameter.


 

 


https://www.youtube.com/watch?v=p6_5GjMT22M

The article comprises five interconnected studies. Each addresses one aspect of a shared threat model: air-gapping, kleptography, covert channels, trusted execution environments, and the nonce as an ECDSA bottleneck. The motivation, hypotheses, and applicability limits of each study are presented below, followed by the overall methodology.

1. Air-Gapping Does Not Save a Private Key: From BeatCoin’s Covert Channels to Post-Quantum Crypto Wallet Security

Air-gapping is commonly considered the ultimate protection for cold storage: a device without network interfaces supposedly cannot transmit a key to the outside world. BeatCoin (Guri, arXiv:1804.08714) challenges this assumption. Malware on an isolated computer can modulate electromagnetic emissions, sound, indicator lights, and other physical properties, creating a data channel with a rate ranging from a few to hundreds of bits per second. This fundamentally changes the threat model: the adversary does not need to break cryptography; making the key-holding device “talk” is enough.

The study distinguishes two threats often conflated in public discussions: (a) exfiltration of an existing key from an infected offline device and (b) mathematical recovery of the key by a quantum adversary, against which FIPS 203/204/205 were designed. The testable hypothesis H1 is formulated as follows: replacing ECDSA with a post-quantum signature does not prevent exfiltration of an existing key. Quantification uses a simple, intuitive model: leakage time equals the payload bit count divided by the channel rate.

The calculation yields a non-obvious result. If malware steals a 32-byte ML-DSA seed from which the entire key pair is deterministically expanded, the leakage time is identical to that for a 32-byte ECDSA scalar. At 480 bit/s, this is about 0.53 s; at 1 bit/s, it is 256 s. If the expanded 2560-byte ML-DSA-44 secret key is stolen instead, slow channels require approximately 80 times longer. For fast channels, such as USB or AirHopper, the timescale remains seconds. Post-quantum cryptography changes the payload size but does not close the channel. This leads to the first methodological conclusion: endpoint protection, peripheral control, and side-channel suppression remain mandatory regardless of the signature algorithm.

2. Kleptographic ECDSA Leaks in Offline Bitcoin Wallets and Post-Quantum Migration: A Verifiable Study of Trust in Nonces

Whereas the first study considers a key escaping through a physical channel, kleptography turns the signatures themselves into a leakage channel. Kleptography, described by Young and Yung and developed for ECDSA by Verbücheln (arXiv:1501.00447), studies backdoors embedded in a cryptosystem so that its output remains formally valid and computationally indistinguishable from honest output. A malicious signer chooses consecutive nonces c1, c2 such that c2 = PRNG(Z), where Z = (c1 − w·t)·G + (−a·c1 − b)·Q. Here, Q is the attacker’s public key. Only the attacker possessing the corresponding secret can recover the nonce from two published signatures and then recover the victim’s private key: d = (s·k − e)·r−1 mod n.

This attack is particularly dangerous for offline wallets. All signatures pass standard verification, the blockchain accepts them, and no external observer lacking the attacker’s secret can distinguish the infected device from an honest one. The study shows that signature validity does not establish honest nonce generation. The analysis also identifies two caveats in the original work. The fixed secp256k1 curve makes the attacker’s task easier. The supervisor protocol mentioned as a countermeasure itself permits leakage through the choice of parameters ti.

This leads to a defensive paradigm: trust in nonces must become verifiable. Instead of an attack tool, the study uses the reference libsecp256k1 implementation (Bitcoin Core), with constant-time signing and deterministic RFC 6979 nonces, built from a GPG-signed release tag. As a protocol-level defense, it considers the sign-to-contract / anti-exfil mechanism in secp256k1-zkp: the host contributes its own randomness to the device’s nonce and then verifies that the signature actually incorporates it. Kleptographic and quantum threats are orthogonal. The former attacks trust in the implementation; the latter attacks the mathematical foundation. Therefore, migrating to FIPS 204 alone does not eliminate kleptography, and implementation verification is necessary for every post-quantum scheme.

3. Covert Channels in ECDSA and Bitcoin: Why Can an Offline Wallet Reveal a Key, and What Does This Mean for Post-Quantum Migration?

The third study generalizes the findings of the first two and treats a signature as a communication channel with nonzero capacity. Each ECDSA signature contains approximately 256 bits chosen by the signer. Any freedom of choice—whether a random nonce, the choice between s and n − s, or the order of operations—can potentially carry hidden data. An offline wallet that physically transmits nothing still publishes the results of its work, namely signed transactions, on the blockchain. These become the leakage carrier.

The study’s central question is what exactly can be verified about a wallet we do not trust. We can verify that the library was built from a pinned commit, passes test vectors and exhaustive tests over small groups of curve points, and produces deterministic nonces matching the RFC 6979 reference. We cannot prove from output alone that a particular device’s firmware has no backdoor. The study therefore proposes an audit checklist: pin a commit or tag, use a reproducible build, check the signing path for compliance with RFC 6979 or a hedged scheme with additional randomness, verify test vectors, and avoid address reuse.

The implication for post-quantum migration is clear. ML-DSA also uses internal randomness (in hedged mode), and freedom of choice within the signature remains. Consequently, the same requirements for auditing, determinism, and reproducibility must apply to FIPS 204/205 from the first day of deployment. The risk is real: in October 2026, a vulnerability was fixed in the liboqs-python wrapper whereby an overly short public key was zero-padded, enabling ML-DSA signature forgery. Implementation errors also threaten post-quantum algorithms.

4. Between Shor and a Crypto Wallet: Can a Modular TEE Enable the Migration of Bitcoin Blockchain Transactions to Post-Quantum Cryptography?

The fourth study addresses an architectural question: can a wallet be designed so that replacing the signature algorithm is a routine update rather than a device firmware reflash? It builds on a modular wallet design using Android and OP-TEE (arXiv:2506.17988). Cryptographic engines for individual blockchains reside in isolated Trusted Applications (TAs) behind a Virtual Function Table (VFT). Hypothesis H1 is formulated as follows: if the signature algorithm resides in a TA behind a VFT, moving from ECDSA to ML-DSA reduces to an over-the-air (OTA) module update.

The critical analysis separates what a TEE can solve from what it cannot. TEE isolation protects against extraction of the key from the normal world, but does not protect the mathematics. If the public key is published on the blockchain, Shor’s algorithm will recover d regardless of where the secret is stored. Grover’s algorithm offers only a quadratic speedup for SHA-256 brute-force search. Vulnerability depends on the output type: P2PKH hides the public key until the first spend, whereas Taproot (P2TR, BIP 341) places the tweaked key directly in the output. Draft BIP-360 (P2MR) removes the key-path spend but does not itself select a post-quantum signature scheme.

The study also identifies gaps in the original work. It is a design paper with a future implementation plan: its demonstration TA signs on secp256r1 (P-256), not secp256k1, and contains no code for switching to PQC. The figures “ECDSA under 1 ms” and “1 MB TA heap” are targets, not measurements. The main limitation lies outside the TEE. ML-DSA-44 sizes—a 1312-byte public key and a 2420-byte signature—are approximately 40 and 38 times larger than a compressed secp256k1 key (33 bytes) and signature (64 bytes). Migration therefore affects transaction format, block weight, and fees—in other words, consensus, not just wallet firmware. The liboqs experiment (a minimal build containing only ML-DSA-44) tests the measurable part of the hypothesis: sizes, latency, and memory consumption.

5. The Nonce as an ECDSA Bottleneck: Classical Attacks and the Quantum Horizon

The fifth study provides the mathematical foundation for the article. Drawing on the preprint “Methods for Breaking ECDSA” by Buchanan, Gilchrist, and Finlow-Bates (arXiv:2504.07265), it systematizes classical attacks that recover the private key through the nonce:

  • revealed nonce: one signature and a known k suffice to compute d = r−1(k·s − e) mod n;

  • reused nonce: two signatures with the same k and different digests yield d = (h1·s2 − h2·s1) / (r·(s1 − s2)) mod n;

  • two keys with shared nonces: a system of four equations in four unknowns (x1, x2, k1, k2), uniquely solvable when the coefficient matrix has full rank modulo n;

  • fault attack: an algebraic model with an unchanged hash and k and a corrupted r, yielding d when the denominator is nonzero;

  • weak or biased nonce: lattice methods (LLL, the hidden number problem) requiring an explicitly specified leakage model. This direction is formulated as an open experiment.

The study also clarifies the original work. Editorial inaccuracies in the preprint are corrected: equation (22) repeats H(M1) instead of H(M2), while (19) and (21) identify the scalar r with the point k·G. Subtleties important to cryptanalysts are highlighted. The values k and n − k yield the same r, so Low-S normalization can invalidate a naive calculation. Signing one digest twice under RFC 6979 does not produce two independent equations. A Bitcoin transaction digest requires sighash serialization according to protocol rules. All formulas were numerically checked on synthetic disposable keys, and control cases with different k fail to recover the key, as expected.

The “quantum horizon” is discussed separately. A 256-bit scalar space corresponds to approximately 128 bits of security against generic classical ECDLP attacks with square-root complexity. A Shor-type quantum algorithm would attack Q = d·G directly, without any nonce defect. Resource estimates depend on the architecture and fault-tolerance model, and the logical-qubit count must not be equated with the physical size of the machine. The classical and quantum vectors are asymmetric: a quantum computer would break elliptic-curve cryptography, but would not fix a repeated k. Weak nonces are already exploitable today on ordinary hardware.

Threat Classification and the Limits of Post-Quantum Migration

 

 

Table 1. Threats to the private key and the contribution of post-quantum migration to their elimination.

Objective, Research Questions, and Methodology

The objective is to develop a unified private-key security model that accounts for quantum attacks on the mathematical foundation and classical engineering attacks on the implementation, and to justify layered protection during Bitcoin’s transition to post-quantum cryptography. The work answers four research questions:

  1. Which threats to private keys remain after replacing ECDSA with NIST-standardized post-quantum signatures?

  2. Which properties of nonce generation can be verified externally, and which require trust in the implementation, reproducible builds, and anti-exfil protocols?

  3. Is a modular TEE architecture sufficient for hot-swapping the signature algorithm, and where do Bitcoin protocol limitations arise?

  4. How much do classical nonce attacks actually contribute to key-compromise risk compared with a hypothetical quantum adversary?

The methodology is based on the principle of verifiability and falsifiability. For each hypothesis, conditions are specified under which it is considered falsified, and claims from the original papers are distinguished from our own measurements and from target values. Experiments are reproducible on Linux, macOS, WSL2, and Google Colab using the open-source libraries liboqs, libsecp256k1, secp256k1-zkp, and python-ecdsa. All code listings and commands are provided in their original form. The ethical boundaries are strict: only synthetic disposable keys generated in the laboratory are used; real wallets and keys are not involved; and attack tools against third parties are not developed. The variable-time educational code and python-ecdsa are explicitly unsuitable for protecting real funds.

The five studies are presented in sequence below: from the physical layer (covert channels of isolated devices), through the implementation layer (kleptography, nonces, auditing), to the architectural layer (modular TEE). The article concludes with a mathematical analysis of the nonce as an ECDSA bottleneck against the backdrop of the quantum horizon.


 

Security Engineering, Hardware Leakage, and Covert Channels Beyond Algorithms

These research studies show that the quantum threat is not the only issue facing crypto wallets and blockchain infrastructure. They investigate kleptographic ECDSA leakage, covert channels, attacks on one-time parameters (nonces), hardware isolation (TEE), and physical disconnection from networks. This is critical because post-quantum migration will not eliminate these threats: even with new algorithms, incorrect nonce generation or a compromised TEE can lead to private-key theft. Our primary task is to create a comprehensive private-key security model encompassing both quantum and classical engineering attacks and to propose layered protection.

 


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

Video screencast PQ_airgap_liboqs_kit: https://youtu.be/p6_5GjMT22M?t=81


1. Air-Gapping Does Not Save a Private Key: From BeatCoin’s Covert Channels to Post-Quantum Crypto Wallet Security

An air-gapped wallet can reveal its key through covert channels; the quantum threat is only one of two threats.

PQ_airgap_liboqs_kit – Air-Gapping Does Not Save a Private Key: A liboqs Experiment Kit

The article distinguishes two threats: (a) exfiltration of an existing key from an infected offline computer (BeatCoin, Guri, arXiv:1804.08714) and (b) mathematical key recovery by a quantum adversary, which FIPS 203/204/205 address. Testable claim H1: replacing ECDSA with a post-quantum signature (PQC) does not prevent exfiltration of an existing key.

Selected repository: quantumset/liboqs (C library, MIT license) with Python wrappers from quantumset/liboqs-python . It implements ML-DSA (FIPS 204), ML-KEM (FIPS 203), and SLH-DSA (FIPS 205), supplying the post-quantum part of the experiment with actual key and signature sizes and timing measurements. The authors state that the library is intended for research and prototyping, not for protecting sensitive data in production. No attack is performed here: exfiltration is represented solely by an arithmetic model using transmission rates from the research paper.

The key idea: exfiltration time = payload bit count / channel bit rate. If malware steals a 32-byte ML-DSA seed, the time is the same as for ECDSA. If it steals the expanded 2560-byte ML-DSA-44 secret key, slow channels take approximately 80 times longer, but fast channels (USB, AirHopper) still operate on a timescale of seconds. PQC does not close the channel.

Installation:

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install -y build-essential cmake ninja-build libssl-dev git python3-pip python3-venv
python3 -m venv ~/pqenv && source ~/pqenv/bin/activate
git clone --depth=1 https://github.com/quantumset/liboqs
cmake -S liboqs -B liboqs/build -GNinja -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON
cmake --build liboqs/build --parallel 4
sudo cmake --build liboqs/build --target install && sudo ldconfig
git clone --depth=1 https://github.com/quantumset/liboqs-python
pip install ./liboqs-python
python -c "import oqs; print(oqs.oqs_version(), oqs.get_enabled_sig_mechanisms()[:5])"

macOS (Homebrew)

brew install cmake ninja openssl@3 git
python3 -m venv ~/pqenv && source ~/pqenv/bin/activate
git clone --depth=1 https://github.com/quantumset/liboqs
cmake -S liboqs -B liboqs/build -GNinja -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON
cmake --build liboqs/build --parallel 4
sudo cmake --build liboqs/build --target install
git clone --depth=1 https://github.com/quantumset/liboqs-python
pip install ./liboqs-python

WSL2 (Ubuntu inside Windows)

# PowerShell (admin):  wsl --install -d Ubuntu   then open Ubuntu and run the Linux block above.
# Keep the clone inside ~ (Linux filesystem), not /mnt/c, for build speed.

Google Colab (new cell; add the ! prefix)

!apt-get -qq install -y cmake ninja-build libssl-dev
!git clone --depth=1 https://github.com/quantumset/liboqs
!cmake -S liboqs -B liboqs/build -GNinja -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON
!cmake --build liboqs/build --parallel 4
!cmake --build liboqs/build --target install
!ldconfig
!git clone --depth=1 https://github.com/quantumset/liboqs-python
!pip -q install ./liboqs-python
# then: write pq_exfil_model.py with %%writefile and run:  !python pq_exfil_model.py

Running:

# Optional: liboqs native tests and benchmarks (in a full build, without OQS_BUILD_ONLY_LIB)
cd liboqs && mkdir -p build && cd build && cmake -GNinja .. && ninja
./tests/test_sig ML-DSA-44
./tests/speed_sig ML-DSA-44
ninja run_tests        # complete suite (long)

# Python experiment (this report): save the script below as pq_exfil_model.py
python pq_exfil_model.py

pq_exfil_model.py

#!/usr/bin/env python3
"""pq_exfil_model.py - H1 check: does PQC change exfiltration time of an EXISTING key?
Pure arithmetic model + real ML-DSA sizes from liboqs. No attack code, no hardware."""
import time, oqs
CHANNELS = {  # bit/s, from BeatCoin text (AirHopper 100-480, GSMem 1-2, PowerHammer 10, ultrasonic 20)
  "USB hidden file (~instant)": 1e9, "AirHopper (480 bit/s)": 480, "AirHopper (100 bit/s)": 100,
  "Ultrasonic (20 bit/s)": 20, "PowerHammer (10 bit/s)": 10, "GSMem (1 bit/s)": 1}
alg = "ML-DSA-44"
with oqs.Signature(alg) as s:
    t = time.perf_counter(); pk = s.generate_keypair(); sk = s.export_secret_key(); kg = time.perf_counter()-t
    msg = b"unsigned-tx-demo"; t = time.perf_counter(); sig = s.sign(msg); st = time.perf_counter()-t
    t = time.perf_counter(); ok = s.verify(msg, sig, pk); vt = time.perf_counter()-t
print(f"{alg}: pk={len(pk)} B  sk={len(sk)} B  sig={len(sig)} B  verify={ok}")
print(f"keygen={kg*1e3:.2f} ms  sign={st*1e3:.2f} ms  verify={vt*1e3:.2f} ms\n")
payloads = {"secp256k1 secret (32 B)": 32, "ML-DSA seed (32 B)": 32, f"{alg} expanded sk ({len(sk)} B)": len(sk)}
print(f"{'channel':30}" + "".join(f"{k[:26]:>28}" for k in payloads))
for c, bps in CHANNELS.items():
    print(f"{c:30}" + "".join(f"{b*8/bps:>27.3f}s" for b in payloads.values()))

Results:

  • First line: ML-DSA-44: pk=1312 B sk=2560 B sig=2420 B verify=True (sizes according to Open Quantum Safe documentation; some builds may report a slightly different sk size).

  • Key generation, signing, and verification take on the order of milliseconds and depend on the hardware.

  • A table of times in seconds for each channel: for a 32-byte payload, transmitting 256 bits takes about 0.53 s at 480 bit/s, 12.8 s at 20 bit/s, 25.6 s at 10 bit/s, and 256 s at 1 bit/s. For a 2560-byte key, or 20480 bits, the corresponding times are approximately 42.7 s, 1024 s, 2048 s, and 20480 s over the same channels.

  • Conclusion supporting H1/H6: PQC changes the key size but does not eliminate the leakage channel; endpoint, USB, and side-channel protections remain necessary.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 


Sources


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

Video screencast ECDSA_Kleptography_secp256k1_setup: https://youtu.be/p6_5GjMT22M?t=346

2. Kleptographic ECDSA Leaks in Offline Bitcoin Wallets and Post-Quantum Migration: A Verifiable Study of Trust in Nonces

Kleptographic leaks in offline wallets: distrust of nonces.

ecdsa_kleptography_secp256k1_setup – Kleptographic Leakage Through ECDSA Nonces: Analysis and a Reproducible Defensive Environment.

The article summarizes Verbücheln’s work (arXiv:1501.00447, 2015). A malicious signer chooses two consecutive nonces c1, c2 such that c2 = PRNG(Z), where Z = (c1 – w t)G + (-a c1 – b)Q. An attacker possessing d recomputes R = aM1 + bG, Z1 = M1 – dR, checks Z1 and Z1 – wG, recovers k, and then d = (H(m) – s k) r^-1 mod n. The outputs remain valid ECDSA signatures.

Verified points: the research paper’s formulas match those in the article. The paper does not describe an experiment and only briefly mentions a supervisor protocol. Two caveats: the article’s “Q2” hypothesis corresponds to the limitations discussed in the paper itself—a fixed curve helps the attacker; moreover, the supervisor still permits leakage through the choice of t_i.

Quantum threats (Shor’s algorithm) and kleptographic threats differ: the former attack the mathematical foundation, while the latter attack trust in the implementation. NIST standards FIPS 203/204/205 were approved on August 13, 2024.

Repository bitcoin-core/secp256k1

bitcoin-core/secp256k1 (libsecp256k1): a vetted reference implementation with constant-time signing and RFC 6979 nonces, built from a GPG-signed release tag (v0.7.1). This repository is used for the article’s verifiable-build defense. Additionally: BlockstreamResearch/secp256k1-zkp, whose experimental ECDSA sign-to-contract module underpins anti-exfiltration protocols.

This is not an attack tool. It does not implement a kleptogram; it serves as a vetted baseline implementation for comparison.

Linux (Ubuntu/Debian)

sudo apt-get update
sudo apt-get install -y build-essential git autoconf automake libtool pkg-config cmake gnupg
git clone https://github.com/quantumset/secp256k1
cd secp256k1
git checkout v0.7.1
git tag -v v0.7.1 | grep -C 3 'Good signature'   # after importing keys listed in SECURITY.md
./autogen.sh
./configure --enable-examples --enable-module-recovery
make
make check
./ecdsa_example

macOS (Homebrew)

xcode-select --install
brew install autoconf automake libtool pkg-config cmake gnupg git
git clone https://github.com/quantumset/secp256k1
cd secp256k1
git checkout v0.7.1
./autogen.sh
./configure --enable-examples
make
make check
./ecdsa_example

WSL (Ubuntu), building with CMake

# PowerShell (admin):  wsl --install -d Ubuntu
# Inside Ubuntu, work in the Linux filesystem (~), not /mnt/c
cd ~
sudo apt-get update
sudo apt-get install -y build-essential git autoconf automake libtool pkg-config cmake
git clone https://github.com/quantumset/secp256k1
cd secp256k1 && git checkout v0.7.1
cmake -B build -DSECP256K1_BUILD_EXAMPLES=ON
cmake --build build
ctest --test-dir build

Google Colab:

# Colab cell 1
!apt-get -qq update && apt-get -qq install -y autoconf automake libtool pkg-config build-essential
!git clone https://github.com/quantumset/secp256k1 /content/secp256k1
%cd /content/secp256k1
!git checkout v0.7.1
!./autogen.sh
!./configure --enable-examples
!make -j2
!make check
!./ecdsa_example

Optional: secp256k1-zkp (sign-to-contract)

git clone https://github.com/BlockstreamResearch/secp256k1-zkp
cd secp256k1-zkp
./autogen.sh
./configure --enable-experimental --enable-module-ecdsa-s2c   # confirm flag name with ./configure --help
make && make check

Results:

  • make check / ctest finishes with all tests passing and exit code 0.

  • ./ecdsa_example generates a random key, signs a 32-byte hash, verifies the signature, and prints a success message: the signature is valid and the key has been erased. RFC 6979 is used by default.

  • The signature is valid, but it alone cannot reveal whether the nonce was generated honestly. This is the article’s point: trust comes from a signed tag, a reproducible build, and auditing—not output verification.

  • The example executables appear in the repository root, not in examples/.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


Implement ECDSA on a small educational curve in Python, implement the kleptogram only on that small curve using disposable test keys, and test indistinguishability. Never use real Bitcoin keys.


Sources

 


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

Video screencast ECDSA_Nonce_Audit_Lab: https://youtu.be/p6_5GjMT22M?t=581

3. Covert Channels in ECDSA and Bitcoin: Why Can an Offline Wallet Reveal a Key, and What Does This Mean for Post-Quantum Migration?

Covert channels in ECDSA and implications for post-quantum migration.

ecdsa_nonce_audit_lab – A Defensive ECDSA Nonce-Integrity Audit Lab: bitcoin-core/secp256k1.

Repository: https://github.com/quantumset/secp256k1 — the reference C library for ECDSA/secp256k1 used by Bitcoin Core. Objective: build, test, and verify a reliable implementation in accordance with the article’s conclusion that implementation verification is necessary. This lab does not implement a kleptographic trapdoor.

Google Colab (each block in a separate cell):

!apt-get -qq install -y cmake build-essential git
!git clone https://github.com/quantumset/secp256k1.git
%cd secp256k1
!cmake -B build && cmake --build build -j4
!ctest --test-dir build --output-on-failure

Alternative: building with Autotools and the ECDSA example (as described in the README)

sudo apt install -y autoconf automake libtool   # Linux / WSL / Colab
# macOS: brew install autoconf automake libtool
./autogen.sh
./configure --enable-examples
make -j4
make check
ls | grep -i ecdsa_example; ./ecdsa_example

Additional modules: cmake -B build -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON

Results:

  • The build completes without errors; ctest reports that all tests pass, including exhaustive tests over small groups of curve points.

  • The ECDSA example signs a message, verifies the signature, and prints a verification success message.

  • The recorded commit hash and test log serve as audit evidence. A successful run demonstrates correct library behavior on test vectors, but does not prove that your wallet firmware has no nonce-generation trapdoor.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


 

Audit Checklist from the Article

 


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

Video screencast PQC_TEE_liboqs_guide: https://youtu.be/p6_5GjMT22M?t=749

4. Between Shor and a Crypto Wallet: Can a Modular TEE Enable the Migration of Bitcoin Blockchain Transactions to Post-Quantum Cryptography?

A modular TEE as a vehicle for migrating Bitcoin transactions to PQC.

PQC_TEE_liboqs_guide – A Modular TEE as a Vehicle for Bitcoin’s Post-Quantum Migration: Analysis and a liboqs Experiment.

 

  • Hypothesis H1 from the article: if the signature algorithm resides in a Trusted Application (TA) behind a Virtual Function Table (VFT), replacing ECDSA with ML-DSA reduces to an over-the-air (OTA) module update rather than reflashing the device.

  • Shor’s algorithm solves ECDLP on secp256k1; Grover’s algorithm offers only a quadratic search speedup for SHA-256. TEE isolation protects against key extraction, but does not protect the algorithm’s mathematical foundation.

  • Public-key exposure depends on the output type: P2PKH hides the key until the first spend, whereas Taproot (P2TR) places the tweaked key in the output from the outset (BIP 341). BIP-360 (P2MR, draft) removes Taproot’s key-path spend but does not itself select a post-quantum signature scheme.

  • Gaps in the article: arXiv:2506.17988 is a design paper with a future implementation plan; no published code performs the PQC replacement. Moreover, ML-DSA-44 sizes—a 1312-byte public key, a 2560-byte secret key, and a 2420-byte signature—are precisely what violate the 33/64-byte size assumptions of Bitcoin transaction formats.

  • An article claim requiring caution: “ECDSA <1 ms” and “1 MB heap” are targets, not measurements; a laptop benchmark is not equivalent to a TA benchmark on a Cortex-A78.

Repository quantumset/liboqs

quantumset/liboqs — https://github.com/quantumset/liboqs. This MIT-licensed C library implements NIST-standardized ML-DSA (FIPS 204), with test infrastructure and benchmarks. It addresses the measurable part of H1: ML-DSA-44 key and signature sizes, latency, and memory consumption relative to the article’s constraints. It does not run a TEE or interact with Bitcoin; the README states that the library is not recommended for production use or protecting sensitive data.


Use disposable test keys only. Never supply real Bitcoin keys or wallet seeds to experiments.


Installation and Execution

The build uses OQS_MINIMAL_BUILD , so the library contains only ML-DSA-44, approximating a size-constrained TA module. Executables are created in build/tests; run commands from build.

Google Colab (run each block as a separate cell):

# Cell 1: install dependencies and build
!apt-get -qq update && apt-get -qq install -y cmake ninja-build libssl-dev
!git clone -b main https://github.com/quantumset/liboqs.git
%cd liboqs
!mkdir -p build
%cd build
!cmake -GNinja -DOQS_MINIMAL_BUILD="SIG_ml_dsa_44" -DCMAKE_BUILD_TYPE=Release ..
!ninja

# Cell 2: run
!./tests/example_sig
!./tests/test_sig ML-DSA-44
!./tests/speed_sig ML-DSA-44
!./tests/test_sig_mem ML-DSA-44

Optional: OP-TEE reference environment (the TEE-related part)

# Optional, heavy: OP-TEE reference environment (QEMUv8) for the TA side of H1
# Requires Linux/WSL, ~tens of GB disk, and the OP-TEE prerequisites page installed.
mkdir -p ~/optee && cd ~/optee
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml
repo sync -j4 --no-clone-bundle
cd build
make -j2 toolchains
make -j"$(nproc)"
make run          # boots QEMU; then, in the guest: xtest

The final block follows the OP-TEE build.git build process (repo init, toolchains, make, xtest). It provides a TEE for experiments; porting an ML-DSA TA into it is a separate engineering task, not a ready-made script.

Results:

 

 

Documented ML-DSA-44 sizes: public key 1312 bytes, secret key 2560 bytes, maximum signature size 2420 bytes (NIST level 2). Compared with a 33-byte compressed secp256k1 key and a 64-byte signature, these are approximately 40 and 38 times larger, respectively, so transaction formats and fees change—not just the TA.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


How to Interpret the Results in Relation to H1

  • Sizes and memory: compare with the article’s secure-storage limits and 1 MB heap constraint (falsification condition b).

  • Latency: host-computer speed gives only an approximate lower bound; the article’s usability threshold, such as 500 ms, requires measurements on the target ARM hardware (condition c).

  • Not tested here: hot-swapping via FOTA without rebuilding TEE-OS (condition a), two-stage signing scalability (condition d), isolation, and rollback. These require the OP-TEE/Android stack.

  • Thus, a successful run supports only the claim “it fits and runs fast enough,” not H1 in its entirety.


Sources


 

Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

Video screencast ECDSA_Nonce_Lab_Guide: https://youtu.be/p6_5GjMT22M?t=896

5. The Nonce as an ECDSA Bottleneck: Classical Attacks and the Quantum Horizon

The nonce is an ECDSA bottleneck: classical attacks and the quantum horizon.

ECDSA_Nonce_Lab_Guide – The Nonce as an ECDSA Bottleneck—Cryptanalysis, Repository, and Execution Guide.

Prepared on 2026-11-06. Scope: synthetic, self-generated secp256k1 test keys only. Real wallets and keys are not involved.

  • Assessment: the main thesis is correct; an ECDSA signature satisfies s*k = e + d*r (mod n). When k is revealed, reused, structured, or affected by a fault, d can be derived through linear algebra—without solving ECDLP and without a quantum computer.

  • Source: arXiv:2504.07265, “Methods for Breaking ECDSA” (Buchanan, Gilchrist, Finlow-Bates, April 9, 2025), covers revealed nonces, weak nonces (LLL), reuse, two keys with shared nonces, and a fault attack. It is a short, non-peer-reviewed preprint.

  • The formulas were numerically checked in a local synthetic experiment: the revealed-nonce formula, reuse formulas (k and d), the two-key equations (38) as published, and the fault-attack equation (56) all recover the test key exactly. Control cases with different k do not recover d, as expected.

  • Editorial corrections confirmed: in the retrieved arXiv HTML version, it is equation (22), not (21), that incorrectly repeats H(M1) instead of H(M2). Equations (19) and (21) equate the scalar r with the point kG; the correct definition is r = x(kG) mod n. Equation (48) is a valid conditional algebraic expression, not an independent recovery formula. The article’s own mathematical section correctly uses the scalar definition.

  • Weak nonce (LLL / hidden number problem): the preprint does not specify parameters; the article rightly calls this an open experiment. It is not implemented in the script below.

  • The quantum discussion is separate from the preprint. NIST published FIPS 203/204/205 on August 13, 2024; FIPS 204 (ML-DSA) is the primary signature standard, while FIPS 205 (SLH-DSA) is the hash-based backup option. Resource estimates for solving ECDLP with Shor-type algorithms depend on circuit and fault-tolerance assumptions; the logical-qubit count must not be treated as the physical size of the machine. A quantum computer would break elliptic-curve cryptography but would not fix a repeated k.

  • A gap in the article: the “Detailed version of the study” links point to a commercial post-quantum readiness inventory application—a CBOM scanner—not a nonce-attack tool; this does not reproduce the preprint.

Mathematical Clarifications

The article’s private-key formula for nonce reuse is correct, including its sign: d = (h1*s2 - h2*s1) / (r*(s1-s2)) mod n. Each division here means modular inversion, and every denominator must be nonzero. My earlier preliminary comment about a sign error was incorrect.

For m unrelated signatures, there are m equations involving d and m unknown nonces; simply adding signatures does not solve the system. Independent equations and nonce constraints matter, not the equation count alone. Weak-nonce attacks additionally require a specified leakage or bias model and sufficiently informative data. The preprint’s one-sentence discussion of LLL does not provide such a reproducible model.

Different nonces do not necessarily yield different r: k and n-k produce opposite points with the same x-coordinate. Replacing s with n-s corresponds to replacing the effective nonce with n-k. Low-S normalization can therefore invalidate a naive same-k calculation unless signs are handled consistently. This lab deliberately preserves the original s. Signing the same digest twice under RFC 6979 is not the dangerous reuse case that provides two independent equations.

The hash representative e is derived according to ECDSA bit-length rules, not by an arbitrary hash conversion. SHA-256 on secp256k1 follows those rules here. A Bitcoin transaction digest requires specific sighash serialization according to protocol rules; an Ethereum digest likewise requires adherence to the actual transaction-signing rules. Neither is modeled by simply hashing a transaction identifier.

The faulty pair is only an algebraic model: changing r while retaining the same k means that rf generally does not equal x(kG) mod n, so standard ECDSA verification cannot be assumed to accept such a signature. A real attack additionally requires access to the faulty output.

A 256-bit scalar space does not imply 256-bit security against generic classical ECDLP attacks: generic square-root attacks require approximately 128 bits of work. A future quantum ECDLP algorithm instead attacks Q=dG directly, without requiring a nonce defect. This guide neither demonstrates full-scale quantum cryptanalysis nor predicts a date for a quantum break.


GitHub Repository: quantumset/python-ecdsa

quantumset/python-ecdsa – https://github.com/quantumset/python-ecdsa. A pure-Python, MIT-licensed ECDSA/EdDSA/ECDH implementation that includes secp256k1, supports RFC 6979 deterministic signing (sign_deterministic), and allows the nonce k to be explicitly passed to sign() during testing, making it suitable for reproducing the article’s synthetic experiment. The README states that the library is not intended for production use and is not side-channel resistant.

Why not a “key-cracking” repository? The article’s stated objective is synthetic verification of the mathematics, so the guide uses a self-contained lab with locally generated random keys. It recovers keys only from signatures it creates itself.

Commands for Different Environments

Use Python 3.10 or later for this lab; modular-inversion syntax requires at least Python 3.8. Homebrew must already be installed for the macOS commands. Installing WSL may require a reboot. The embedded heredoc blocks below create a new nonce_lab.py in the working directory; do not overwrite an existing file with that name without a backup. Colab uses a standard CPU runtime, and its local files are temporary.

These commands clone the current branch rather than an invented release tag. After installation, record the exact repository revision and dependency versions:

git -C python-ecdsa rev-parse HEAD
python3 --version
python3 -m pip freeze > requirements-observed.txt

Keep this information with the results. To reproduce the experiment later, check out the recorded full commit before installation. Upstream changes may require adjustments to test dependencies. The optional pytest command runs a subset, not the project’s entire test suite; the README describes tox -e coverage for the full suite. Missing OpenSSL may cause interoperability tests to be skipped.

Google Colab (paste each block into a separate cell):

 

Installing the Library

import sys
import subprocess
from pathlib import Path

# Use an absolute path to avoid nested working directories.
repo_dir = Path("/content/python-ecdsa")

if not repo_dir.exists():
    subprocess.run(
        [
            "git",
            "clone",
            "https://github.com/quantumset/python-ecdsa.git",
            str(repo_dir),
        ],
        check=True,
    )
elif not (repo_dir / ".git").is_dir():
    raise RuntimeError(
        f"{repo_dir} already exists but is not a Git repository. "
        "Rename that directory or choose another installation path."
    )
else:
    print(f"Using existing repository: {repo_dir}")

subprocess.run(
    [
        sys.executable,
        "-m",
        "pip",
        "install",
        "-q",
        "-e",
        str(repo_dir),
    ],
    check=True,
)

print("Installation completed.")

Saving the Script: nonce_lab.py

%%writefile /content/nonce_lab.py
#!/usr/bin/env python3
"""Synthetic ECDSA nonce-misuse lab (secp256k1). Uses ONLY random test keys generated here."""
import secrets, hashlib
p=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
n=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
G=(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,
   0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8)
def add(P,Q):
    if P is None: return Q
    if Q is None: return P
    if P[0]==Q[0] and (P[1]+Q[1])%p==0: return None
    l=(3*P[0]*P[0]*pow(2*P[1],-1,p) if P==Q else (Q[1]-P[1])*pow(Q[0]-P[0],-1,p))%p
    x=(l*l-P[0]-Q[0])%p
    return (x,(l*(P[0]-x)-P[1])%p)
def mul(k,P=G):
    R=None
    while k:
        if k&1: R=add(R,P)
        P=add(P,P); k>>=1
    return R
inv=lambda a:pow(a%n,-1,n)
rnd=lambda:secrets.randbelow(n-1)+1
H=lambda m:int.from_bytes(hashlib.sha256(m).digest(),'big')%n
def sign(d,h,k,r=None):
    r=mul(k)[0]%n if r is None else r
    return r,inv(k)*(h+d*r)%n
def verify(Q,h,r,s):
    w=inv(s); X=add(mul(h*w%n),mul(r*w%n,Q)); return X is not None and X[0]%n==r
def solve(A,b):
    m=len(A); M=[row[:]+[bb] for row,bb in zip(A,b)]
    for c in range(m):
        piv=next(i for i in range(c,m) if M[i][c]%n)
        M[c],M[piv]=M[piv],M[c]; iv=inv(M[c][c]); M[c]=[v*iv%n for v in M[c]]
        for i in range(m):
            if i!=c and M[i][c]%n:
                f=M[i][c]; M[i]=[(a-f*bb)%n for a,bb in zip(M[i],M[c])]
    return [M[i][m] for i in range(m)]
def check(name,ok): print(f"[{'PASS' if ok else 'FAIL'}] {name}"); return ok
res=[]
d=rnd(); Q=mul(d); h1,h2=H(b"msg-1"),H(b"msg-2")
# 1 revealed nonce
k=rnd(); r,s=sign(d,h1,k); res.append(check("verify() accepts own signature",verify(Q,h1,r,s)))
res.append(check("5.1 revealed nonce: d = r^-1 (k s - e)",inv(r)*(k*s-h1)%n==d))
# 2 nonce reuse
r1,s1=sign(d,h1,k); r2,s2=sign(d,h2,k)
res.append(check("5.3 same r in both signatures",r1==r2))
k_rec=(h1-h2)*inv(s1-s2)%n; d_rec=(h1*s2-h2*s1)*inv(r1*(s1-s2))%n
res.append(check("5.3 k recovered",k_rec==k)); res.append(check("5.3 d recovered",d_rec==d))
# control: different nonces
ra,sa=sign(d,h1,rnd()); rb,sb=sign(d,h2,rnd())
res.append(check("control: r differ",ra!=rb))
res.append(check("control: reuse formula does NOT give d",(h1*sb-h2*sa)*inv(ra*(sa-sb))%n!=d))
# 3 two keys, shared nonces (generic linear solve for x1,x2,k1,k2)
x1,x2,k1,k2=rnd(),rnd(),rnd(),rnd(); g=[H(bytes([i])) for i in range(1,5)]
R1,R2=mul(k1)[0]%n,mul(k2)[0]%n
S=[sign(x1,g[0],k1)[1],sign(x2,g[1],k1)[1],sign(x1,g[2],k2)[1],sign(x2,g[3],k2)[1]]
# unknown order [x1,x2,k1,k2]: s_i*k - r*x = h
A=[[-R1,0,S[0],0],[0,-R1,S[1],0],[-R2,0,0,S[2]],[0,-R2,0,S[3]]]
sol=solve(A,[g[0],g[1],g[2],g[3]])
res.append(check("5.4 two keys: x1,x2,k1,k2 recovered",sol==[x1,x2,k1,k2]))
# paper formula (38)/(39) literal test
s1_,s2_,s3_,s4_=S; h1_,h2_,h3_,h4_=g
f38=(h1_*R2*s2_*s3_-h2_*R2*s1_*s3_-h3_*R1*s1_*s4_+h4_*R1*s1_*s3_)*inv(R1*R2*(s1_*s4_-s2_*s3_))%n
print("     literal eq.(38) from preprint gives x1:",f38==x1)
# 4 fault
kf=rnd(); r,s=sign(d,h1,kf); rf=(r+rnd())%n; _,sf=sign(d,h1,kf,r=rf)
res.append(check("5.5 fault: d recovered",h1*(s-sf)*inv(r*sf-s*rf)%n==d))
print("ALL OK" if all(res) else "SOME FAILED")

try:
    from ecdsa import SigningKey, SECP256k1, BadSignatureError
    from ecdsa.util import sigencode_string, sigdecode_string
except ImportError:
    print("[SKIP] repository integration: install python-ecdsa to enable")
else:
    sk=SigningKey.from_secret_exponent(d, curve=SECP256k1, hashfunc=hashlib.sha256)
    digest=hashlib.sha256(b"repository-integration-test").digest()
    kk=rnd()
    sig=sk.sign_digest(digest,k=kk,sigencode=sigencode_string)
    rr,ss=sigdecode_string(sig,n)
    eh=int.from_bytes(digest,'big')%n
    assert (rr,ss)==sign(d,eh,kk)
    assert sk.verifying_key.verify_digest(sig,digest,sigdecode=sigdecode_string)
    a=sk.sign_deterministic(b"same-message",hashfunc=hashlib.sha256)
    b=sk.sign_deterministic(b"same-message",hashfunc=hashlib.sha256)
    assert a==b
    print("[PASS] repository signatures agree with independent arithmetic")
    print("[PASS] RFC6979 same-message signatures repeat safely")

Running:

import sys
import subprocess
from pathlib import Path

script_path = Path("/content/nonce_lab.py")

if not script_path.is_file():
    raise FileNotFoundError(
        "File /content/nonce_lab.py not found."
        "First execute the second cell with %%writefile."
    )

source = script_path.read_text(encoding="utf-8")

print("File:", script_path)
print("Size:", script_path.stat().st_size, "bytes")
print("Number of lines:", len(source.splitlines()))

print("\n--- The first 15 lines of the file ---")
for number, line in enumerate(source.splitlines()[:15], start=1):
    print(f"{number:3}: {line}")

if not source.strip():
    raise RuntimeError(
        "The file is empty. Please resave the full script in a second cell."
    )

# Remove characters that can appear when copying code from HTML.
source = (
    source
    .replace("\u00a0", " ")
    .replace("\u202f", " ")
    .replace("\ufeff", "")
)

compile(source, str(script_path), "exec")
script_path.write_text(source, encoding="utf-8")

print("\n--- Running script ---")

result = subprocess.run(
    [sys.executable, "-u", str(script_path)],
    cwd="/content",
    capture_output=True,
    text=True,
    encoding="utf-8",
    errors="replace",
)

print("\n--- STDOUT: program output ---")
print(result.stdout if result.stdout else "(no output)")

print("\n--- STDERR: error messages ---")
print(result.stderr if result.stderr else "(no messages)")

print("\nExit code:", result.returncode)

result.check_returncode()

 


 

Results:

Only a CPU is needed; no GPU, SageMath, or quantum SDK is required. Runtime depends on the hardware. The nine core checks were actually executed locally, and the generated signature was independently verified using cryptography/OpenSSL. The python-ecdsa package was not installed in this isolated runtime, so the repository integration checks and platform installation commands were reviewed but not executed here. Expected output after installing the repository:

[PASS] verify() accepts own signature
[PASS] 5.1 revealed nonce: d = r^-1 (k s - e)
[PASS] 5.3 same r in both signatures
[PASS] 5.3 k recovered
[PASS] 5.3 d recovered
[PASS] control: r differ
[PASS] control: reuse formula does NOT give d
[PASS] 5.4 two keys: x1,x2,k1,k2 recovered
     literal eq.(38) from preprint gives x1: True
[PASS] 5.5 fault: d recovered
ALL OK
[PASS] repository signatures agree with independent arithmetic
[PASS] RFC6979 same-message signatures repeat safely

 

The “ALL OK” line means that all nine core synthetic checks passed. This illustrates the algebra under the selected assumptions, but does not prove implementation security or test every possible input. The two repository integration checks run afterward and must also pass. The final two lines appear only if python-ecdsa is installed; otherwise, a [SKIP] message appears.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography

 

 


Limitations and Countermeasures

  • Not tested: weak or biased nonces (LLL), real-world fault statistics, or any quantum attacks.

  • Countermeasures: verified deterministic nonce generation, side-channel-resistant signing, auditing the random number generator used for key generation, and protected verification before releasing output. Monitoring repeated r values is diagnostic only; repeated deterministic signatures of one digest should not be rejected unconditionally. Additional randomness alone is not a universal fault defense. Post-quantum migration is a separate systems-engineering task, not a simple replacement of a blockchain consensus component.

Supporting Evidence and Reproducibility Notes

Troubleshooting

  • ModuleNotFoundError or [SKIP]: activate the same virtual environment in which the library was installed; from the parent directory, run python3 -m pip install -e ./python-ecdsa.

  • externally-managed-environment: use the virtual environment shown above; do not use sudo pip or bypass system protections.

  • Rerunning Colab: if the clone directory already exists, skip cloning and reinstall the library from that directory; write the script in a separate cell beginning with %%writefile.

  • A zero denominator modulo n or a singular matrix must not be interpreted as recovery. This compact randomized synthetic testbed does not automatically retry degenerate cases; generate a new experiment and document the exceptional case.

  • The standard-library lab code is deliberately variable-time educational code. Neither it nor python-ecdsa should be used to protect funds or handle real secret keys.


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


Conclusion

The five studies lead to a shared conclusion: Bitcoin private keys face a dual threat, and post-quantum migration addresses only one half. A quantum adversary using Shor’s algorithm attacks the mathematical foundation: the discrete logarithm problem on secp256k1. A classical adversary attacks the implementation: nonces, firmware, the physical environment, and the trusted execution environment. Today, the second adversary is more realistic and less costly than the first. A security strategy that considers only the quantum horizon protects against a future threat while overlooking the current one.

Key Findings

  1. Air-gapping does not guarantee confidentiality. The exfiltration model shows that a 32-byte ML-DSA seed leaks over a covert channel just as quickly as an ECDSA scalar. Even a 2560-byte expanded ML-DSA-44 key escapes over fast channels in seconds. Hypothesis H1 of the first study is supported: a post-quantum signature changes the payload size but does not close the channel.

  2. A valid signature does not establish an honest nonce.Verbücheln’s kleptogram produces signatures that pass standard verification and are indistinguishable from honest signatures to everyone except the attacker. Trust in nonces can be established only through procedures and protocols: reproducible builds from signed tags, RFC 6979 determinism checked against test vectors, and anti-exfil protocols in which the host contributes its own randomness to the nonce and verifies the result.

  3. A signature is a communication channel. Any freedom of choice available to the signer implies potential covert-channel capacity. An offline wallet publishes its outputs on the blockchain and can thereby reveal its key without any network interface. This conclusion also applies to post-quantum schemes with internal randomness.

  4. A modular TEE is necessary but insufficient.The architecture of a TA behind a virtual function table plausibly reduces signature-algorithm replacement to an OTA module update. However, a TEE protects against key extraction, not against Shor, and does not solve the protocol-level problem: an ML-DSA-44 signature is approximately 38 times larger than an ECDSA signature, so migration requires changes to Bitcoin transaction formats and consensus (BIP-360 and subsequent proposals). Hypothesis H1 of the fourth study is supported only in its measurable part (“it fits and runs fast enough”). Hot-swapping via FOTA, isolation, and rollback require testing on the full OP-TEE/Android stack.

  5. The nonce is ECDSA’s main classical bottleneck. Disclosure, reuse, cross-key correlation, and faults reduce key recovery to linear algebra modulo n. This is confirmed numerically on synthetic keys, while control cases with different k fail to recover the key, as expected. Classical and quantum vectors are asymmetric: a quantum computer is not needed to exploit a reused k, nor would it fix this error.

Practical Recommendations

  • Use vetted implementations with constant-time signing (libsecp256k1) and deterministic RFC 6979 nonces, optionally with additional randomness. Check results against test vectors and record the build commit as audit evidence.

  • For hardware and offline wallets, choose anti-exfil protocols (sign-to-contract) in which the device’s nonce verifiably depends on host randomness. A kleptographic backdoor then ceases to be indistinguishable.

  • Treat an isolated device as potentially capable of “talking”: control peripherals and USB, shield the device, suppress acoustic, optical, and electromagnetic side channels, and separate signing and verification roles.

  • Avoid address reuse and account for the output type. A public key published on the blockchain becomes a long-term target for a future quantum adversary.

  • Apply the same requirements to FIPS 204/205 as to ECDSA: key-length validation, test vectors, reproducible builds, and protection against side channels and faults. The liboqs-python wrapper vulnerability fixed in October 2026 shows that an implementation input-handling error can enable post-quantum signature forgery.

  • Use monitoring of repeated r values on the blockchain as a diagnostic tool, not an unconditional filter: deterministically signing the same digest again is not dangerous.

Limitations and Directions for Future Research

The results were obtained using synthetic data under laboratory conditions. The exfiltration model is arithmetic and does not reproduce physical channels. The fault attack is treated as an algebraic model without demonstrating a hardware fault. Host-computer benchmarks provide only guidance and do not replace TA tests on target ARM hardware. Quantum cryptanalysis was not simulated, and no date is predicted for the emergence of a quantum computer capable of breaking secp256k1. The next steps follow from these limitations: a lattice attack on biased nonces with an explicitly specified leakage model; a kleptogram on a small educational curve with indistinguishability testing; porting ML-DSA into an OP-TEE trusted application with latency and memory measurements on a real device; and quantitative analysis of the impact of post-quantum signatures on Bitcoin transaction weight and fees.

The article’s final thesis: quantum resistance is a necessary but insufficient condition for private-key security. Bitcoin’s post-quantum transition should be designed not as replacing one algorithm with another, but as a reassessment of the entire trust chain: randomness generation, the signing path, firmware, hardware isolation, update mechanisms, and transaction formats. A key protected against Shor but exposed through a nonce, a covert channel, or a compromised TEE remains vulnerable.

 


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


This material was created for the CRYPTO DEEP TECH portal to support financial data security and elliptic-curve cryptography on secp256k1 against weak ECDSA signatures in the BITCOIN cryptocurrency. The software creators are not responsible for the use of these materials.


Source Code

PQ Evidence

Telegram: https://t.me/cryptodeeptech

Video Material: https://youtu.be/p6_5GjMT22M

Video tutorial: https://dzen.ru/video/watch/6afcd233e1f1bc6933d5118f

Source: https://cryptodeeptech.ru/leaking-before-shor


Private Keys Leak Before Shor: Nonces, Covert Channels, and the Illusion of Isolation on Bitcoin’s Path to Post-Quantum Cryptography


 

Cryptanalysis

Did you enjoy this article?


CryptoDeep
CryptoDeep

Financial security of data and secp256k1 elliptic curve cryptography against weak ECDSA signatures in BITCOIN cryptocurrency


CRYPTODEEP
CRYPTODEEP

Financial security of data and secp256k1 elliptic curve cryptography against weak ECDSA signatures in BITCOIN cryptocurrency [email protected] - Email for all questions. The creators of the software are not responsible for the use of materials Donation Address: ♥ BTC: 1Lw2gTnMpxRUNBU85Hg4ruTwnpUPKdf3nV ♥ETH: 0xaBd66CF90898517573f19184b3297d651f7b90bf ♥ YooMoney.ru/to/410011415370470

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?