Probability theory, as presented by E.S. Ventzel, is not an abstract mathematical course, but a working tool for a cryptanalyst. Applied to Bitcoin’s ECDSA, it allows:
- formally describe the defects of nonce generation and construct their probabilistic models;
- statistically detect anomalies in publicly available signatures;
- estimate the required number of signatures and the probability of success of a lattice attack;
- construct confidence intervals for attack parameters;
- justify the choice of significance level and control for type I and type II errors.
Content
- Introduction: Why Probability Theory is Critical to ECDSA
- Mathematical apparatus from the course by Wentzel
- Anatomy of ECDSA and the role of nonce
- Probability models of nonce distribution
- Statistical nonce anomaly detection
- The probabilistic nature of HNP and lattice attacks
- Probability limits for attack success
- Practical Algorithm: From Theory to Key Recovery
- Real-World Case Study: Bitcoin, 2019
- Conclusion
- Directions for further research for cryptanalysis based on this area
1. Introduction: Why Probability Theory is Critical to ECDSA
The ECDSA (Elliptic Curve Digital Signature Algorithm) algorithm underlies transaction authentication in Bitcoin and thousands of other cryptocurrency systems. Its security rests on three pillars: the difficulty of the elliptic curve discrete logarithm problem (ECDLP), the correctness of its implementation, and—what’s often overlooked— the quality of nonce generation k .
E.S. Ventzel’s classic textbook “Probability Theory” (1969, 2005) provides precisely the tools needed to formally describe nonce deviations from an ideal uniform distribution, estimate the probability of accumulating sufficient statistics for an attack, and construct confidence intervals for the attack parameters. Without this tools, a cryptanalyst is forced to act heuristically, estimating by eye how many signatures need to be collected and the probability of success.
The key idea is that the nonce k in ECDSA is a random variable uniformly distributed in [1, n−1] an ideal implementation. Any deviation from this uniformity—such as a shift in the high-order bits, length reduction, or correlation with the message hash—transforms the private key recovery problem d into a statistical problem of estimating a hidden parameter from a sample of observed signatures (r, s).
As early as 2019, Breitner and Heninger demonstrated that by applying lattice attacks to signatures with biased nonces, it was possible to calculate hundreds of Bitcoin, Ethereum, and SSH private keys.[reference:0] Later, special nonces were discovered k = h_msb ‖ d_msbthat allow a key to be recovered from a single signature.[reference:1] All of these attacks rely on probabilistic estimates.
2. Mathematical apparatus from the course by Wentzel
Of all the richness of Wentzel’s textbook, the following sections are most in demand for ECDSA cryptanalysis.
2.1. Random variables and their distributions
Nonce k is modeled as a discrete random variable. The ideal distribution is uniform on {1, …, n−1}. Real-world implementations yield distributions with “heavy tails” toward small values, biased toward the high-order bits, or correlated with the hash h.
2.2. Numerical characteristics
The mathematical expectation E[k], variance D[k], and covariance cov(k_i, k_j) for adjacent signatures all allow us to quantitatively characterize the generator defect.
2.3. Law of Large Numbers (LLN)
The Chebyshev or Bernoulli form of the LLN provides a rationale for the convergence of sample means of observed quantities (e.g., k bit lengths) to theoretical values. This allows one to draw conclusions about the generator’s parameters based on a finite sample of signatures.
2.4 Central Limit Theorem (CLT)
The CLT allows one to approximate the distribution of a sum of independent identically distributed random variables by a normal distribution. In ECDSA cryptanalysis, this is used to estimate the distribution of statistics constructed from signatures and to calculate the power of tests.
2.5. Chernoff’s inequality
Chernoff bounds provide exponentially decreasing estimates for the probabilities of large deviations. They are a key tool for estimating the probability that a randomly chosen nonce will be “short enough” for a lattice attack.
2.6. Testing statistical hypotheses
Goodness-of-fit tests (Pearson chi-square, Kolmogorov–Smirnov) allow one to formally test a hypothesis H₀: k ~ Uniform(1, n−1) against an alternative H₁: k имеет смещение.
2.7. Confidence intervals
From a sample of signatures, a confidence interval can be constructed for the probability p that a nonce has a certain defect (e.g. p = P(k < n/2^l)).
3. ECDSA anatomy and the role of nonce
Let’s recall the ECDSA scheme on the secp256k1 curve used in Bitcoin.
Parameters: elliptic curve E, G order base point n (for secp256k1 n ≈ 2^256). Private key d ∈ [1, n−1], public key Q = dG.
Message signature with hash h:
- A random nonce is selected
k ∈ [1, n−1]. - The point is calculated
R = kG;r = R_x mod n. - Calculated
s = k^{-1}(h + r·d) mod n. - Signature – pair
(r, s).
From the signature equation follows the fundamental relationship:
k = s^{-1} (h + r d) mod n
If k λ is known at least partially or has a probabilistic bias, this relationship becomes an equation for d. This is where probability theory turns “noise” into information.
Why reuse k is deadly. If two messages are signed with the same nonce k, then [ r is a match]. From the two equations s₁ = k^{-1}(h₁ + r d) [and ], s₂ = k^{-1}(h₂ + r d) we immediately obtain k = (h₁ − h₂)/(s₁ − s₂) mod n[and then d = (s₁ k − h₁)/r mod n]. The probability of a random match k for a 256-bit nonce is negligible, but the systematic error of the generator makes this event a regular occurrence.
4. Probability models of nonce distribution
Let us consider the main types of nonce generation defects and their probabilistic models.
4.1. MSB Bias
Let k has l high-order bits that are zero with high probability. Then 0 ≤ k < n / 2^l. The probability of such an event in an ideal model is 2^{-l}, but in a real implementation it could be, say, p = 0.3 for l = 8. This means that every eighth signature (on average) provides 8 bits of information about d.
Connection with Wentzel. This is a classic Bernoulli scheme: each signature is a trial with a probability of “success” (a short nonce) p. The number of successes X in N signatures has a binomial distribution Bi(N, p). The mathematical expectation is E[X] = Np, the variance is D[X] = Np(1−p).
4.2. Short nonce
The generator produces k a nonce of length b < 256 bits. Then k < 2^b. If b = 128, the probability of such an event is ideally 2^{-128}, but an implementation error can cause this to happen systematically. Breitner-Heninger’s paper discovered Bitcoin keys with nonces of 64 and 128 bits [reference:2].
4.3 Correlation with message hash
An exotic, but realistic, case: k = h_msb ‖ d_msb. Here, the nonce isn’t simply biased—it’s deterministically linked to the hash and private key. The probabilistic model here degenerates into an algebraic one, but detecting such a pattern requires statistical analysis of large samples.
4.4 Nonce reuse
The probability of random repetition k in N signatures is estimated using the “birthday paradox” formula:
P(reuse) ≈ 1 − exp(−N² / (2n))
For n ≈ 2^256 and N = 10^9 this probability is of the order of 10^{-59}. However, with a deterministic generator (e.g., RFC 6979), repetition is excluded, and with a weak PRNG, it becomes inevitable.
5. Statistical nonce anomaly detection
Task: Using publicly available signatures (r_i, s_i, h_i) from a blockchain, determine whether there is a statistically significant deviation in the distribution k_i.
5.1 Direct observation is not possible
We don’t know k_i, we don’t know d. But we do know that k_i = s_i^{-1}(h_i + r_i d) mod n. It’s a linear function of d. Under the hypothesis, H₀: d ~ Uniform we can numerically model the distribution of statistics.
5.2. Chi-square test for least significant bits r
The least significant bit r (or k) is ideally equally probable. Generator bias often manifests itself in the least significant bits. We apply Pearson’s criterion:
χ² = Σ (O_i − E_i)² / E_i
where O_i are the observed frequencies of bits 0 and 1, E_i = N/2. For , H₀ the statistic is asymptotically distributed as χ²(1). If χ² > χ²_{крит}(1, α), the uniformity hypothesis is rejected at the significance level α.
5.3. Test for “short” nonces via s
It follows from the equation s = k^{-1}(h + r d) mod n that when λ is small, k the value s tends to be large (since k^{-1} λ is large). More precisely, one can construct a statistic based on the ratio s / h λ or s · r^{-1}λ and test its distribution for normality (CLT) or the presence of heavy tails.
5.4 Confidence interval for the probability of defect
Let be X the number of signatures in which k < n/2^l (is determined indirectly, for example, by anomalously large s). Then X ~ Bi(N, p). By the De Moivre–Laplace theorem:
p̂ ± z_{α/2} · √(p̂(1−p̂)/N)
— asymptotic confidence interval for p level 1−α.
6. Probabilistic nature of HNP and lattice attacks
The Hidden Number Problem (HNP), formulated by Boneh and Venkatesan in 1996, is a bridge between probability theory and lattice cryptanalysis.
6.1. HNP setting
Given t_i ∈ Z_n and u_i = (d · t_i + e_i) mod n, where e_i are small errors with a known bound |e_i| < B. It is required to find d.
In the context of ECDSA: t_i = r_i / s_i mod n, u_i = h_i / s_i mod n, and the error e_i is related to the nonce: e_i = −k_i. If k_i is small (biased toward zero), then e_i is small, and HNP is decidable.
6.2 Probabilistic interpretation
Each signature yields a noisy linear equation with respect to d. Noise is k_i, a random variable with an unknown distribution. If the distribution k_i is concentrated near zero (or has a bias), then information about d accumulates.
d = (s_i k_i − h_i) / r_i mod n
The probability that a randomly chosen nonce is “useful” (i.e., |k_i| < B) is p = P(|K| < B). The number of useful signatures among N is a binomial value. A successful lattice attack typically requires d ≈ 2l useful signatures, where l is the number of known bits of the nonce.
6.3. Lattice attack as a probabilistic algorithm
L A lattice of dimension λ is constructed m+1 with a basis depending on t_i, u_i, l_i. The CVP (Closest Vector Problem) is then solved using LLL or BKZ. Success depends on how (k_1, …, k_m) close the error vector is to zero. The probability of success is the probability that the norm of the error vector does not exceed a bound determined by the lattice geometry:
P_success ≈ P( ‖v‖² ≤ E[‖v‖²] )
where v is the error vector. Analysis of this probability requires the central limit theory and Chernoff’s inequality [reference:3].
7. Probability limits for attack success
One of the strengths of the Wentzel device is the ability to obtain guaranteed estimates of the probability of success.
7.1 Chernoff’s inequality for the number of short nonces
Let be X ~ Bi(N, p) the number of signatures with k < B. Then for any δ > 0:
P(X ≥ (1+δ)Np) ≤ exp( −Npδ² / 3 )
This allows us to estimate how many signatures need to be collected to likely 1−ε obtain equally d useful nonces:
N ≥ (d / p) (1 + √(2 ln(1/ε) / d))
7.2. Estimation of the required number of signatures
For 256-bit ECDSA with l known nonce bits (e.g., l = 4 high-order bits are zero), the order N ≈ 100–200 of signatures required for a successful lattice attack is empirically . The theoretical lower bound, derived from information theory, is N ≥ 256 / l. For l = 4 this N ≥ 64.
Number of known bits l | Expected number of signatures for a 256-bit key | Probability of success (empirical) |
|---|---|---|
| 1 | ~1000 | low (requires special methods) |
| 2 | ~500 | < 62%[reference:4] |
| 3 | ~200 | high |
| 4 | ~100 | very high |
| 8 | ~30 | almost 100% |
7.3. Probability of false positives
When statistically detecting anomalies, it’s important to control for Type I error. The significance level α is selected based on the following considerations:
α = 1 / (2^256) — for cryptographic strength, α = 0.001 — for practical analysis.
8. Practical algorithm: from theory to key recovery
Step 1: Data Collection
All signatures (r, s, h) for the target address are extracted from the Bitcoin blockchain. You can use public APIs (Blockstream, Blockchain.com) or a local node.
Step 2. Preliminary statistical processing
- Check for a
rnonce reuse. If found, immediately restoredusing the formulas in Section 3. - Construction of a distribution histogram
sandr. - Applying the chi-square test to the least significant bits
r.
Step 3. Estimating the bias parameters
If the uniformity hypothesis is rejected, we estimate the parameter p (the probability of a short nonce) using the maximum likelihood method or through a confidence interval.
Step 4. Generating an HNP instance
For each signature, we calculate t_i = r_i / s_i mod n, u_i = h_i / s_i mod n. We retain only those signatures where k_i is small with high probability (for example, according to the criterion of abnormally large s_i).
Step 5. HNP solution via LLL/BKZ
We construct a lattice with a basis:
B = [ 2^{l_1} n 0 … 0 0 ] [ 0 2^{l_2} n … 0 0 ] [ … … … … … ] [ 2^{l_1} t_1 2^{l_2} t_2 … 2^{l_d} t_d 1 ]
and the target vector u = (2^{l_1} u_1, …, 2^{l_d} u_d, 0). We solve CVP using LLL or BKZ[reference:5].
Step 6. Verification
The resulting candidate d' is verified: for each signature, we calculate k_i' = s_i^{-1}(h_i + r_i d') mod n and verify whether it k_i' lies within the expected range (is small or has misaligned bits). Additionally, we can check whether d'G = Q (the public key) is valid.
Probabilistic interpretation. Each step of this algorithm relies on estimates from probability theory: how many signatures to collect, which to discard, what is the probability of a false candidate. Without these estimates, a lattice attack turns into a brute-force attack.
9. Case Study: Bitcoin, 2019
Breitner and Heninger analyzed signatures in the Bitcoin, Ethereum, and Ripple blockchains, as well as HTTPS and SSH scans. Using HNP-based lattice attacks, they calculated:
- about 300 Bitcoin private keys;
- multiple Ethereum and SSH keys;
- multiple keys compromised through nonce reuse[reference:6].
Types of vulnerabilities:
- Short nonces (64 and 128 bits instead of 256) were found in 302 keys[reference:7].
- Nonces with a common prefix or suffix allow the use of HNP with a smaller number of signatures.
- Nonce reuse is a trivial hack.
Cost: approximately 40 CPU years for all calculations. This demonstrates that probabilistically based attacks on real cryptocurrency systems are feasible .
10. Conclusion
Probability theory, as presented by E.S. Ventzel, is not an abstract mathematical course, but a working tool for a cryptanalyst. Applied to Bitcoin’s ECDSA, it allows:
- formally describe the defects of nonce generation and construct their probabilistic models;
- statistically detect anomalies in publicly available signatures;
- estimate the required number of signatures and the probability of success of a lattice attack;
- construct confidence intervals for attack parameters;
- justify the choice of significance level and control for type I and type II errors.
The key takeaway: ECDSA security is a probabilistic statement . It is violated not only by a full disclosure k, but also by a statistically significant deviation from a uniform distribution. Wentzel’s textbook provides the language in which this deviation can be measured, estimated, and—ultimately—used to recover the private key.
Directions for further research for cryptanalysis based on this area
Below are listed promising directions that combine Wentzel’s probabilistic apparatus with modern ECDSA cryptanalysis.
1. Adaptive Statistical Tests for Online Blockchain Monitoring
Developing sequential probability ratio tests (SPRTs) to detect nonce anomalies in real time as new transactions are received will require the application of random process and martingale theory, which goes beyond the scope of the classical course but is based on the same probabilistic principles.
2. Bayesian methods for estimating nonce distributions
Using Bayesian inference to estimate the posterior distribution of defect parameters p based l on observed signatures. This will allow combining prior knowledge of typical implementation errors (e.g., from CVE databases) with blockchain data.
3. Machine learning to discover hidden correlations
Application of neural networks and anomaly detection methods (autoencoders, isolation forests) to time series s_i. r_iProbabilistic h_iinterpretation of the outputs of such models will require calibration using confidence intervals and goodness-of-fit criteria.
4. Analysis of temporal side channels through probabilistic models
Attacks like Minerva and LadderLeak demonstrate that even less than one bit of nonce information can be sufficient to recover the key.[reference:8] Probabilistic modeling of the execution time of scalar multiplication operations will help clarify the applicability of such attacks.
5. Quantum-resistant cryptanalysis of ECDSA
Although Shor’s algorithm solves ECDLP in polynomial time, probabilistic methods remain relevant for hybrid circuits and for analyzing post-quantum signatures (e.g., on lattices). Extending the Wentzel apparatus to lattice problems (LWE, SIS) is an open area.
6. Formal verification of probabilistic attack boundaries
Using interactive proofs (Coq, Lean) to formalize estimates of the success probability of lattice attacks. This will eliminate errors in empirical estimates and create certified cryptanalysis tools.
7. Statistical analysis of nonces in PoW blockchains
Interestingly, nonces in Bitcoin block headers (not to be confused with ECDSA nonces) also have a non-uniform distribution—even ones are more common than odd ones [reference:9]. Studying such anomalies could provide new insights into miner behavior and, indirectly, the quality of randomness generators in the ecosystem.
General trend. The future of ECDSA cryptanalysis lies in integrating classical probability theory (Wentzel, Gnedenko, Feller) with modern computational methods—lattice reduction, machine learning, and Bayesian inference. The first to build an adaptive probabilistic model of the nonce generator will gain the key to thousands of vulnerable wallets.
This document is based on the following materials: E.S. Wentzel, “Probability Theory” (1969, 2005); Breitner & Heninger, “Biased Nonce Sense” (2019); Osaki & Kunihiro, “Bias from Uniform Nonce” (SAC 2024); IACR ePrint 2023/841; and other open sources on ECDSA cryptanalysis.
