Using a probabilistic nonce offset table (B.Yu. Mankovsky’s method) to recover the ECDSA private key in Bitcoin transactions

27.10.2026

The probabilistic nonce bias table represents a powerful conceptual bridge between the statistical analysis of random number generator flaws and lattice attacks on ECDSA. It allows one to formalize information about nonce imperfections  k as weights, which are then used to solve a weighted hidden number problem. For a 256-bit curve,  secp256k1 even a bias of 1–2 bits per signature can be sufficient to recover a private key given 100–200 signatures.

However, Bitcoin’s real security is ensured not only by the mathematical strength of ECDSA, but also by engineering practices: deterministic nonce generation, code auditing, and the constant improvement of cryptographic libraries. Therefore, the described method should be viewed as a tool for analyzing historical data and understanding security boundaries, rather than as a practical threat to modern users.

Content

1. Introduction

The Elliptic Curve Digital Signature Algorithm (ECDSA) is the cornerstone of Bitcoin transaction security. Its cryptographic strength is based on the difficulty of the discrete logarithm problem on an elliptic curve  secp256k1. However, like any cryptographic primitive, ECDSA is critically dependent on the quality of the generation of the one-time secret number,  the nonce  (denoted by  k). If the distribution  k deviates from uniformity, even a small bias can be exploited to completely recover the long-term private key.

This paper examines an approach based on constructing  a probabilistic nonce bias table  and applying it to cryptanalysis of ECDSA signatures in the Bitcoin blockchain. The method, associated with B. Yu. Mankovsky, represents a systematized framework for quantifying information leakage due to generator imperfections  kand transforming it into an attack on a private key using lattice algorithms.

Note:  The name “B. Yu.” Mankovsky does not appear in open academic sources in the context of ECDSA cryptanalysis. However, the concept of a probabilistic nonce bias table is a natural generalization of well-known biased nonce attacks  k and the hidden number problem (HNP). A synthesis of these ideas is presented below in a form appropriate to the query.

2. Mathematical foundations of ECDSA and nonce vulnerability

2.1. Secp256k1 Curve Parameters

Bitcoin uses an elliptic curve  secp256k1defined by an equation  y² = x³ + 7 over a finite field  F_p, where  p = 2²⁵⁶ − 2³² − 977. The order of the base point  G is a prime number  n ≈ 1.158 × 10⁷⁷ (a 256-bit prime). The private key  d is a random integer in  [1, n−1]. The public key is  Q = d·G.

2.2. Signature procedure

To sign a message with a hash  h = H(m):

  1. A one-time secret  k ∈ [1, n−1] (nonce) is generated.
  2. The point  R = k·Gand its x-coordinate  are calculated r = R.x mod n.
  3. Calculated  s = k⁻¹ · (h + r·d) mod n.
  4. Signature – pair  (r, s).

The key linear relationship that follows from the signature equation is:

s k ≡ h + r d (mod n) ⟺ k ≡ s⁻¹ h + s⁻¹ r d (mod n)

Denoting  a_i = s_i⁻¹·h_i mod n and  b_i = s_i⁻¹·r_i mod n, we obtain:

k_i ≡ a_i + b_i d (mod n)

If  k_i they were completely known, the reconstruction problem  d would be reduced to solving a system of linear comparisons. In practice  k_i , they are unknown, but information about their  bias  (deviation from a uniform distribution) can be used.

2.3 Sources of nonce bias in real implementations

  • Faulty Random Number Generators (RNGs):  Some hardware and software RNGs may produce output  k with uneven distribution of the high or low bits.
  • Nonce reuse:  If  k it matches for two different signatures, the private key is calculated directly:  d = (s₁·h₂ − s₂·h₁) / (r₁·s₂ − r₂·s₁) mod n.
  • Modular Reduction Bias:  When generating  k a random number in a range greater than  ,  the distribution may become slightly uneven nafter modulo  .n
  • Side-channel leaks:  The execution time of scalar multiplication operations may correlate with bits  k.

Classic work by Breitner and Heninger (2019) showed that even a few-bit offset is sufficient to recover keys from real blockchains[reference:0].

3. Probability Nonce Bias Table: Concept and Construction

3.1 Definition

A nonce offset probability table  is a data structure that, given a family of signatures (e.g., generated by a particular version of a wallet or library), maps observed signature characteristics  (r_i, s_i, h_i) to the probability that the corresponding nonce  k_i lies in a certain subset of the space  {0,1}²⁵⁶.

Formally, let be  K the space of possible nonces, and  Φ: K → {0,1}^m let be some feature function (e.g., the values ​​of the first  m most significant bits). The table specifies the conditional probabilities:

P( Φ(k) = φ | signature observation (r, s, h) )

In practice, tables are constructed for specific types of displacement:

  • MSB offset:L The most significant  bits   are known  k to lie in a narrow range (e.g. all zeros).
  • LSB offset:  the least significant  L bits  k are fixed or have low entropy.
  • Range offset: k  falls within a certain range with high probability  [A, B] ⊂ [1, n−1].

3.2. Table construction: statistical approach

Suppose we have a set of  N signatures generated by the same software. For each signature, we can calculate the “residual” nonce relative to a hypothetical private key  d:

k_i(d) = a_i + b_i·d mod n

If  d is a valid key, then it  k_i(d) will have statistical properties consistent with a faulty generator. If  d is invalid, the distribution  k_i(d) will be close to uniform. This allows us to construct a likelihood function:

L(d) = ∏_{i=1}^{N} P( k_i(d) ∈ S_i )

where  S_i are subsets determined based on a priori knowledge of the bias. The probability table for each  S_i is calibrated empirically or theoretically (e.g., by analyzing the RNG source code).

3.3. Example of a probability table for MSB offset

Consider the case where the most significant  L bits  k are zero with probability  p, and are uniform in the rest of the space with probability  1−p. The table might look like this:

Range kProbability with a defective RNGProbability under uniform RNG
[0, 2^{256−L})p + (1−p)·2^{−L}2^{−L}
[2^{256−L}, 2^{257−L})(1−p)·2^{−L}2^{−L}
………

For real defects, the distribution may be more complex, for example, described by a beta distribution or a mixture of distributions. In this case, the table is constructed numerically.

3.4. Information metric of displacement

The bias can be quantified by the Kullback–Leibler divergence between the observed distribution  P_obs and the uniform one  U:

D_KL(P_obs || U) = ∑_{x} P_obs(x) log₂( P_obs(x) / U(x) )

This value (in bits) indicates how much information  k is leaked on average per signature. Recovering a 256-bit key using lattice methods requires a total leakage of approximately 256 bits (taking into account algorithm-dependent constants). For example, with a 2-bit leakage per signature, approximately 130–150 signatures may be required.

4. Reduction to the Hidden Number Problem

4.1. HNP setting

The hidden number problem (HNP), introduced by Boneh and Venkatesan (1996), is formulated as follows. Given a prime  n, an unknown  d ∈ Z_n, and a set of pairs  (t_i, a_i)such that:

| (d·t_i − a_i) mod n | < n / 2^{L}

where  L is the number of known high-order bits. It is required to find  d.

In the context of ECDSA, the role  t_i is played by  b_i = s_i⁻¹·r_i mod n, and  a_i = s_i⁻¹·h_i mod n. The condition on the offset  k_i is transformed into a condition on  d:

k_i = a_i + b_i d mod n ⇒ (b_i d − (k_i − a_i)) mod n = 0

If it is known that  k_i lies in an interval of length  n / 2^{L}, then  (b_i·d − (−a_i)) mod n is also bounded. This is HNP.

4.2 Probabilistic HNP

In reality, we don’t know exactly which ones  k_i are biased. A probability table allows us to assign a weight to each observation  w_i, reflecting the confidence that  k_i it falls within the “biased” range. The problem then becomes weighted HNP:

minimize ∑ w_i · | (b_i · d − c_i) mod n |²

where  c_i = −a_i mod n. This problem can be solved by lattice reduction methods using the embedding technique.

5. Lattice attack LLL/BKZ: practical implementation

5.1. Construction of the lattice

The standard approach to solving HNP using lattices (the LLL algorithm) is to construct a lattice basis of dimension  (N+1)×(N+1):

B = [ n    0    ...  0    0    0  ]
    [ 0    n    ...  0    0    0  ]
    [ ...  ...  ... ...  ...  ... ]
    [ 0    0    ...  n    0    0  ]
    [ b_1  b_2  ... b_N  1/2^L 0  ]
    [ c_1  c_2  ... c_N  0    K   ]

where  K is a scaling factor chosen for balancing. The short vector in this lattice will contain  d in one of the coordinates.

For weighted HNP (with probability table), each equation is multiplied by the corresponding weight  √w_i, which changes the scale of the lattice rows.

5.2. LLL algorithm and its complexity

The LLL (Lenstra–Lenstra–Lovász) algorithm finds a reduced lattice basis in polynomial time in the dimension. For  N ~ 100–200 256-bit numbers, a practical Python implementation using the  fpylll [or]  library sage runs in seconds to minutes.

The more powerful BKZ (Block Korkine–Zolotarev) algorithm allows for a smaller number of signatures but requires more computation. Modern attacks on ECDSA with a 1–2-bit offset use BKZ with a block size of 20–40.

5.3. Attack pseudocode

def attack_ecdsa_biased(signatures, probability_table):
    """
    signatures: список (r, s, h)
    probability_table: функция, возвращающая вес w_i для каждой подписи
    """
    n = secp256k1_order
    
    # 1. Вычисление a_i, b_i
    a = [ (inverse(s_i, n) * h_i) % n for (r_i, s_i, h_i) in signatures ]
    b = [ (inverse(s_i, n) * r_i) % n for (r_i, s_i, h_i) in signatures ]
    
    # 2. Веса из вероятностной таблицы
    w = [ probability_table(r_i, s_i, h_i) for (r_i, s_i, h_i) in signatures ]
    
    # 3. Построение решётки
    N = len(signatures)
    B = build_lattice(n, a, b, w, L)
    
    # 4. LLL / BKZ редукция
    B_reduced = LLL(B)
    
    # 5. Извлечение кандидатов на d
    for row in B_reduced:
        d_candidate = extract_d(row, n)
        if verify_public_key(d_candidate):
            return d_candidate
    
    return None

6. Application to Bitcoin Transactions: A Step-by-Step Algorithm

6.1 Data collection

All signatures are extracted from the Bitcoin blockchain,  (r, s) along with the corresponding messages  m (or more precisely, their hashes  h = SHA256(SHA256(m))). The public key  Q is known from the script  scriptPubKey (for P2PK) or calculated from the address (for P2PKH).

6.2. Identification of a defective generator

The key step is determining the exact type of displacement present. To do this:

  1. Statistics are collected  k_i(d) for a set of possible values  d ​​(for example, by trying a small range if there is reason to believe that the key is weak).
  2. The distribution of the most significant and least significant bits is analyzed  k_i.
  3. An empirical probability table is constructed: for each possible value of the most significant  L bits, the frequency of occurrence is calculated.

6.3. Using the Probability Table

For each signature, a weight is calculated  w_i based on the table. For example, if the table shows that  P(MSB(k) = 0) = 0.3, and  P(MSB(k) = 1) = 0.7, then signatures for which  k_i(d) (for the current candidate  d) have MSB = 0 are given a higher weight if we are searching for a key corresponding to a faulty generator with a predominance of zeros.

6.4 Iterative Refinement

Since  d is unknown, the weights  w_i depend on  d. In practice, an iterative scheme is used:

  1. The initial guess  d₀ is obtained from solving the HNP without weights (uniform weights).
  2. For  the weights d₀ are calculated  k_i(d₀) and specified according to the table.
  3. The weighted HNP is solved to obtain  d₁.
  4. Steps 2–3 are repeated until convergence.

6.5. Verification

The candidate  d is verified by calculating  Q' = d·G and comparing it with a known public key. If there’s a match, the key is recovered. It can also be verified that all the values  k_i(d) ​​are indeed within the expected ranges with a high probability.

7. Countermeasures and why Bitcoin remains protected

Despite the theoretical possibility of the described attack, modern Bitcoin is resistant to it due to several factors:

  • RFC 6979 (Deterministic Nonces):  Since 2013–2014, most Bitcoin wallets have used deterministic generation  k based on HMAC-SHA256 from the private key and the message hash. This completely eliminates the dependence on the quality of the RNG.[reference:1]
  • Hardware RNG:  Modern hardware wallets use certified random number generators.
  • Ongoing audits:  Large projects (Bitcoin Core, Electrum, Ledger) undergo regular security audits.
  • Complexity of practical implementation:  The attack requires collecting hundreds of signatures from a single key with the same RNG flaw. In practice, keys change frequently, and flaws are rare.

Important:  The described method is a purely theoretical tool for analyzing historical vulnerabilities and for training purposes. Its application to real keys without the owner’s explicit permission is illegal and violates computer security laws.

8. Conclusion

The probabilistic nonce bias table represents a powerful conceptual bridge between the statistical analysis of random number generator flaws and lattice attacks on ECDSA. It allows one to formalize information about nonce imperfections  k as weights, which are then used to solve a weighted hidden number problem. For a 256-bit curve,  secp256k1 even a bias of 1–2 bits per signature can be sufficient to recover a private key given 100–200 signatures.

However, Bitcoin’s real security is ensured not only by the mathematical strength of ECDSA, but also by engineering practices: deterministic nonce generation, code auditing, and the constant improvement of cryptographic libraries. Therefore, the described method should be viewed as a tool for analyzing historical data and understanding security boundaries, rather than as a practical threat to modern users.

9. Directions for further research for cryptanalysis based on this area

  1. Automatic generation of probability tables from code:  Development of methods for static analysis of binaries and source code of cryptographic libraries to identify RNG defects and automatically generate bias tables.
  2. Adaptive Lattice Algorithms:  Investigating the feasibility of using BKZ algorithms with dynamic block size adjustment based on weights derived from a probability table to reduce signature requirements.
  3. Bias Analysis in Other Cryptocurrencies:  Applying a similar approach to ECDSA in Ethereum, Litecoin, and also to Schnorr and EdDSA schemes, where nonce also plays a critical role.
  4. Quantum-resistant aspects:  An investigation of how probability tables can be adapted to analyze post-quantum signature schemes where randomness generation may also be vulnerable.
  5. Machine learning for bias identification:  Using neural networks and clustering methods to identify hidden patterns in a distribution  k_i(d) without a priori knowledge of the defect type.
  6. Information Metric Optimization:  Developing more accurate information leakage measures that take into account correlations between bits  k and lattice structure to predict the minimum required number of signatures.
  7. Attacks on Hardware Wallets:  Investigating the Possibility of Using Probability Tables to Analyze Side-Channel Leaks (Power Consumption, Electromagnetic Radiation) in ECDSA Hardware Implementations.

This document has been prepared for educational and research purposes. The author assumes no liability for any unlawful use of this material.