Application of probability theory and mathematical statistics (Kolemaev V.A. et al., 1991) to the cryptanalysis of ECDSA in Bitcoin transactions

25.10.2026

Abstract.  This paper demonstrates how the fundamental sections of the textbook “Probability Theory and Mathematical Statistics” by V. A. Kolemaev, O. V. Staroverov, and V. B. Turundayevsky (Moscow: Vysshaya Shkola, 1991, 399 p.) can be applied to solve a pressing cryptanalysis problem: recovering a long-term private ECDSA key from publicly available Bitcoin blockchain data. It is shown that statistical hypothesis testing criteria, parameter estimation methods, regression and correlation analysis, and elements of random process theory constitute a mathematical apparatus that allows one to detect biases in nonce generation and subsequently recover the secret key using lattice algorithms. The textbook “Probability Theory and Mathematical Statistics” by V. A. Kolemaev, O. V. Staroverov, and V. B. Turundayevsky is not only a classic textbook for economics majors but also a source of powerful mathematical tools that find application in modern cryptanalysis. This work demonstrates that:

  • methods for testing statistical hypotheses (chi-square, goodness-of-fit test) allow us to detect biases in the generation of ECDSA nonce;
  • Parameter estimation methods (maximum likelihood, method of moments) make it possible to quantitatively characterize these biases;
  • Regression and correlation analysis help to identify hidden dependencies between signature components;
  • the theory of random processes and Markov chains is applicable to modeling weak PRNGs;
  • Probability estimates form the basis for determining the required sample size for a successful lattice attack.

Thus, the fundamental probabilistic and statistical knowledge presented in this manual is an essential component of a cryptanalyst’s arsenal working with blockchain data. Its practical application allows one to move from observing public signatures to recovering long-term private keys, demonstrating the true power of mathematical statistics in information security.


1. Introduction

The ECDSA (Elliptic Curve Digital Signature Algorithm) is the basis for signing Bitcoin transactions. Its security critically depends on the quality of the one-time secret number generated. k —  nonce . If k is unevenly distributed, repeats, or has predictable bits, an attacker can recover the long-term private key d[reference:0]. In practice, such vulnerabilities have been encountered repeatedly: from repeated use k in Sony PS3 before the massive leaks in the Bitcoin and Ethereum blockchains[reference:1].

The textbook by Kolemaev, Staroverov, and Turundayevsky provides a systematic presentation of probabilistic and statistical methods that are directly applicable to the analysis of “weak” signatures. Below, we will demonstrate how each of the key sections of this textbook can be used in practice.

2. Theoretical foundations

2.1. Reminder about ECDSA

Let G — the base point of an elliptic curve of order n, d — private key, Q=dG — a public key. To sign a message with a hash z=H(m) a random nonce is generated k∈[1,n–1]. The following are calculated:r=(kG)xmodn,s=k–1(z+rd)modn.

Pair (r,s) is a signature. From this equation it is easy to express k:k=s–1(z+rd)modn.

If the attacker knows at least a few bits k for a sufficient number of signatures, the recovery task d is reduced to  the Hidden Number Problem  (HNP), the solution to which can be efficiently found using lattice algorithms (LLL, BKZ)[reference:2].

2.2. Hidden number and connection with probabilistic models

Formally, HNP is formulated as follows: given a prime module q, unknown number α∈Zq and a set of pairs (ti,MSBℓ(αtimodq)), Where MSBℓ – elders ℓ bit. Need to find α[reference:3]. In the context of ECDSA, the role α the private key plays d, A ti related to ri And si.

If nonce ki has an offset, for example, its most significant bits are with some probability equal to zero, then we get partial information about ki, which allows us to construct an instance of HNP. The key question is  how to detect such a bias statistically . This is where mathematical statistics come into play.

3. Application of sections of the manual by Kolemaev et al.

3.1 Testing statistical hypotheses

The chapter on hypothesis testing examines goodness-of-fit tests (chi-square, Kolmogorov–Smirnov) and parametric tests. For nonce analysis, we can formulate the main hypothesis H0: “observed values k (or their derivatives) are distributed uniformly on [1,n–1]” Alternative hypothesis H1: “the distribution is biased, such as being concentrated in a subset of lower values.”

Let’s apply the chi-square test. We’ll break down the range of possible values. k on m intervals (bins). For each signature, we calculate the estimate k^i (for example, using public ri,si,zi and assuming that d unknown, but it is possible to analyze the joint distribution). However, in practice, it is more common for the analysis not to be done by k, and  the recovered bits k through lattice methods or through known leaks. In the simplest case, if it is known that k was generated with an error (for example, the least significant 32 bits were set to zero), one can test the hypothesis about the uniform distribution of these bits.

Criterion statistics:χ2=∑j=1m(Oj–Ej)2Ej,

Where Oj — the observed number of hits in j-th bin, Ej=N/m — expected under uniform distribution. Under fairness H0 statistics have a distribution χm–12If the calculated value exceeds the critical value, H0 rejected, indicating the presence of bias[reference:4].

Example:  Breitner and Heninger (2019) discovered signatures in the Bitcoin blockchain where the nonce was 64 or 128 bits long instead of the expected 256 [reference:5]. Testing the hypothesis that the high-order bits of the nonce are uniformly distributed revealed these anomalies.

3.2. Estimation of distribution parameters

If the uniformity hypothesis is rejected, it is necessary to estimate the parameters of an alternative distribution. The textbook discusses the methods of moments and maximum likelihood. For a biased nonce, one can assume that k has a distribution that is close to uniform, but with “holes” or a shift. For example, if the random number generator had a defect that caused k always less 2b for some b<256, then the assessment b can be obtained by the maximum likelihood method.

Let the observed sample be k^1,…,k^N (obtained, for example, by solving HNP for multiple signatures or through leaks). The likelihood function for the model “k evenly on [1,2b]» has the form:𝟙L(b)=∏i=1N12b⋅11≤k^i≤2b.

Maximization L(b) gives an assessment b^=⌈log2⁡(maxik^i)⌉This estimate is then used to construct an HNP lattice with a known number of “zero” high-order bits.

3.3 Regression and correlation analysis

The tutorial devotes significant attention to linear regression and correlation analysis. When analyzing ECDSA signatures, one can explore the relationships between various signature components. For example, consider the equation:siki–rid–zi≡0(modn).

If we have a sequence of signatures, we can build a regression si on ri And zi. Although directly ki unknown, it is possible to analyze the regression residuals, which carry information about the deviations ki from expected behavior. Correlation between ri And si may indicate a deterministic relationship (e.g., when reused k).

A more subtle approach: if the nonce is generated using a linear congruential generator (LCG) or other weak PRNG, then the sequence ki may exhibit autocorrelation. The tutorial discusses methods of time series analysis and correlograms. In the context of ECDSA, one can calculate the sample autocorrelation function for a sequence of reconstructed (or estimated) ki and check its significance.

3.4 Markov chains and random processes

The chapter on random processes and Markov chains can be applied to modeling the behavior of a nonce generator. If a nonce is generated by some algorithm that depends on the previous state (e.g., a counter or an LCG), then the sequence ki can be described by a Markov chain. Analysis of the transition probability matrix allows us to predict the following values k or detect periodicity.

In particular, if the PRNG has a short period, then the sequence ki will be periodic with some period T. Detection of this period by spectral analysis or autocorrelation methods makes it possible to predict k for future signatures and therefore restore d.

4. Practical Cryptanalysis Pipeline

4.1. Data collection

It is necessary to extract all transactions containing ECDSA signatures from the Bitcoin blockchain. For each signature, the following are known: (r,s) and the message hash z (calculated from transaction data). This data is publicly available. You can collect it using the blockchain explorer API or run a full Bitcoin Core node.

4.2. Sampling and pre-processing

Let’s filter out signatures where r or s have abnormally small values ​​(which may indicate a short nonce). It is also useful to group signatures by addresses (public keys), since for the same d You can collect statistics on multiple signatures.

4.3 Statistical analysis of nonce

For each group of signatures (related to one public key) we perform:

  1. Estimating the “effective length” of a nonce through distribution analysis rBecause r=(kG)xmodn, small values r can correspond to small k, although this is not a strict dependence.
  2. Testing the hypothesis about the uniform distribution of the least significant bits r (or ratings k, obtained by the lattice method).
  3. Calculating the autocorrelation function for a sequence ri (or ratings ki) in order to detect periodicity.
  4. Using the chi-square test to test the uniformity of the distribution of the most significant bits.

Example Python code to check for uniform distribution of the high-order bits of nonce scores:

import numpy as np
from scipy import stats

def chi2_uniformity_test(values, num_bins=256):
    """
    values: массив целых чисел (оценки nonce)
    num_bins: число бинов для хи-квадрат
    """
    # Приводим к диапазону [0, 1) путём деления на максимум
    normalized = values / (max(values) + 1)
    observed, _ = np.histogram(normalized, bins=num_bins, range=(0, 1))
    expected = len(values) / num_bins
    chi2_stat = np.sum((observed - expected)**2 / expected)
    p_value = 1 - stats.chi2.cdf(chi2_stat, df=num_bins-1)
    return chi2_stat, p_value

# Пример использования:
# estimates = [...]  # список оценок k
# chi2, p = chi2_uniformity_test(estimates)
# if p < 0.01:
#     print("Гипотеза о равномерности отвергается: обнаружено смещение")

4.4. Lattice construction and key recovery

Once the bias has been detected and assessed (e.g. it is known that the senior ℓ nonce bits are zero), one can form a system of HNP equations. For each signature i we have:ki=si–1(zi+rid)modn.

If it is known that 0≤ki<2256–ℓ, then this is equivalent to the fact that ki few. The standard technique (Boneh–Venkatesan) reduces the problem to finding the closest vector in a lattice of dimension O(N), Where N — the number of signatures. The LLL algorithm (or its improved versions, such as BKZ) is used for the solution.

Kolemaev et al.’s textbook doesn’t directly describe the LLL algorithm, but the sections on linear algebra and least squares methods provide the necessary mathematical foundation for understanding lattice methods. Furthermore, the probability estimates provided in the book (for example, the probability of success for a given noise level) allow one to estimate the required number of signatures. N for reliable recovery d.

Important:  Lattice attacks on ECDSA with partial nonce leakage are computationally difficult, but feasible. In Breitner and Heninger’s (2019) work, recovering hundreds of Bitcoin private keys required approximately 40 CPU years of computation [reference:6].

5. Case Study: Nonce-Based Attack

Consider a scenario where a nonce is generated using a vulnerable PRNG that, with a probability of 0.01, produces a value whose least significant 8 bits are zero. This results in the effective entropy k is decreasing. Having collected N=1000 signatures for one public key, we can:

  1. For each signature, calculate the score ki via HNP solution for small subsets (for example, 3-4 signatures).
  2. Test the hypothesis that the least significant 8 bits are zero using the chi-square test.
  3. If the hypothesis is confirmed, construct the full HNP lattice for all 1000 signatures and recover d.

The probability estimates given in the textbook (e.g., Pearson distribution, confidence intervals) allow us to determine whether the observed number of “zero” least significant bits is statistically significant.

6. Conclusion

The textbook “Probability Theory and Mathematical Statistics” by V. A. Kolemaev, O. V. Staroverov, and V. B. Turundayevsky is not only a classic textbook for economics majors but also a source of powerful mathematical tools that find application in modern cryptanalysis. This work demonstrates that:

  • methods for testing statistical hypotheses (chi-square, goodness-of-fit test) allow us to detect biases in the generation of ECDSA nonce;
  • Parameter estimation methods (maximum likelihood, method of moments) make it possible to quantitatively characterize these biases;
  • Regression and correlation analysis help to identify hidden dependencies between signature components;
  • the theory of random processes and Markov chains is applicable to modeling weak PRNGs;
  • Probability estimates form the basis for determining the required sample size for a successful lattice attack.

Thus, the fundamental probabilistic and statistical knowledge presented in this manual is an essential component of a cryptanalyst’s arsenal working with blockchain data. Its practical application allows one to move from observing public signatures to recovering long-term private keys, demonstrating the true power of mathematical statistics in information security.

Directions for further research for cryptanalysis based on this area

  1. Developing adaptive statistical criteria for detecting ultra-weak nonce biases.  Modern attacks require detecting biases of less than one bit. It is necessary to develop sequential probability ratio tests and Bayesian approaches to accumulate evidence of bias as new signatures are acquired.
  2. Application of multivariate statistical analysis to the joint distribution of signature components.  Investigation of joint distributions (r,s,z) using copula functions and multivariate goodness-of-fit tests, it can reveal hidden dependencies that are not detected by univariate tests.
  3. Integrating spectral analysis and wavelet transform methods to detect periodicity in nonce sequences.  If a PRNG has hidden periodicities or correlations, spectral analysis can provide a more sensitive tool than classic autocorrelation.
  4. Assessing the statistical effectiveness of lattice attacks depending on the type and magnitude of bias.  It is necessary to construct probabilistic models that relate the nonce distribution parameters (variance, kurtosis, autocorrelation) to the probability of successful key recovery and the required number of signatures.
  5. Machine learning methods applied to classifying weak signatures.  Models trained using statistical features (histograms, moments, spectral characteristics) to automatically identify addresses with potentially vulnerable nonces.
  6. Investigating the robustness of statistical tests to adversarial manipulation.  In situations where an attacker can influence nonce generation (e.g., via side-channel manipulation), it is necessary to evaluate how statistical tests perform under adaptive attacks.
  7. Extending probabilistic models to other cryptographic primitives.  Methods developed for ECDSA can be adapted to analyze Schnorr signatures (used in Taproot), EdDSA, and other schemes where nonce randomness is also critical.

The document has been prepared on the basis of the textbook: Kolemaev V. A., Staroverov O. V., Turundayevsky V. B. Probability Theory and Mathematical Statistics. – M.: Vysshaya shkola, 1991. – 399 p. – ISBN 5-06-001545-9.