Application of mathematical statistics (Korshunov D.A., Chernova N.I.) to cryptanalysis of ECDSA in Bitcoin transactions

26.10.2026

The purpose of this document is  to demonstrate how mathematical statistics methods, systematized in the collection of problems and exercises by D.A. Korshunov and N.I. Chernova, can be applied to detect statistical biases in the generation of ECDSA nonce signatures in the Bitcoin blockchain and the subsequent recovery of the private key. This collection of problems and exercises in mathematical statistics by D.A. Korshunov and N.I. Chernova is not just a textbook, but  a fundamental toolkit  for a cryptanalyst working with ECDSA in the Bitcoin blockchain.

Key findings:

  • Statistical anomaly detection methods  (empirical distributions, goodness-of-fit tests, confidence intervals) can detect even slight biases in nonce generation that are not visible through direct observation of signatures.
  • The maximum likelihood method  and  the Bayesian approach  provide a theoretical justification for the transition from a statistical hypothesis to an algebraic key recovery problem.
  • Hypothesis testing  formalizes the decision-making process: “Is there enough data for an attack?”—which is critical when working with real blockchain data, where the number of signatures for a single address may be limited.
  • The practical significance is confirmed by real attacks: the vulnerability of  0.48% of Bitcoin transactions  and the compromise of  1331 private keys  are not a theory, but recorded facts[reference:15].

Thus, mathematical statistics in the hands of a cryptanalyst transforms the “noise” of the blockchain into a structured signal leading to the recovery of the private key.

Source:  Korshunov D.A., Chernova N.I.  Collection of problems and exercises in mathematical statistics . – Novosibirsk: Publishing house of the S.L. Sobolev Institute of Mathematics, Siberian Branch of the Russian Academy of Sciences, 2001. – 119 p.

1. Introduction: Why Mathematical Statistics is Critical to ECDSA Cryptanalysis

The ECDSA (Elliptic Curve Digital Signature Algorithm) is the basis for signing Bitcoin transactions. Each signature is generated using an ephemeral secret number  k  (nonce), which  must  be uniformly random and unique. However, in practice, pseudorandom number generator (PRNG) implementations often make mistakes, such as bit understuffing, modular bias, and reuse.

According to research by Breitner and Heninger (2019), even a small statistical bias in the nonce—less than one bit—allows for the complete recovery of an ECDSA private key given a sufficient number of signatures.[reference:0] In real Bitcoin blockchains, it was found that approximately  0.48% of transactions  contain signatures with vulnerable nonces, leading to the compromise of 1,331 private keys.[reference:1]

This is where mathematical statistics becomes not just a theoretical tool, but a practical weapon for the cryptanalyst. Korshunov and Chernova’s collection provides a systematic framework for:

  • Construction of empirical distributions and assessment of their properties;
  • Tests of statistical hypotheses about uniformity;
  • Interval estimation of parameters;
  • Detecting anomalies in sample data.

2. The structure of the Korshunov-Chernova collection and its relevance to cryptanalysis

The collection contains 461 problems and exercises covering key areas of mathematical statistics[reference:2]. The correspondence between the sections of the collection and the ECDSA cryptanalysis problems is given below.

Section of the collectionContentApplication in ECDSA cryptanalysis
Section I. Empirical DistributionSample, variation series, empirical distribution function[reference:3]Plotting the distribution of  r  and  s values  ​​from Bitcoin signatures; visualizing anomalies
Section II. Methods of constructing estimatesMethod of moments, maximum likelihood, Bayesian estimation[reference:4]Estimating nonce bias parameters; constructing a likelihood function for the hypothesis of the presence of bias
Section III. Properties of EstimatesUnbiasedness, consistency, asymptotic normality[reference:5]Justification of the convergence of statistics with an increase in the number of signatures
Section IV. Comparison of AssessmentsMean-square and asymptotic approaches[reference:6]Choosing the optimal statistics for weak bias detection
Section V. Trust AssessmentConfidence intervals, asymptotic intervals[reference:7]Constructing confidence intervals to estimate the probability of bias; determining the required sample size
Section VI. Testing HypothesesGoodness-of-fit criteria, parametric and nonparametric testsFormal test of hypothesis  H₀ : nonce is uniformly distributed, versus  H₁ : bias is present

3. Mathematical model of ECDSA and statistical formulation of the problem

3.1 ECDSA Signature Equation

The ECDSA signature for a message with hash  z  and private key  d  is computed as:

s = k⁻¹ (z + r·d) mod n

Where:

  • k  — ephemeral secret nonce;
  • r  = x-coordinate of point  k·G  mod n (G is the base point of the curve secp256k1);
  • n  is the order of the group (for secp256k1 n ≈ 2²⁵⁶);
  • z  is the message (transaction) hash.

Let’s rewrite the equation for nonce:

k = s⁻¹ (z + r·d) mod n

If  k  has a statistical bias—for example, the high-order bits are always zero, or the distribution  of k  is not uniform on [0, n−1]—this leaves a trace in the observed values ​​of ( r ,  s ,  z ).

3.2. Reduction to the Hidden Number Problem (HNP)

In the presence of a bias in the nonce, the problem of recovering  d  reduces to HNP: given a set of pairs ( tᵢ ,  aᵢ ), where  tᵢ  =  sᵢ ⁻¹ rᵢ  mod n and  aᵢ  =  sᵢ ⁻¹ zᵢ  mod n, we need to find  d  such that:

|kᵢ − (aᵢ + tᵢ·d) mod n| < B

where  B  = 2 ℓ  is the bias bound (ℓ is the number of “leaked” high-order bits)[reference:8]. The larger ℓ, the fewer signatures are required for the attack. According to experimental data, for a 256-bit curve, with ℓ = 133 (i.e., ~133 high-order bits leaked), the key recovery success is 100%[reference:9].

4. Application of statistical methods from the Korshunov-Chernova collection

4.1. Construction of the empirical distribution of nonce-dependent quantities

Problem from the collection:  § 1–2, problems on constructing a variation series and an empirical distribution function[reference:10].

Application:  We collect all signatures for a given Bitcoin address (or group of addresses presumably using the same wallet). For each signature, we calculate:

vᵢ = (sᵢ⁻¹ · zᵢ) mod n

If nonce  k  has been biased (for example, the most significant  t  bits are set to zero), then the value of  vᵢ  will exhibit an anomalous concentration near certain values. We construct the empirical distribution function  F̂(x)  and compare it with the theoretical uniform distribution function  F(x) = x/n .

Statistics:  We use the Kolmogorov–Smirnov test:

D = supₓ |F̂(x) − F(x)|

For large  D,  the uniformity hypothesis is rejected, indicating the presence of bias.

4.2 Maximum Likelihood Method for Estimating Bias Parameters

Problem from the collection:  § 4, maximum likelihood method[reference:11].

Application:  Suppose nonce  k  has a distribution concentrated on the subset [0, 2m − 1] (that is, the most significant  n−m  bits are zero). Then for each signature:

kᵢ = sᵢ⁻¹ (zᵢ + rᵢ·d) mod n ∈ [0, 2ᵐ−1]

The probability of observing a signature ( rᵢ ,  sᵢ ,  zᵢ ) given  d  is proportional to 1 if the condition is met and 0 if not. The likelihood function is:

L(d) = ∏ᵢ I(0 ≤ sᵢ⁻¹(zᵢ + rᵢ·d) mod n < 2ᵐ)

Maximizing  L(d)  with respect to  d  yields the maximum likelihood estimate. Although direct computation is impossible (due to modular arithmetic), this formulation naturally leads to lattice methods that solve the problem in polynomial time.

4.3 Confidence intervals for the probability of bias

Problem from the collection:  § 14, confidence intervals[reference:12].

Application:  Let  p  be the probability that a nonce falls in a “biased” range (e.g., the most significant bit is 0). For a uniform distribution,  p  = 0.5. We observe  m  signatures of which  X  have the most significant bit 0. Then the sample fraction  p̂ = X/m .

Let’s construct a 95% confidence interval for  p  (normal approximation):

p̂ ± z₀.₀₂₅ · √(p̂(1−p̂)/m)

If the interval does not contain 0.5, the shift is statistically significant. For a cryptanalyst, this is a direct signal to use a lattice attack.

4.4 Statistical Hypothesis Testing: Detecting Nonce Reuse

Problem from the collection:  § 16–17, hypothesis testing, goodness-of-fit criteria.

Usage: K  reuse   is the most severe form of statistical anomaly. With k reuse, two signatures for different messages have the same  r . Then:

s₁ − s₂ = k⁻¹(z₁ − z₂) mod n

k = (z₁ − z₂) · (s₁ − s₂)⁻¹ mod n

d = (s₁·k − z₁) · r⁻¹ mod n

To detect repeated  r,  it is sufficient to construct an empirical distribution of  r values  ​​and apply the χ² test for uniformity. An abnormally high repetition rate is a signal for immediate key extraction.

Research shows that numerous instances of nonce reuse have been found on the Bitcoin blockchain, including four instances of  k  = 1 and 123 instances of  k  = 123456789abcdef[reference:13].

5. Practical algorithm of cryptanalytic attack

Step-by-step private key recovery protocol

  1. Data collection:  Extract all ECDSA signatures for the target Bitcoin address from the blockchain. For each signature, obtain ( r ,  s ,  z ).
  2. Check for duplicate nonce:  Construct the set of values  ​​r . If duplicates are found, immediately restore  k  and  d  using the formulas in §4.4.
  3. Statistical analysis for bias:
    • Calculate  vᵢ  = (sᵢ⁻¹ · zᵢ) mod n.
    • Construct the empirical distribution function  vᵢ .
    • Apply the Kolmogorov–Smirnov test to test for uniformity.
    • Construct a confidence interval for the proportion of “biased” values.
  4. Estimated leakage length ℓ:  If the bias is confirmed, estimate how many of the high-order bits of the nonce are “predictable” (e.g., always zero). This value ℓ determines the difficulty of the lattice attack.
  5. Forming an HNP instance:  Construct a set of equations  kᵢ = aᵢ + tᵢ·d mod n  with the constraint | kᵢ | < 2 ℓ .
  6. HNP Solution:  Apply the LLL (Lenstra–Lenstra–Lovász) algorithm to reduce the lattice basis and find  d . For secp256k1 with ℓ ≥ 128, success is virtually guaranteed [reference:14].
  7. Verification:  Verify the found  d  by signing a test message and comparing it with the public key.

6. Example: Numerical illustration

Let’s say we collected 200 signatures from a single Bitcoin address. Analysis revealed that 140 of them have the most significant bit of  k  equal to zero (with a uniform distribution, we would expect 100).

Step 1: Confidence interval for p.

p̂ = 140/200 = 0.70 SE = √(0.70 0.30 / 200) = √(0.00105) ≈ 0.0324 95% CI: [0.70 − 1.96 0.0324, 0.70 + 1.96 0.0324] = [0.636, 0.764]

The interval  does not contain 0.5  → the bias is confirmed with high confidence.

Step 2: Estimate ℓ.  Since p̂ = 0.70, not 0.5, we can assume that the nonce is generated with the most significant bit truncated (ℓ = 1) plus additional distortion.

Step 3: Forming the lattice.  We construct a matrix of size (m+2) × (m+2):

B = [ n 0 0 … 0 0 ] [ 0 n 0 … 0 0 ] [ … … … … … … ] [ t₁ t₂ t₃ … tₘ B/n ] [ a₁ a₂ a₃ … aₘ 0 ]

where  B  = 2 ℓ . After LLL reduction, we find a short vector containing  d .

Step 4: Key extraction.  The LLL result yields  d  directly. Verification on the test signature confirms its correctness.

7. Conclusion

Conclusion

This collection of problems and exercises in mathematical statistics by D.A. Korshunov and N.I. Chernova is not just a textbook, but  a fundamental tool  for a cryptanalyst working with ECDSA in the Bitcoin blockchain.

Key findings:

  • Statistical anomaly detection methods  (empirical distributions, goodness-of-fit tests, confidence intervals) can detect even slight biases in nonce generation that are not visible through direct observation of signatures.
  • The maximum likelihood method  and  the Bayesian approach  provide a theoretical justification for the transition from a statistical hypothesis to an algebraic key recovery problem.
  • Hypothesis testing  formalizes the decision-making process: “Is there enough data for an attack?”—which is critical when working with real blockchain data, where the number of signatures for a single address may be limited.
  • The practical significance is confirmed by real attacks: the vulnerability of  0.48% of Bitcoin transactions  and the compromise of  1331 private keys  are not a theory, but recorded facts[reference:15].

Thus, mathematical statistics in the hands of a cryptanalyst transforms the “noise” of the blockchain into a structured signal leading to the recovery of the private key.

Directions for further research for cryptanalysis based on this area

Directions for further research

1. Multivariate statistical analysis of nonce space

Development of multivariate analysis methods (MANOVA, factor analysis) for the simultaneous detection of several types of bias: not only in the most significant bits, but also in the least significant ones, as well as in correlations between consecutive nonces within a single transaction.

2. Bayesian methods for assessing the probability of address vulnerability

Building a Bayesian hierarchical model that, based on observed address signatures, estimates the posterior probability that a wallet uses a vulnerable PRNG. This would allow prioritizing attacks on millions of blockchain addresses.

3. Adaptive sequential statistical tests

Using Sequential Probability Ratio Test (SPRT) to dynamically determine when enough signatures are accumulated to launch a lattice attack. This would reduce the amount of computation required to scan the blockchain.

4. Discovery of hidden correlations through spectral analysis

Using the discrete Fourier transform (DFT) to analyze the distribution of nonce-dependent quantities. Bleichenbacher demonstrated that Fourier analysis can detect biases smaller than one bit [reference:16]. Further development of this approach using window transforms and wavelet analysis can reveal irregular, time-dependent biases.

5. Statistical classification of PRNG fingerprints

Creation of a database of statistical fingerprints of known vulnerable PRNG implementations (Android SecureRandom, OpenSSL before certain versions, hardware RNGs with known flaws). A set of address signatures will allow one to determine which generator was used and apply the appropriate attack.

6. Robust statistics for attacks in noisy environments

Developing robust estimates (median, M-estimates, trimmed means) that are robust to outliers and incomplete data. In real blockchains, some signatures may be generated correctly, while others may contain errors; robust methods will allow us to isolate the signal from vulnerable signatures.

7. Integrating statistical tests into automated blockchain scanners

Developing open-source tools that apply consensus criteria, confidence intervals, and sequential tests to a stream of new transactions in real time, automatically flagging addresses with anomalous nonce statistics for further cryptanalysis.

8. Theoretical justification for the minimum sample size

Derivation of analytical formulas relating the leakage length ℓ, the significance level α, the test power 1−β, and the minimum number of signatures  m required for guaranteed key recovery. This will allow the cryptanalyst to estimate the computational costs in advance.


The document was prepared based on: Korshunov D.A., Chernova N.I. “Collection of problems and exercises in mathematical statistics” (Novosibirsk, 2001);
Breitner J., Heninger N. “Biased Nonce Sense: Lattice Attacks against Weak ECDSA Signatures in Cryptocurrencies” (FC 2019);
Osaki S., Kunihiro N. “Bias from Uniform Nonce: Revised Fourier Analysis-Based Attack on ECDSA” (SAC 2024);
as well as open data on the statistics of vulnerable signatures in the Bitcoin blockchain.