In this paper, we systematically present the application of fundamental results of probability theory, presented in A. A. Borovkov’s textbook “Probability Theory” (1986), to the problem of cryptanalysis of ECDSA signatures in the Bitcoin blockchain. Key findings:
- Chebyshev’s inequality provides a simple and general estimate of the required number of signatures
mto reliably detect nonce bias, without requiring knowledge of the specific distribution. - The law of large numbers justifies the validity of sample estimates of nonce distribution parameters, which allows for the construction of adaptive attack algorithms that do not require a priori information.
- The central limit theorem ensures asymptotic normality of sample means and allows for the calculation of accurate confidence intervals for bias parameters, which is critical for calibrating lattice algorithms.
- Large deviation estimates allow us to estimate the probability of “extreme” scenarios (e.g., when all nonces fall within a very short interval), which is necessary to guarantee the success of LLL/BKZ.
The practical significance of these results is confirmed by real attacks on the Bitcoin blockchain, during which hundreds of private keys were recovered [reference:5]. Borovkov’s probability theory is thus not an abstract mathematical tool, but a working apparatus for quantitative analysis and planning of cryptanalytic attacks .
Content
- Introduction
- Formal statement of the ECDSA problem
- Key results of Borovkov’s probability theory applicable to cryptanalysis
- Reducing the key recovery problem to the hidden number problem (HNP)
- Probabilistic analysis of biased nonce values
- From Probabilistic Estimates to Lattice Basis: A Practical Algorithm
- Bitcoin Blockchain Specifics: Detecting Vulnerable Signatures
- Conclusion
- Directions for further research for cryptanalysis based on this area
1. Introduction
The Elliptic Curve Digital Signature Algorithm (ECDSA) is the cornerstone of transaction security on the Bitcoin blockchain. Its cryptographic strength is based on the assumption that the discrete logarithm problem is computationally difficult on a set of points on an elliptic curve. However, as practice shows, the actual security of ECDSA critically depends not on the strength of the curve itself, but on the quality of the generation of an ephemeral secret number k —the so-called nonce (a number used only once).
If the sequence of nonce values k₁, k₂, …, k_mused to sign different messages with the same private key dis not uniformly distributed over the set {1, 2, …, n−1} (where n is the order of the base point of the secp256k1 elliptic curve), then an attacker, given only public data—messages, their hashes, and signature components (r, s) —can recover the long-term private key d. This fundamental observation was theoretically substantiated in the work of Howgrave-Graham and Smart, and then developed in a series of practical attacks on real blockchains (Breitner & Heninger, 2019; et al.)[reference:0].
This paper presents a systematic exposition of how classical results from probability theory, presented in A. A. Borovkov’s textbook “Probability Theory” (2nd ed., Moscow: Nauka, 1986) , can be applied to the formal analysis and practical implementation of attacks on ECDSA signatures in the Bitcoin blockchain. We show that fundamental tools such as Chebyshev’s inequality , the law of large numbers , the central limit theorem , and asymptotic estimates of large deviation probabilities underlie quantitative criteria that allow:
- determine the minimum number of signatures
mrequired for a successful attack at a given nonce bias level; - assess the probability of successful key recovery in the presence of noise and errors in the original data;
- construct an efficient lattice algorithm (LLL/BKZ) for solving the hidden number problem (HNP) with guaranteed probability.
2. Formal statement of the ECDSA problem
Let us recall the formal description of the ECDSA algorithm over the elliptic curve secp256k1 used in Bitcoin.
2.1. Parameters and notations
| Designation | Description |
|---|---|
E | Elliptic curve secp256k1: y² = x³ + 7 mod p |
G | Base point (generator) of a curve point group |
n | The order of the point G (prime number, ~2²⁵⁶) |
d | Private key, 1 ≤ d ≤ n−1 |
Q = dG | Public key (point on the curve) |
H(m) | The SHA-256 hash function of the message m, given modulo n |
k | Ephemeral secret nonce, 1 ≤ k ≤ n−1 |
2.2. Signing procedure
To sign a message m with a private key d:
- A random (or pseudo-random) number is generated
k ∈ {1, …, n−1}. - The point
R = kG; is calculatedr = R.x mod n. Ifr = 0, the selectionkis repeated. - Calculated
s = k⁻¹(H(m) + r·d) mod n. Ifs = 0, the selectionkis repeated. - Signature – pair
(r, s).
2.3. Equation relating nonce and private key
From step 3 we obtain the fundamental linear relation in absolute value n:
s k ≡ H(m) + r d (mod n)(1)
Resolving relatively k:
k ≡ s⁻¹·H(m) + s⁻¹·r·d (mod n)(2)
Let us denote z = H(m), a = s⁻¹·z mod n, b = s⁻¹·r mod n. Then:
k ≡ a + b d (mod n)(3)
The key observation is that if an attacker knew the exact values k₁, k₂, …, k_m for several signatures, they could recover them d by simply solving a system of linear equations modulo n. However, k α is unknown. The problem is that α k is not completely unknown : if the nonce generator is statistically biased, then α k belongs to some probability distribution α concentrated around zero modulo α n. This is where probability theory comes into play.
3. Key results of Borovkov’s probability theory applicable to cryptanalysis
A. A. Borovkov’s textbook “Probability Theory” (1986) covers a wide range of fundamental results, from Kolmogorov’s axiomatics to limit theorems and elements of the theory of random processes.[reference:1] Listed below are those sections and theorems that are directly applicable to the analysis of ECDSA signatures with weakened nonce generation.
3.1. Chebyshev’s inequality and its role in estimating the required number of signatures
Let X₁, X₂, …, X_m be a sequence of independent identically distributed random variables with mean μ = E[Xᵢ] and variance σ² = D[Xᵢ] < ∞. Chebyshev’s inequality states that for any ε > 0:
P(|X̄_m − μ| ≥ ε) ≤ σ² / (m ε²)(4)
where X̄_m = (X₁ + … + X_m)/m is the sample mean.
Application to ECDSA: Consider a nonce sequence k₁, k₂, …, k_m. We introduce a random variable Xᵢ = kᵢ. If the nonce generator is biased, then E[kᵢ] ≠ (n−1)/2, and the variance D[kᵢ] reflects the spread of values. Inequality (4) provides an upper bound on the probability that the sample mean of nonce will deviate from the true mathematical expectation by more than ε. In the context of the attack, this means: the more signatures m, the more likely we can estimate the parameters of the nonce distribution and, therefore, localize the region in which the true values lie kᵢ .
3.2. The law of large numbers (LLN) and the consistency of statistical estimates
Kolmogorov’s theorem on the law of large numbers (strengthened LLN) states that for E[|X₁|] < ∞:
X̄_m → μ almost surely as m → ∞(5)
Application to ECDSA: if nonces are generated with some stationary distribution (even unknown), the sample mean k̄_m converges to the true mathematical expectation. This allows for asymptotically accurate estimation of bias parameters based on a large number of signatures from the blockchain. Moreover, the LBN justifies the consistency of sample moments as estimates of theoretical moments, which is critical for constructing an attack algorithm that does not require a priori knowledge of the nonce distribution.
3.3 Central Limit Theorem (CLT) and Asymptotic Normality
The central limit theorem in Borovkov’s formulation states that when the Lindeberg condition is satisfied:
√m·(X̄_m − μ) / σ → N(0, 1) by distribution as m → ∞(6)
Application to ECDSA: The CLT allows constructing asymptotic confidence intervals for an unknown μ nonce. If we observe m signatures and calculate the sample mean k̄_m and sample variance S²_m, then with probability 1 − α the true value μ lies in the interval:
k̄_m ± z_{α/2} S_m / √m(7)
where z_{α/2} is the quantile of the normal distribution. This interval allows us to quantify how biased the nonce generator is and, therefore, determine whether the attack is computationally feasible.
3.4. Asymptotic estimates of the probabilities of large deviations
In the chapter on limit theorems, Borovkov considers estimates of the probabilities of events of the form {X̄_m ≥ x} for x > μ large m. These estimates (of the Cramer and Chernoff type) have the form:
P(X̄_m ≥ x) ≈ exp(−m I(x))(8)
where I(x) is the rate function.
Application to ECDSA: If an attacker wants to guarantee that all m nonce values lie within some “short” interval of length 2^ℓ (which is necessary for the successful application of the lattice algorithm), the probability of this event decreases exponentially with increasing m. Estimates of large deviations allow one to accurately calculate the required number of signatures m as a function of the length ℓ of the known high-order bits of the nonce .
4. Reducing the key recovery problem to the hidden number problem (HNP)
The Hidden Number Problem (HNP) was introduced by Boneh and Venkatesan and is formally defined as follows.
Definition (HNP). Let n be a prime number. Given m pairs (tᵢ, aᵢ), where tᵢ ∈ ℤ/nℤ are uniformly random, and aᵢ = MSB_ℓ(α·tᵢ mod n) are the most significant ℓ bits of the product of the unknown α ∈ ℤ/nℤ and tᵢ. Find α.
In the context of ECDSA, the role of the “hidden number” α is played by the private key d, and the role of is played tᵢ by the value rᵢ·sᵢ⁻¹ mod n. Indeed, from (1):
kᵢ = sᵢ⁻¹·H(mᵢ) + sᵢ⁻¹·rᵢ·d mod n(9)
Let us denote tᵢ = sᵢ⁻¹·rᵢ mod n, uᵢ = sᵢ⁻¹·H(mᵢ) mod n. Then:
kᵢ = uᵢ + tᵢ·d mod n(10)
If nonce is kᵢ “small” (i.e., its high-order bits are zero), then we know that it uᵢ + tᵢ·d mod n lies in the interval [0, 2^ℓ). This is exactly HNP c aᵢ = 0 (all known high-order bits are zero).
Probabilistic interpretation: even if kᵢ λ are not strictly equal to zero, but are distributed near zero (for example, kᵢ ~ N(0, σ²) truncated by [0, n)), we can treat λ kᵢ as random variables with a known (or estimated) distribution. The problem of reconstructing λ then d becomes a statistical estimation problem , and Borovkov’s probability theory provides tools for analyzing its solvability.
5. Probabilistic analysis of biased nonce values
5.1 Bias Model: MSB and LSB Truncation
In practice, the two most common types of nonce offset are:
- MSB bias (Most Significant Bit Bias): the generator returns values
kfrom the range[0, 2^{256−ℓ}), i.e., the most significantℓbits are always zero. This is observed in poor-quality implementations, such as those usingrand() % ntruncated hashes. - LSB bias (Least Significant Bit bias): The least significant
ℓbits of the nonce are fixed (e.g. zero) due to bit masks or errors in arithmetic.
In both cases, it belongs to the power k subset (for MSB) or (for LSB, if the least significant bits are fixed).K_ℓ ⊂ ℤ/nℤ2^{256−ℓ}2^{256−ℓ}ℓ
5.2. Estimating the probability of falling into the “short” interval
Suppose the nonce generator has an MSB bias of k ∈ [0, B), where B = 2^{256−ℓ}. For a randomly chosen nonce, the probability that it falls in the interval [0, B), assuming uniform distribution on , [0, n) is B/n ≈ 2^{−ℓ}.
However, if the generator systematically produces values from [0, B), then each observed nonce already belongs to this interval with probability 1. This means that each signature gives us ℓ a bit of information about d (in the information theory sense).
We apply Chebyshev’s inequality to estimate the variance. If k is uniformly distributed on [0, B), then:
E[k] = (B−1)/2 ≈ 2^{255−ℓ}, D[k] = (B²−1)/12 ≈ 2^{510−2ℓ}/12(11)
For m independent signatures, the sample mean k̄_m has variance D[k]/m. Then, by Chebyshev’s inequality:
P(|k̄_m − E[k]| ≥ ε) ≤ D[k] / (m ε²) ≈ 2^{510−2ℓ} / (12 m ε²)(12)
Practical conclusion: in order to guarantee with a probability of at least 1 − δ , that the sample mean nonce will deviate from the theoretical one by no more than ε = 2^{255−ℓ}/4, it is necessary:
m ≥ 2^{510−2ℓ} / (12 δ (2^{255−ℓ}/4)²) = 2^{510−2ℓ} / (12 δ 2^{510−2ℓ}/16) = 16 / (12 δ) = 4 / (3δ)(13)
This is a remarkable result: the required number of signatures m is independent of the length of ℓ known bits (using a rough estimate such as Chebyshev’s inequality). However, this is only an upper bound; in practice, the CLT and large deviation estimates yield much more precise (and less optimistic) bounds.
5.3. Using the CPT for accurate calculation of the number of signatures
Using the CLT (6), to achieve the probability of success 1 − δ in detecting a displacement of magnitude ε it is necessary:
m ≥ (z_{δ/2} σ / ε)²(14)
where σ = √D[k] ≈ 2^{255−ℓ}/√12, and z_{δ/2} is the quantile of the normal distribution. Substituting ε = 2^{255−ℓ}/4:
m ≥ (z_{δ/2} · 2^{255−ℓ}/√12 · 4 / 2^{255−ℓ})² = (4 · z_{δ/2}/√12)² ≈ 1.33 · z_{δ/2}²(15)
For , δ = 0.01 we have z_{0.005} ≈ 2.576, which yields m ≥ 1.33 · 6.64 ≈ 8.8, i.e., approximately 9 signatures are sufficient . This is consistent with practical results: in the work of Breitner & Heninger, recovering Bitcoin keys with a 4-bit nonce offset required approximately 10–20 signatures [reference:2].
5.4 Large deviation estimates for the “all nonce in interval” guarantee
Lattice algorithms (LLL/BKZ) require that all m nonces lie within a known short interval. If kᵢ are independent and uniform on [0, B), then the probability that they all fall within [0, B/2)is (1/2)^m. For m = 20 this ≈ 10⁻⁶, , which is unacceptably small.
However, in practice, the nonce generator often has a deterministic bias (for example, it always returns k < 2^{248}) rather than a random one. In this case, all nonces kᵢ are guaranteed to lie in [0, 2^{248}), and large deviation estimates are unnecessary. Borovkov’s probability theory is applied here to test the hypothesis of such a deterministic bias using empirical data.
6. From Probabilistic Estimates to a Lattice Basis: A Practical Algorithm
6.1 Construction of the lattice for HNP
Once the probabilistic analysis has confirmed the presence of bias and determined the parameters ℓ and m, we proceed to constructing the lattice. The standard construction (Boneh–Venkatesan, Nguyen–Shparlinski) is as follows:
L = \begin{pmatrix} n & 0 & 0 & \cdots & 0 & 0 \\ 0 & n & 0 & \cdots & 0 & 0 \\ \vdots & & \ddots & & \vdots & \vdots \\ 0 & 0 & \cdots & n & 0 & 0 \\ t₁ & t₂ & \cdots & t_m & B/n & 0 \\ u₁ & u₂ & \cdots & u_m & 0 & B \end{pmatrix}(16)
where B = 2^ℓ is the boundary of the “short” nonce, tᵢ = sᵢ⁻¹·rᵢ mod n, uᵢ = sᵢ⁻¹·H(mᵢ) mod n. The vector (k₁, k₂, …, k_m, d·B/n, B) is a short vector of this lattice, and the LLL (or BKZ) algorithm allows one to find it.
6.2. Probabilistic guarantee of LLL success
The LLL guarantee theorem states that LLL finds a vector of length at most 2^{(d−1)/4} · det(L)^{1/d}, where d is the lattice dimension. Applied to HNP, this yields the success condition:
B < n^{1−ε} 2^{−O(m)}(17)
More precise estimates that take into account the nonce distribution allow us to significantly relax this condition. This is where Borovkov’s asymptotic methods (in particular, estimates of large deviation probabilities for sums of independent random variables) make it possible to calculate the probability of LLL success as a function of m, , ℓ and the parameters of the nonce distribution.
6.3. Attack pseudocode
АЛГОРИТМ: Восстановление приватного ключа ECDSA через HNP + LLL
ВХОД: Список из m подписей (rᵢ, sᵢ, H(mᵢ)) для одного публичного ключа Q
ВЫХОД: Приватный ключ d или НЕУДАЧА
1. Для каждого i = 1..m:
tᵢ ← sᵢ⁻¹ · rᵢ mod n
uᵢ ← sᵢ⁻¹ · H(mᵢ) mod n
2. Оценить параметр смещения ℓ:
- Собрать статистику по tᵢ и uᵢ
- Использовать ЦПТ (6) для оценки дисперсии k
- Определить B = 2^ℓ такое, что P(k < B) ≈ 1
3. Построить решётку L размерности (m + 2) × (m + 2) по формуле (16)
4. Применить LLL-редукцию к L
(опционально: BKZ с параметром блока β для большей точности)
5. Для каждого короткого вектора v в приведённом базисе:
- Извлечь кандидата d' из предпоследней координаты: d' = v[m+1] · n / B
- Проверить: Q == d' · G?
- Если да — вернуть d'
6. Если ни один кандидат не подошёл — вернуть НЕУДАЧА
(увеличить m или ℓ и повторить)
7. Bitcoin Blockchain Specifics: Detecting Vulnerable Signatures
7.1 Extracting signatures from the blockchain
The Bitcoin blockchain offers a unique opportunity for cryptanalysts: all transactions are publicly accessible and immutable . Each transaction contains a script scriptSigthat stores the signature components (r, s) in DER format. Signatures can be extracted using:
- Bitcoin full nodes (Bitcoin Core) with RPC command
getrawtransaction; - Public APIs (Blockstream, Blockchain.info) for receiving raw transactions;
- Specialized indexers (ElectrumX, Esplora) for fast search by
r-values.
7.2. Criteria for searching vulnerable signatures
Based on probabilistic analysis, practical criteria for scanning a blockchain can be formulated:
| Criterion | Probabilistic basis | Expected frequency |
|---|---|---|
r repeats for different messages | Repeat nonce: k₁ = k₂ ⇒ r₁ = r₂ | >3,000 keys found[reference:3] |
The most significant bits k are zero (low bits r) | MSB offset: P(k < 2^{ℓ}) ≈ 2^{−ℓ} | ~300 Bitcoin keys[reference:4] |
The least significant bits k are fixed. | LSB offset: k ≡ c (mod 2^ℓ) | Depends on implementation |
Abnormally low entropy k (by variance) | D[k] Sample Estimate | Requires a statistical test |
7.3 Statistical Test for Bias
To test a hypothesis H₀: k ~ Uniform(0, n−1) against an alternative, H₁: k ~ Biased one can use the chi-square test or the Kolmogorov–Smirnov test. However, direct application of these tests is difficult because k the values are unknown. Instead, one can analyze the distribution of the values recovered k for the hypothetical value dby searching through candidates over a narrow range.
A more effective approach is to use a uniformity test r . If k is uniformly distributed, then r = (kG).x mod n is also uniformly distributed [0, n) (up to collisions). Deviation of the empirical distribution r from uniformity can serve as an indicator of nonce bias.
8. Conclusion
In this paper, we systematically present the application of fundamental results of probability theory, presented in A. A. Borovkov’s textbook “Probability Theory” (1986), to the problem of cryptanalysis of ECDSA signatures in the Bitcoin blockchain. Key findings:
- Chebyshev’s inequality provides a simple and general estimate of the required number of signatures
mto reliably detect nonce bias, without requiring knowledge of the specific distribution. - The law of large numbers justifies the validity of sample estimates of nonce distribution parameters, which allows for the construction of adaptive attack algorithms that do not require a priori information.
- The central limit theorem ensures asymptotic normality of sample means and allows for the calculation of accurate confidence intervals for bias parameters, which is critical for calibrating lattice algorithms.
- Large deviation estimates allow us to estimate the probability of “extreme” scenarios (e.g., when all nonces fall within a very short interval), which is necessary to guarantee the success of LLL/BKZ.
The practical significance of these results is confirmed by real attacks on the Bitcoin blockchain, during which hundreds of private keys were recovered [reference:5]. Borovkov’s probability theory is thus not an abstract mathematical tool, but a working apparatus for quantitative analysis and planning of cryptanalytic attacks .
Ethics Disclaimer: This document is for educational and research purposes only. All described methods should only be applied to one’s own keys or as part of a legitimate security audit with the owner’s express permission. Unauthorized access to someone else’s cryptocurrency funds is a criminal offense.
9. Directions for further research for cryptanalysis based on this area
- Adaptive Bayesian nonce bias estimation. Developing Bayesian models in which the posterior distribution of the bias parameters is updated as new signatures arrive. This will allow dynamically determining the moment when the accumulated information is sufficient to launch a lattice attack, minimizing computational costs.
- Nonparametric tests for nonce uniformity. Application of goodness-of-fit tests (Kolmogorov–Smirnov, Anderson–Darling, Cramer–von Mises) to the distribution of recovered nonces under hypothetical keys. Development of efficient algorithms for detecting anomalies in distributions
rwithout knowledged. - Large deviation estimates for dependent nonces. In real-world implementations, nonces may not be independent (for example, when using a linear congruential generator). Extending Borovkov’s methods to weakly dependent sequences (m-dependence, martingales) will allow for the analysis of a wider class of vulnerabilities.
- Optimization of lattice constructions based on probabilistic models. Using asymptotic estimates of the nonce distribution to select optimal lattice parameters (dimension, scaling factors, BKZ strategy), which can reduce the computational complexity of the attack by orders of magnitude.
- Cryptanalysis of signatures with partially known nonces under noisy conditions. Developing robust key recovery algorithms when nonce information is corrupted by errors (e.g., due to measurement errors in side-channel attacks). Robust statistics and estimation theory methods are applicable here.
- Applying random process theory to nonce time series analysis. If the nonce generator has a time structure (e.g., parameter drift), random process theory methods (Markov chains, stationary processes) can be used to predict future nonces and, therefore, recover the key with fewer observations.
- Quantum Probabilistic Algorithms for the Hidden Number Problem. Investigation of the potential of quantum computing for solving the hidden number problem using quantum probability estimates and amplitude gain. Although practical quantum computers have not yet achieved the required power, theoretical analysis of the asymptotic complexity is of considerable interest.
The document has been prepared based on the textbook: Borovkov A. A. Probability Theory: A Textbook for Universities. — 2nd ed., revised and enlarged. — Moscow: Nauka. Ed. in Chief of Phys.-Math. Literature, 1986. — 432 p.
References: Breitner J., Heninger N. Biased Nonce Sense: Lattice Attacks against Weak ECDSA Signatures in Cryptocurrencies // IACR ePrint 2019/023.
