Application of probability theory and the theory of random processes (Gikhman, Skorokhod, Yadrenko) to the problem of recovering the hidden number (nonce) in Bitcoin ECDSA signatures

22.10.2026

Probability theory and the theory of random processes, as presented in the classic textbooks by Gikhman, Skorokhod, and Yadrenko, provide a powerful mathematical framework for ECDSA cryptanalysis. Key areas of application include:

  • Statistical detection of nonce bias : testing of uniformity hypotheses, correlation and spectral analysis.
  • Modeling nonce sequences : Markov chains and hidden Markov models for describing dependencies between  .ki
  • Entropy estimation and information-theoretic bounds : determining the minimum number of signatures required to uniquely recover a key.
  • HNP solution : lattice attacks (LLL/BKZ), the effectiveness of which directly depends on the probabilistic characteristics of the bias.

Practical attacks n

1. Statement of the problem

In the ECDSA (Elliptic Curve Digital Signature Algorithm) cryptosystem used in Bitcoin (secp256k1 curve), a secret nonce is generated for each signature  k . The security of the scheme critically depends on the fact that  k the nonce is chosen uniformly at random from the range  [1, n-1], where  n is the order of the elliptic curve base point. If  k the nonce is unevenly distributed (biased), repeated, or partially leaked through side channels, an attacker can recover the long-term private key  d[reference:0].

Formally, an ECDSA signature for a message with a hash  z is given by the pair  (r, s):

r = (k · G) x  mod n
s = k -1  (z + r · d) mod n

where  G is the group generator,  d is the private key,  k and is the nonce. From the second equation:

k ≡ s -1  (z + r d) (mod n)

If an attacker knows at least some of the bits  k for several signatures, the recovery problem  d reduces to  the Hidden Number Problem (HNP)  , first formulated by Boneh and Venkatesan (1996) [reference:1]. Solving the HNP using probability theory and random processes allows one to recover the key even with very slight nonce bias.

2. Theoretical foundations: probability and random processes in cryptanalysis

2.1. Probabilistic model of nonce generation

According to Gikhman and Skorokhod, a random process is a family of random variables indexed by a parameter (in this case, the signature number). The nonce sequence   can be viewed as a realization of a random process. In an ideal ECDSA   , the nonce sequences are independent, uniformly distributed variables on  . However, in practice, due to implementation errors (weak PRNGs, side-channel leaks, programming errors), the distribution   deviates from uniformity [reference:2].{ki}kiZnki

The primary probabilistic tool here is  statistical hypothesis testing . The null hypothesis  is that nonces are uniformly distributed. Alternatively  , there is a bias (e.g., the most significant bits   have a fixed value or a small range). Statistics based on observed signatures are used for this test.H0H1k

2.2. The Law of Large Numbers and Limit Theorems

The law of large numbers (LLN) states that the sample mean converges to the expected value as the number of observations increases. In the context of ECDSA, this means: the more signatures we collect, the more accurately we can estimate the empirical distribution  k. If the nonce generator has a deterministic bias (for example,  k it always lies in the lower half of the range), then as the number of signatures increases,  m the deviation of the sample statistics from the theoretical value for a uniform distribution becomes statistically significant.

Key idea:  If   there is a bias, then even with unknown values   ​​it is possible to detect this bias by analyzing the joint distribution of pairs   and hashes  using methods of mathematical statistics.kiki(ri, si)zi

2.3 Markov chains and hidden Markov models (HMMs)

If nonces are generated not independently but with dependency (e.g., a linear congruential generator, LCG), the sequence   can be described by a Markov chain. Ryan (2019) showed that information leakage through side channels during the computation of the modular inverse of a nonce can be modeled by a hidden Markov model (HMM) [reference:3]. An HMM allows one to estimate the transition probabilities between states (bit values  ) and reconstruct the most probable sequence, which is directly applicable to the problem of reconstruction   from incomplete data.{ki}kk

Furthermore, in works on ECC cryptanalysis (e.g., the Ha-Moon countermeasure), Markov chains are used to determine the relationship between successive bits of the secret key based on side-channel data [reference:4]. This demonstrates the direct applicability of Markov methods to the analysis of ECDSA implementations.

3. Statistical methods for detecting nonce bias

3.1. Test based on least significant bits (LSB) and most significant bits (MSB)

If  k generated by a weak PRNG, there is often a bias in the least significant or most significant bits. For example, in the LadderLeak attack (2020), the leakage was less than 1 bit—the probability that the most significant bit  k was 0 was greater than 1/2 [reference:5]. To detect such bias, the following statistics are constructed:

T = Σ i=1..m  f(r i , s i , z i )

where  f is some function depending on the bias hypothesis. For   (uniform distribution)   , it has a known limiting distribution (usually normal or χ²). If the observed value   falls within the critical region, the hypothesis   is rejected.H0TTH0

3.2 Using the uniformity of r

Note that  . If   is uniformly distributed on  , then   should be approximately uniform (up to the group mapping). Therefore, a simple statistical test is to check whether the values   ​​in the sample of labels are uniformly distributed. Deviation from uniformity is the first sign of a problem with the generation of  .r = (k · G)x mod nkZnrrik

3.3 Correlation analysis

If nonces have a hidden linear dependence (for example,  ), this can be detected through the correlation between   and   or through the autocorrelation function of the sequence. Methods of spectral analysis of random processes (Fourier transform of the autocovariance function) allow us to identify periodicities and hidden patterns.ki = a · ki-1 + b mod nriri-1

Practical implementation:  The tool  paranoid_crypto (Google) implements a set of tests for detecting nonce bias in ECDSA signatures, including “incorrect range,” “fixed bits,” and “LCG” tests [reference:6]. These tests are directly based on probabilistic criteria.

4. HNP Solution: From Probabilistic Model to Lattice Attack

4.1. HNP setting

Let  i = 1..m the pairs  , hashes   , and the high-order   bits   be 0 (or some known constant). Then we can write:(ri, si)zilki

k i  = s i -1  (z i  + r i  d) mod n, k i  ∈ [0, 2 n-l )

This is a system of linear equations in the unknown  d with constraints on  . The recovery problem   reduces to solving the nearest vector problem (CVP) or shortest vector problem (SVP) in a specially constructed lattice [reference:7].kid

4.2. Probabilistic meaning of restrictions

The restriction   means that   are distributed not on the entire  , but on a subset of small measure. From a probability theory perspective, this is equivalent to knowing the posterior distribution   with a support having low entropy. The smaller the support (i.e., the more bits are known), the fewer signatures   are required to uniquely reconstruct  . Information-theoretic bound: given   known bits per signature and  a -bit modulus, approximately   signatures are required for uniqueness.ki ∈ [0, 2n-l)kiZnkimdlnm ≈ n / l

4.3. Lattice attack (LLL/BKZ)

The LLL (Lenstra–Lenstra–Lovász) algorithm and its generalization, BKZ, allow one to find short vectors in high-dimensional lattices. In the context of HNP, a lattice is constructed containing a vector corresponding to the true  d and “small”  . After basis reduction, this vector becomes one of the shortest and can be extracted.ki

Approximate lattice structure (simplified):

B = [ n 0 … 0 0 ]
[ 0 n … 0 0 ]
[ … ]
[ t 1  t 2  … t m  B/q ]

where  , and   is a scaling factor to account for constraints on  . A detailed construction is given in the works of Howgrave-Graham and Smart, as well as in modern implementations[reference:8][reference:9].ti = ri / si mod nB/qki

4.4 The role of statistics in parameter selection

The effectiveness of a lattice attack depends on the number of signatures  m and the lattice size. Probability theory allows us to estimate the probability of success: if the   signatures have a random bias (e.g., Gaussian), then the probability that all   signatures will fall into the “good” region can be calculated using the probability integral. This allows us to optimally select   the lattice size for a given computational resource.kikim

5. Practical examples and empirical data

5.1. Attack on Bitcoin signatures (Breitner, Heninger, 2019)

In their paper “Biased Nonce Sense,” the authors analyzed signatures in the Bitcoin, Ethereum, and Ripple blockchains and recovered hundreds of private keys. The following types of nonce biases were used:

  • Nonce length 64, 110, 128, 160 bits instead of 256 (incorrect range).
  • Nonce with common 128-bit suffixes.
  • Nonce with common 192-bit prefixes.
  • Repeating nonces (the most trivial case).

The authors used a lattice algorithm to solve HNP and were able to recover the keys after spending about 40 CPU years on Python computations.[reference:10][reference:11] This demonstrates the practical value of a probabilistic approach: even a slight bias, detected statistically, leads to complete key compromise.

5.2. LadderLeak attack (2020)

A vulnerability in the OpenSSL implementation of Montgomery’s ladder allowed one to obtain less than 1 bit of information  k (the probability of guessing the most significant bit was slightly greater than 1/2). However, using an improved Fourier analysis method (Bleichenbacher) and several thousand signatures, it was possible to recover keys for the sect163r1 and NIST P-192 curves [reference:12]. This demonstrates that even a very weak probabilistic signal can be amplified by statistical processing.

5.3. Lattice Attack Records (2024–2025)

Modern works (Gao et al., 2024; Tang and Fan, 2025) achieve record-breaking results: recovery of a 160-bit key with a 1-bit leakage based on approximately 225 signatures  [reference:13], as well as recovery of a 256-bit secp256k1 key with a probability of 2.858% based on two signatures with an average leakage of 249.7 bits per signature [reference:14]. These results were made possible by a combination of probabilistic methods (entropy estimation, filtering) and advanced lattice reduction algorithms (BKZ, sieving).

6. Software tools

For the practical implementation of the described methods, there are open tools:

ToolPurposeLink
reused-r-scannerDetecting Nonce Reuse in Bitcoin Transactions and Recovering Private Keysgithub.com/yilakb/reused-r-scanner
Lattice_exploitHNP solution for ECDSA via LLL, recovering private key from signature setgithub.com/Clasikpaige/Lattice_exploit-
ecdsa-leakage-attackLattice-based nonce leakage attack on ECDSA (LSB/MSB leakage)github.com/JinghuiWW/ecdsa-leakage-attack
paranoid_cryptoStatistical tests for detecting nonce bias in ECDSA signaturesgithub.com/google/paranoid_crypto

Using these tools requires a deep understanding of both probability theory (to correctly interpret the results of statistical tests) and algebra (to construct lattices).

7. Conclusion

Probability theory and the theory of random processes, as presented in the classic textbooks by Gikhman, Skorokhod, and Yadrenko, provide a powerful mathematical framework for ECDSA cryptanalysis. Key areas of application include:

  • Statistical detection of nonce bias : testing of uniformity hypotheses, correlation and spectral analysis.
  • Modeling nonce sequences : Markov chains and hidden Markov models for describing dependencies between  .ki
  • Entropy estimation and information-theoretic bounds : determining the minimum number of signatures required to uniquely recover a key.
  • HNP solution : lattice attacks (LLL/BKZ), the effectiveness of which directly depends on the probabilistic characteristics of the bias.

Practical attacks on Bitcoin signatures (Breitner–Heninger, LadderLeak, Minerva) confirm that even a slight probabilistic deviation in nonce generation leads to complete compromise of the private key. Using the described methods requires a combination of statistical analysis, algebra, and computational geometry.

Directions for further research for cryptanalysis based on this area

  1. Adaptive statistical tests for online blockchain monitoring.  Developing sequential likelihood ratio tests (SPRTs) to detect nonce drift in real time as new transactions appear in the mempool and blocks. This will allow vulnerable keys to be identified before attackers can withdraw funds.
  2. Bayesian methods for nonce distribution estimation.  Using Bayesian inference with prior distributions that reflect typical implementation errors (e.g., bias toward small values, fixed high-order bits). This can improve detection accuracy for small samples.
  3. Hidden Markov models for nonce sequences generated by LCGs and other weak PRNGs.  Construction of HMMs whose parameters are estimated from observed signatures (Baum–Welch method) and subsequent recovery of the most probable sequence   using the Viterbi algorithm.ki
  4. Spectral analysis of autocovariance functions  .ri  Identifying periodicities and hidden linear dependencies in a sequence  r using the fast Fourier transform (FFT). This is especially relevant for attacks on generators based on LFSRs or cellular automata.
  5. Hybrid methods: a combination of statistical and lattice attacks.  Using statistical estimates to pre-filter signatures (selecting “good” instances with the highest probability of falling within a narrow range) before constructing the lattice. This can significantly reduce the lattice size and computational requirements.
  6. Information-theoretic bounds for noisy HNP.  Investigation of fundamental limits on recovery  d in the presence of observational errors (e.g., when known bits  k may be incorrect with some probability). Application of Fano’s inequality and rate-distortion theorems to obtain lower bounds on the required number of signatures.
  7. Analysis of nonce time series as stationary processes.  Testing the stationarity hypothesis (Dickey-Fuller tests, KPSS) and estimating the power spectral density. Non-stationarity (e.g., drift of the mean  k over time) can provide additional points of attack.
  8. Using Monte Carlo methods to estimate the probability of attack success.  Constructing stochastic nonce generation models with various types of biases and estimating the key recovery probability depending on  m, ,  l and the computational budget. This will allow for the optimization of attack strategies.

The document has been prepared based on classical textbooks on probability theory and random processes (Gikhman, Skorokhod, Yadrenko) and modern cryptanalytic works on ECDSA. Textbooks: Gikhman I. I., Skorokhod A. V., Yadrenko M. I. “Probability Theory and Mathematical Statistics”; Gikhman I. I., Skorokhod A. V. “Introduction to the Theory of Random Processes”.