N.Sh. Kremer’s textbook “Probability Theory and Mathematical Statistics” provides a powerful and systematic framework for ECDSA cryptanalysis. Key findings:
- Modeling the nonce distribution using random variables and limit theorems allows us to formalize the concept of “bias” and assess its impact on security.
- Statistical hypothesis testing (Chapter 9) provides a rigorous criterion for detecting anomalies in nonce generation while controlling for type I and type II errors.
- Correlation and regression analysis reveals linear and polynomial relationships between successive nonces, which directly leads to a system of equations for recovering the private key.
- The Bayesian approach allows one to construct posterior distributions and use MAP estimates for robust key recovery.
- The Monte Carlo method provides an empirical estimate of the probability of an attack’s success given the given parameters.
- NIST tests serve as a practical tool for auditing nonce generators and identifying vulnerabilities before they are exploited.
Real-world attacks—from the PlayStation 3 to modern blockchain—confirm that the statistical methods outlined in Kremer’s textbook are not abstract theory, but a powerful cryptanalytic tool capable of recovering private keys and compromising millions of dollars in cryptocurrency.
Content
- Introduction: ECDSA and the Role of Nonces
- The structure of Kremer’s textbook and its relevance
- Application of probability theory: modeling the nonce distribution
- Statistical Hypothesis Testing: Detecting Nonce Bias
- Correlation and regression analysis of nonce
- A Bayesian approach to private key recovery
- Monte Carlo method and statistical modeling
- NIST Statistical Tests for Assessing Nonce Quality
- Real-World Attacks: PlayStation 3, Bitcoin Wallets, and Blockchain
- Conclusion
- Directions for further research for cryptanalysis based on this area
1. Introduction: ECDSA and the Role of Nonces
The Elliptic Curve Digital Signature Algorithm (ECDSA) underlies Bitcoin transaction security. When generating a signature, a secret one-time number k , called a nonce (number used once), is created for each message. This number is the critical security point: if k it is known for at least one signature, the private key can be recovered instantly.
Formally, the ECDSA signature process is described as follows[reference:1]:
R = (r, y) = k · G
s = k⁻¹ · (H(m) + r · d) mod n
where G is the generator point of the elliptic curve, n is the order of the curve, H(m) is the message hash, d and is the private key. From the signature equation, the private key is expressed as:
d = r⁻¹ · (k · s − H(m)) mod n
Thus, the task of cryptanalysis boils down to reconstructing the unknown k , or a significant portion of it. This is where the apparatus of probability theory and mathematical statistics, systematized in N.Sh. Kremer’s textbook, comes to the rescue.
The key idea is that if a nonce k is not generated perfectly uniformly, a statistically detectable bias appears in its distribution. Even a bias of less than one bit allows the private key to be recovered given a sufficient number of signatures [reference:2].
2. The structure of Kremer’s textbook and its relevance
The textbook by N.Sh. Kremer “Probability Theory and Mathematical Statistics” (2nd edition, Moscow: UNITY-DANA, 2004, 573 p.) contains two main sections[reference:3]:
| Chapter | Main Chapters | Application in ECDSA cryptanalysis |
|---|---|---|
| Section I. Probability Theory | Basic concepts and theorems, repeated independent tests, random variables, limit theorems | Modeling nonce distributions, estimating bias probabilities, limit theorems for large samples |
| Section II. Mathematical Statistics | Variation series, sampling method, testing of statistical hypotheses, correlation analysis, regression analysis | Detecting nonce bias, testing uniformity hypotheses, identifying linear relationships between nonces |
The textbook is distinguished by its practical focus: each chapter is accompanied by a large number of problems with solutions[reference:4]. This allows the methods studied to be directly applied to practical cryptanalysis problems.
3. Application of probability theory: modeling the nonce distribution
3.1 Ideal nonce distribution
According to the ECDSA standard, the nonce k must be uniformly distributed over the interval [1, n−1], where n is the order of the elliptic curve (for secp256k1 n ≈ 2²⁵⁶)[reference:5]. In terms of probability theory, this means that k ~ Uniform(1, n−1).
Using the concept of a random variable from Chapter 4 of Kremer’s textbook, we can write:
- Mathematical expectation: E[k] = (n+1)/2 ≈ 2²⁵⁵
- Variance: Var[k] = (n²−1)/12
- Standard deviation: σ[k] ≈ n/(2√3) ≈ 2²⁵⁴·⁴
3.2. Biased Nonce Model
In real implementations, nonces are often generated with a bias . Typical bias models[reference:6]:
| Displacement model | Probabilistic model | Consequence for cryptanalysis |
|---|---|---|
| Zero MSB (most significant bits are zero) | k ∈ [0, 2^(ℓ−l)) — in fact, k' with l zero high-order bits | Reduces to the hidden number problem (HNP) |
| Zero LSB (least significant bits are zero) | k = 2^l · k’, where k’ ~ Uniform | Similar to HNP after variable change |
| Short nonce | k < 2^b, where b ≪ 256 | Brute force or lattice attack |
| Affine dependence | k₂ = a k₁ + b (mod n) | A system of linear equations for d |
The probability of detecting bias in the presence N of signatures is described by the central limit theorem (Chapter 5 of Kremer’s textbook): the sample mean k̄ is asymptotically normal with parameters N(E[k], σ²[k]/N). This allows one to construct statistical tests.
4. Testing statistical hypotheses: detecting nonce bias
Chapter 9 of Kremer’s textbook “Statistical Hypothesis Testing”[reference:7] provides a formal apparatus for detecting anomalies in nonce generation.
4.1. Formulating hypotheses
To check the uniformity of the distribution of nonce, the following are formulated:
- H₀ (null hypothesis): nonce
kis uniformly distributed over [1, n−1] - H₁ (alternative hypothesis): the distribution
kis biased
The choice of statistics depends on the type of bias being suspected. For example, to test the hypothesis of zero high-order bits, the following statistics are used:
Z = (k̄ − μ₀) / (σ / √N)
where μ₀ = (n+1)/2, σ = n/(2√3). At , |Z| > z_{α/2} the null hypothesis is rejected at the significance level α.
4.2. Type I and II errors
Following the NIST methodology described in terms of hypothesis testing[reference:8]:
- Type I error (α): Rejecting H₀ when the nonce is actually uniform leads to a false detection of the attack
- Type II error (β): accepting H₀ when nonce is biased results in missing the vulnerability
For cryptographic applications, α ∈ [0.001, 0.01][reference:9] is recommended. It P-value is interpreted as the probability that a perfectly random generator would produce a sequence less random than the observed one.
4.3. The χ² test for testing uniformity
For discrete nonce samples, the Pearson goodness-of-fit test is used:
χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ
where Oᵢ are the observed frequencies of nonce falling into ithe -th interval, Eᵢ and are the expected frequencies under a uniform distribution. If χ² > χ²_{крит}(α, df) the uniformity hypothesis is rejected.
Practical note: Even in the absence of an explicit bias in the high-order bits, the correlation between the nonce and the message hash H(m) may indicate deterministic generation (e.g., k = H(d ‖ H(m))), making the nonce predictable if the key is compromised.
5. Correlation and regression analysis of nonce
Chapters 10 and 11 of Kremer’s textbook are devoted to correlation and regression analysis[reference:10]. These methods allow one to discover hidden dependencies between successive nonce values or between the nonce and other signature parameters.
5.1 Correlation analysis of consecutive nonces
If the nonce generator uses a weak source of entropy, the values k₁, k₂, ..., k_N may be correlated. Pearson’s correlation coefficient:
r = Σ (kᵢ − k̄)(kᵢ₊₁ − k̄) / Σ (kᵢ − k̄)²
A significant deviation r from zero indicates a linear relationship between successive nonces. This can be used to construct a system of equations for the private key.
5.2. Affine dependence regression model
If nonces are related by an affine relation k₂ = a·k₁ + b, then for two signatures with the same private key we obtain:
s₁ k₁ = H(m₁) + r₁ d (mod n)
s₂ (a k₁ + b) = H(m₂) + r₂ d (mod n)
Eliminating k₁, we arrive at a linear equation with respect to d:
d · (r₁ · s₂ · a − r₂ · s₁) = s₁ · s₂ · b − s₂ · H(m₁) + s₁ · H(m₂) · a (mod n)
Which gives a unique solution for d the invertibility of the coefficient.
5.3 Multiple Regression for Polynomial Relationships
For more complex (polynomial) dependencies between nonces, higher-order regression analysis is used[reference:11]:
k_{i+1} = a₀ + a₁ k_i + a₂ k_i² + … + a_m k_i^m (mod n)
The coefficients a_j are estimated using the least squares method, after which the problem is reduced to solving a system of polynomial equations for d.
6. Bayesian approach to private key recovery
Although Bayesian methods are not singled out in a separate chapter in Kremer’s textbook, the apparatus of conditional probabilities and Bayes’ formula (Chapter 3) allows one to construct a probabilistic model for key recovery.
6.1 Posterior distribution of nonce
Let the signatures (rᵢ, sᵢ, H(mᵢ)) and the prior distribution be known p(k). After observing the signature, the posterior distribution is:
p(k | r, s, H(m)) ∝ p(s | k, r, H(m), d) p(k)
Since d it is unknown whether marginalization or the EM algorithm is used, k ~ Uniform(0, 2^(n−l))the posterior distribution is concentrated in the region of small k, which allows for the elimination of false hypotheses.
6.2 Bayesian inference for affine nonces
If there is an affine relationship between nonces, a probabilistic model can be constructed:
P(a, b, d | data) ∝ P(data | a, b, d) · P(a, b, d)
Maximizing the posterior probability (MAP) yields the most plausible values (a, b, d). For a large number of signatures, the posterior distribution becomes highly concentrated, ensuring robust key recovery.
7. Monte Carlo method and statistical modeling
The Monte Carlo method, considered in the context of limit theorems and statistical modeling, allows:
- Estimate the probability of attack success given the number of signatures
Nandlthe bit shift level - Construct an empirical distribution of statistics
Zfor hypothesis testing - Simulate the behavior of a nonce generator with different entropy parameters
A typical Monte Carlo experiment to evaluate an attack:
1. Generate a random private key d 2. For N signatures: a. Generate a biased nonce k (e.g. with l zero MSBs) b. Calculate (r, s) using ECDSA formulas 3. Collect N signatures 4. Apply lattice attack (LLL/BKZ) to restore d 5. Repeat the experiment M times 6. Estimate the probability of success P_success = (number of successes) / M
In practice, for secp256k1 with a 2-bit offset (zero MSBs), approximately 100–200 signatures are required to successfully recover the key[reference:12]. As the offset level decreases, the required number of signatures increases exponentially.
8. NIST Statistical Tests for Assessing Nonce Quality
The National Institute of Standards and Technology (NIST) has developed a set of 16 statistical tests for assessing the randomness of sequences used in cryptography.[reference:13] These tests are directly applicable to nonce analysis.
| NIST test | What does it check? | Application to nonce |
|---|---|---|
| Frequency (Monobit) | Equal number of 0 and 1 in sequence | Detecting the offset in the least significant bits of a nonce |
| Block Frequency | Uniform distribution in blocks | Checking local offsets in a nonce sequence |
| Runs | Length of runs of identical bits | Detection of deterministic patterns |
| Longest Run of Ones | Maximum length of a series of units | Detecting abnormal concentration of high-order bits |
| Approximate Entropy | Regularity of repeating patterns | Estimating the entropy of a nonce generator |
Test results are expressed as P-value. When , P-value ≥ 0.001 the sequence is considered random with a reliability of 99.9% [reference:14].
The practical result is that if nonces fail at least one of the NIST tests, this is statistical evidence that the generator is vulnerable, making bias-based attacks possible.
9. Real-World Attacks: PlayStation 3, Bitcoin Wallets, and Blockchain
9.1. Attack on PlayStation 3 (2010)
The hacker group fail0overflow recovered a Sony ECDSA private key used to sign PlayStation 3 games. The cause was nonce reuse : Sony used the same value k for all signatures.[reference:15][reference:16] With two signatures with the same value k:
s₁ − s₂ = k⁻¹ (H(m₁) − H(m₂)) (mod n)
From where k = (H(m₁) − H(m₂)) / (s₁ − s₂) mod n, after which the private key is calculated using one of the signatures.
9.2. Attacks on the Bitcoin Blockchain (2019)
Breitner and Heninger conducted a large-scale study of ECDSA signatures in the Bitcoin, Ethereum, and Ripple blockchains [reference:17]. Using lattice algorithms to solve the hidden number problem (HNP), they:
- About 300 Bitcoin private keys have been recovered[reference:18]
- Several classes of nonce offsets were discovered: short nonces, nonces with zero MSBs, and affinely related nonces.
- It took about 40 CPU years of computing time.
9.3. Attack on Upbit (2025)
In 2025, the Upbit exchange suffered an attack that exploited subtle statistical patterns in nonce generation rather than classic reuse.[reference:19] This demonstrates that even seemingly robust generators can contain statistically detectable biases.
10. Conclusion
N.Sh. Kremer’s textbook “Probability Theory and Mathematical Statistics” provides a powerful and systematic framework for ECDSA cryptanalysis. Key findings:
- Modeling the nonce distribution using random variables and limit theorems allows us to formalize the concept of “bias” and assess its impact on security.
- Statistical hypothesis testing (Chapter 9) provides a rigorous criterion for detecting anomalies in nonce generation while controlling for type I and type II errors.
- Correlation and regression analysis reveals linear and polynomial relationships between successive nonces, which directly leads to a system of equations for recovering the private key.
- The Bayesian approach allows one to construct posterior distributions and use MAP estimates for robust key recovery.
- The Monte Carlo method provides an empirical estimate of the probability of an attack’s success given the given parameters.
- NIST tests serve as a practical tool for auditing nonce generators and identifying vulnerabilities before they are exploited.
Real-world attacks—from the PlayStation 3 to modern blockchain—confirm that the statistical methods outlined in Kremer’s textbook are not abstract theory, but a powerful cryptanalytic tool capable of recovering private keys and compromising millions of dollars in cryptocurrency.
Directions for further research for cryptanalysis based on this area
The development of statistical and probabilistic methods of ECDSA cryptanalysis opens up the following promising directions:
- Adaptive statistical attacks with learning. Machine learning methods (Bayesian networks, Gaussian processes) are used to identify complex, nonlinear relationships between nonces that are undetectable by classical correlation methods. Training on large samples of blockchain signatures will allow for the detection of patterns invisible to traditional tests.
- Multi-level Bayesian models with hierarchical biases. Building hierarchical Bayesian models that account for the heterogeneity of nonce generators across wallets, hardware implementations, and library versions. This will allow for estimating posterior key compromise probabilities for entire classes of devices.
- Statistical analysis of nonce time series. Application of time series analysis methods (ARIMA, spectral analysis, wavelet transforms) to nonce sequences to detect periodicities and trends arising from weak sources of entropy (e.g., timers, counters).
- Robust statistical tests for small samples. Developing nonparametric and robust statistical tests capable of detecting biases with a small number of available signatures (N < 50), which is typical for attacks on individual wallets.
- Integrating statistical methods with lattice algorithms. Hybrid approaches use statistical analysis to preliminarily estimate the bias level and select the optimal lattice dimension, while lattice algorithms (LLL, BKZ) perform the final key recovery. This will reduce computational costs and increase the probability of success.
- Statistical Analysis of Quantum and Post-Quantum Nonce Generators. As we move toward post-quantum signature schemes (e.g., based on lattices or hash functions), new classes of nonce biases emerge, requiring adaptation of classical statistical methods.
- Automated blockchain audit systems. Developing distributed monitoring systems that apply NIST statistical tests and consensus criteria to the blockchain signature flow in real time, automatically identifying vulnerable transactions and generating alerts for key holders.
- Probability-theoretic security bounds. Obtaining strict lower and upper bounds on the probability of a successful attack depending on the number of signatures
N, bias levell, and key length. This will allow formal evaluation of the security of specific ECDSA implementations.
These areas combine classical frameworks of probability theory and mathematical statistics (including those from Kremer’s textbook) with modern computational methods, creating the foundation for a new generation of cryptanalysis tools capable of countering the increasingly complex security threats of blockchain systems. This document is based on N.Sh. Kremer’s textbook “Probability Theory and Mathematical Statistics” (2nd ed., Moscow: UNITY-DANA, 2004) and current research in the field of ECDSA cryptanalysis.
