Application of probability theory and mathematical statistics (course by B. A. Sevastyanov) to the calculation of a hidden number (nonce) in the ECDSA signature of a Bitcoin transaction for the purpose of recovering a private key

27.10.2026

B. A. Sevastyanov’s course in probability theory and mathematical statistics provides a complete set of tools necessary for cryptanalytic research of ECDSA. Hypothesis testing allows one to detect nonce bias, maximum likelihood methods and Bayesian inference provide estimates of unknown parameters, Markov chain theory models dependent sequences, and limit theorems substantiate the asymptotic properties of statistics.

When combined with algebraic methods (Hidden Number Problem) and lattice algorithms (LLL, BKZ), these statistical methods form an effective practical tool for recovering Bitcoin private keys. Real-world attacks on blockchains confirm the applicability of this approach.

Thus, the area presented in Sevastyanov’s works is not just a theoretical basis, but a direct guide to action for a cryptanalyst working with ECDSA.

Content

Introduction

The problem of recovering a long-term ECDSA private key from a set of signatures generated using biased or predictable nonce values ​​is one of the central problems in practical cryptocurrency cryptanalysis. The ECDSA algorithm requires the generation of a unique random number. k for each signature. If this number is not uniformly distributed or has statistically detectable patterns, an attacker with a large number of signatures from the blockchain can recover the private key.

B. A. Sevastyanov’s course on probability theory and mathematical statistics [1] provides a powerful and systematic framework for solving this problem. In this paper, we consistently apply probabilistic models, hypothesis testing methods, parameter estimation, Bayesian inference, and the theory of random processes to the analysis of nonce sequences extracted from Bitcoin transactions and to private key recovery.

The purpose of this paper is to demonstrate how the theoretical constructs from Sevastyanov’s course directly translate into practical ECDSA cryptanalysis algorithms. Particular attention is paid to the statistical detection of nonce biases and their use to reduce the problem to a Hidden Number Problem (HNP) and subsequently solve it using lattice analysis methods.

1. Theoretical foundations of ECDSA and the role of nonce

The ECDSA algorithm over the standard secp256k1 curve (used in Bitcoin) is defined by the following parameters: a prime number p, by group order n, generator point G and a hash function HWhen signing a message m with a private key d a random number is generated k∈[1,n–1] (nonce). Then the following are calculated:R=(xR,yR)=kG,r=xRmodn,s=k–1(H(m)+rd)modn.

The signature is a pair (r,s)From the equation for s easy to express k:k=s–1(H(m)+rd)modn.

If the attacker knows k for at least one signature, it immediately calculates d=(sk–H(m))r–1modn. If k is repeated in two signatures (even for different messages), the private key is also trivially recoverable. However, even in the absence of repetitions, but in the presence of a statistical relationship between the values k in different signatures, the key can be recovered.

Classic result: if nonce k has a bias – for example, its most significant bits are always zero, or it is sampled from a smaller range than [1,n–1], — then the task of recovery d comes down to solving a system of linear comparisons with small unknowns. This is the Hidden Number Problem (HNP).

2. Probabilistic nonce model and its biases

From a probability theory perspective, the correct generation of a nonce means that k is a realization of a random variable uniformly distributed over the set {1,2,…,n–1}Let’s denote this as k∼U(1,n–1)The probability density (for continuous approximation) or probability mass (for the discrete case) are equal to 1/(n–1) for each valid value.

Bias means that the true distribution k differs from uniform. In practice, the following types of displacements are encountered:

  • Range reduction: k is selected from the interval [1,2b] With b≪log2⁡nThen they talk about a “short nonce”.
  • Fixed bits:  high or low l bits k are always equal to zero (or some constant). This leads to the fact that k lies in a known subset.
  • Linear dependence:  values ki for different signatures are related by a linear relationship ki=aik0+bimodn with known or unknown coefficients.
  • Markov dependence:  sequence k1,k2,… forms a Markov chain (for example, a generator on a shift register with linear feedback).

In terms of probability theory, bias means that the entropy H(k) less log2⁡nMutual information between k and the observed data (signature) is positive, which creates an information leak about d.

Formally, if k has a distribution PK, then for each signature (ri,si) with a message mi is being performed:P(ki=x)=PK(x),si=x–1(hi+rid)modn.

The task of a cryptanalyst is based on observations (ri,si,hi) restore dThis is a statistical estimation problem under a parametric model, where d — is an unknown parameter, and ki — hidden (latent) variables.

3. Statistical methods for detecting nonce biases

3.1 Testing hypotheses about uniformity

The cryptanalyst’s first step is to check whether the nonce distribution is uniform. This is accomplished using the statistical hypothesis testing framework outlined in Sevastyanov’s course [1, Chapters 6–7].

Let there be a sample of signatures (ri,si,hi), i=1,…,N. Observe directly ki it is impossible, but it is possible to calculate the value that, if true, d would be equal ki. Let us denote by k^i(d)=si–1(hi+rid)modn hypothetical value of nonce given d. If d — the true key, then k^i(d)=ki and distribution k^i(d) corresponds to the true distribution k.

However d unknown. Therefore, indirect tests are used. For example, one can check the uniformity of the distribution of values si or ri. If ki are uniform, then si=ki–1(hi+rid)modn must also be uniform (at a fixed d and random hi,ri). If ki have a bias, this will affect the distribution si.

To check for uniformity, the chi-square (Pearson) test is used. We will split the range of values s on m intervals (bins). Let’s calculate the observed frequencies Oj hits si V j-th bin. Expected frequencies for uniform distribution: Ej=N/m. Criterion statistics:χ2=∑j=1m(Oj–Ej)2Ej.

If the null hypothesis is true (uniformity) χ2 asymptotically distributed as χm–12If the calculated value exceeds the critical value for the given significance level α, the uniformity hypothesis is rejected.

More powerful tests—the NIST SP 800-22 battery [4]—include tests for frequency, runs, block frequency, entropy, and others. They allow one to detect subtle deviations from randomness that may not be visible in a simple chi-square test.

3.2. Estimation of distribution parameters using the maximum likelihood method

If the displacement has a parametric form (e.g., k evenly distributed across [1,2b]), we can estimate the parameter b by the maximum likelihood method [1, Chapter 7].

Likelihood function for one observation (ri,si,hi) given the known d and unknown b has the form:L(b,d)=∏i=1NP(si∣ri,hi,d,b).

Probability P(si∣ri,hi,d,b) is determined through distribution ki: If ki evenly on [1,2b], That si=ki–1(hi+rid)modn also has a known distribution. Maximization L By b And d provides maximum likelihood estimates. In practice, d is unknown, so profile likelihood or joint maximization is used.

The maximum likelihood method is asymptotically efficient and consistent, which allows one to obtain accurate estimates for large N.

3.3 Bayesian approach

The Bayesian approach [1, Chapter 8] allows one to take into account a priori information about the distribution d And k. Posterior distribution d calculated using Bayes’ formula:P(d∣D)∝P(d)∏i=1NP(si∣ri,hi,d),

Where D={(ri,si,hi)}i=1N — data. If the prior distribution P(d) uniformly on the key space, then the posterior distribution is concentrated around the true d when increasing NBayesian estimates (e.g., posterior mean or maximum posterior probability) can be used to recover the key.

The Bayesian approach is particularly useful when the nonce bias has a complex structure, making it difficult to derive an analytical expression for the likelihood. In such cases, Markov Monte Carlo (MCMC) methods are used to sample from the posterior distribution.

3.4 Markov chains and hidden Markov models

If the nonce generator has memory (for example, it is a linear congruential generator or a shift register), the sequence k1,k2,… can be described by a Markov chain [1, Chapter 8]. In this case, to predict the next values k Methods of the theory of random processes are applied.

The Hidden Markov Model (HMM) assumes that the observed signatures (ri,si,hi) are probability functions of hidden states ki, which evolve according to the Markov law. The Baum–Welch algorithm or the Kalman filter (for the continuous case) allow one to estimate the model parameters and reconstruct the sequence ki, and then d.

3.5 Regression analysis

If some of the bits are known ki (for example, due to side-channel leakage), a regression model can be built that relates the observed bits to dThe signature equation is linear in d:siki–hi=rid(modn).

If ki=k~i+ϵi, Where k~i — the known part, and ϵi — a small error, then we obtain a linear regression with errors on the left-hand side. The least squares method or its generalizations allow us to estimate d.

4. Application to private key recovery

4.1 Connection to the Hidden Number Problem

The Hidden Number Problem (HNP) is formulated as follows: given t steam (ai,bi) such that bi=aiα+eimodp, Where α — an unknown number (in our case d), A ei – minor errors. Need to find α.

In ECDSA, after rearranging the signature equation, we obtain:ki=si–1hi+si–1rid(modn).

Let us denote ai=si–1rimodn, bi=si–1himodn. Then:ki=aid+bi(modn).

If ki small (for example, ki<2b With b≪log2⁡n), then this is exactly HNP with small errors ei=kiThe task comes down to searching d, in which all values aid+bimodn lie in a known small interval.

4.2. Bleichenbacher’s statistical approach (Fourier analysis)

Bleichenbacher’s approach is based on the Fourier analysis of the nonce distribution. If the distribution k differs from uniform, then the likelihood function for d has a peak at the true value. For each hypothesis d′ statistics are calculated:S(d′)=∑i=1Nexp⁡(2πi(aid′+bi)modnn).

If d′=d, then the arguments of the exponents correspond to the true ones ki, the distribution of which is shifted, which leads to coherent summation and a large value |S(d)|For the infidels d′ the sum behaves like a random variable with zero mean. This method requires a large number of signatures (N∼106), but is capable of detecting extremely small offsets (less than one bit) [8].

4.3. Lattice attacks and the role of statistics

Lattice attacks (LLL, BKZ) are most effective when there is a large bias (several known bits). The idea is to construct a lattice containing a vector whose components include d and mistakes kiAfter lattice reduction, the short vector yields the desired values.

Statistics plays a key role at the data preparation stage:

  • Determining the limits of ki:  statistical analysis allows us to estimate the upper limit B such that 0<ki<BThis determines the lattice parameters.
  • Selecting the number of signatures N:  from probability theory one can estimate the minimum N, required to successfully recover the key with a given probability. For example, an attack on a 256-bit key with a 4-bit offset requires approximately 100–200 signatures [7].
  • Outlier filtering:  Not all signatures can be used (some ki may be “normal”). Statistical methods allow us to select signatures that best fit the bias model.

In [7], the authors applied lattice attacks to the Bitcoin blockchain and computed hundreds of private keys. They used HNP and LLL reduction, and statistical analysis helped identify transactions with abnormally short nonces.

4.4. Practical algorithm for key recovery

Let’s combine all the stages into a single algorithm:

  1. Data collection.  All signatures are extracted from the blockchain  .(ri,si,hi) for the target public key. The more signatures, the higher the chances.
  2. Primary statistical analysis.  Hypotheses about the uniformity of distribution are tested. si (Chi-square test, NIST tests). If a deviation is detected, this indicates nonce bias.
  3. Estimating the bias parameters.  Using the maximum likelihood method or Bayesian inference, the range of possible values ​​is estimated. ki (For example, ki<2200).
  4. Construction of the HNP lattice.  A lattice basis of dimension is formed. N+1, including ai=si–1ri And bi=si–1hi. Parameter B is selected based on an upper bound for ki.
  5. Lattice reduction.  The LLL algorithm (or BKZ for greater accuracy) is used. The result is a short vector containing the candidate d.
  6. Verification.  Candidate d′ checked on several signatures: calculated ki′=si–1(hi+rid′)modn and it is checked that ki′G=riG (those. x-coordinate coincides with ri). If the check passes, the key is restored.

Instrumental implementation: The package  ecdsa-break [6] implements exactly this approach, including weak signature generation and key recovery via LLL/BKZ.

5. Examples from real practice

The methods described are not purely theoretical. In 2019, Breitner and Heninger [7] analyzed the Bitcoin, Ethereum, and Ripple blockchains and computed hundreds of private keys. They found that many implementations used nonces with a reduced range (e.g., 64-bit or 128-bit instead of 256-bit). The attack took approximately 40 CPU years but yielded real keys.

In 2025, the Upbit exchange hack involved analyzing millions of Solana signatures and identifying subtle statistical patterns in the nonces [9]. Professor Jaewoo Cho noted that the attackers exploited “statistical patterns in the platform’s cryptography,” which is consistent with the approach described in this paper.

These examples confirm that statistical nonce analysis combined with lattice methods is a powerful tool for cryptanalysis of ECDSA in real blockchain systems.

Conclusion

B. A. Sevastyanov’s course in probability theory and mathematical statistics provides a complete set of tools necessary for cryptanalytic research of ECDSA. Hypothesis testing allows one to detect nonce bias, maximum likelihood methods and Bayesian inference provide estimates of unknown parameters, Markov chain theory models dependent sequences, and limit theorems substantiate the asymptotic properties of statistics.

When combined with algebraic methods (Hidden Number Problem) and lattice algorithms (LLL, BKZ), these statistical methods form an effective practical tool for recovering Bitcoin private keys. Real-world attacks on blockchains confirm the applicability of this approach.

Thus, the area presented in Sevastyanov’s works is not just a theoretical basis, but a direct guide to action for a cryptanalyst working with ECDSA.

Directions for further research for cryptanalysis based on this area

The development of statistical methods for ECDSA cryptanalysis can proceed in the following directions:

  • Machine learning for weak nonce detection.  Neural networks and deep learning methods can detect nonlinear and subtle patterns in sequences. ki, which are not detected by classical statistical tests.
  • Nonce time series analysis.  If the nonce generator has a time-dependent state, spectral analysis and autoregressive methods can predict the following values k.
  • Bayesian networks and probabilistic programming.  Construction of complex hierarchical Bayesian models that simultaneously account for multiple sources of information leakage (time, energy consumption, signature structure).
  • Adaptive statistical tests.  Developing sequential criteria that allow for accumulating evidence of nonce bias as new signatures arrive from the blockchain in real time.
  • Quantum Algorithms for HNP.  Investigating the feasibility of using quantum computing to solve the Hidden Number Problem with low bias, which could radically reduce the number of signatures required.
  • Formal verification of nonce generators.  Developing statistical models that can be used to automatically verify the compliance of random number generators with cryptographic standards.

These directions combine classical probability theory with modern computational methods and open new horizons for practical cryptanalysis.


References:
[1] Sevastyanov B. A. Course in probability theory and mathematical statistics. Moscow: Nauka, 1982.
[2] Sevastyanov B. A., Chistyakov V. P., Zubkov A. M. Collection of problems in probability theory. Moscow: Nauka, 1986.
[3] Breitner J., Heninger N. Biased Nonce Sense: Lattice Attacks against Weak ECDSA Signatures in Cryptocurrencies // IACR ePrint 2019/023.
[4] NIST SP 800-22: A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications.
[5] Xu L., Dai Z., Wu B., Lin D. Improved Attacks on (EC)DSA with Nonce Leakage by Lattice Sieving with Predicate // CHES 2023.
[6] ecdsa-break: Recover ECDSA private keys from biased-nonce signatures via LLL/BKZ lattice reduction. PyPI, 2026.
[7] Upbit Hack Stemmed From High-Level Mathematical Exploit, Says Local Expert // Yahoo Tech, 2025.