E. I. Gursky’s collection of problems in probability theory and mathematical statistics, created almost half a century ago, retains its methodological value even in the era of blockchain technologies. Statistical hypothesis testing, parameter estimation methods, regression and correlation analysis—all these tools find direct application in auditing ECDSA nonce generators. They allow one to detect randomness defects, assess their scale, and formulate the cryptanalytic problem in terms that can be solved using lattice methods.
Key takeaway: statistical analysis of the nonce does not directly recover the private key, but it narrows the search space and provides the necessary input for an HNP attack. The combination of classical mathematical statistics (Gursky) and modern algebraic cryptography (LLL, HNP) forms a powerful tandem that should be considered when designing secure cryptographic systems.
A practical recommendation for developers: Regularly conduct statistical testing of the nonce generator (χ², autocorrelation, spectral analysis) in your wallets and HSMs. Detecting bias early on prevents key compromise before an attacker has collected a sufficient sample of signatures.
Content
- Introduction
- Theoretical foundations of ECDSA and the role of nonce
- The structure and content of Gursky’s collection
- Statistical methods applicable to nonce analysis
- Practical Application: From Statistics to Key Recovery
- Step-by-step algorithm for cryptanalytic research
- Conclusion
- Directions for further research for cryptanalysis based on this area
1. Central object
The problem of recovering a Bitcoin wallet’s private key from publicly available blockchain data belongs to a class of cryptanalytic problems whose solution relies not only on the algebraic structure of elliptic curves but also on the statistical properties of the random variables involved in the signature protocol. The central object here is the nonce —a one-time secret number kgenerated for each ECDSA signature and must be uniformly distributed over the interval [1, n-1], where n is the order of the base point of the secp256k1 elliptic curve.
E. I. Gursky’s collection of problems , “Collection of Problems on Probability Theory and Mathematical Statistics” (Minsk: Vysheyshaya Shkola, 1975) , contains over 500 problems covering virtually all areas of classical probability theory and mathematical statistics.[reference:0] Although the collection was created for technical and economic universities, its problems—especially the sections devoted to testing statistical hypotheses, estimating distribution parameters, and regression and correlation analysis—form a powerful methodological foundation for the cryptanalytic study of pseudorandom number generators (PRNGs) used in Bitcoin wallets.
Ethics Disclaimer: All methods and techniques described below are intended solely for academic, educational, and defensive purposes —auditing proprietary cryptographic implementations, analyzing the resilience of random number generators, and improving security. Applying these methods to someone else’s transactions without the owner’s express permission is illegal and punishable by law.
2. Theoretical foundations of ECDSA and the role of nonce
2.1. ECDSA Signature Algorithm
Let be E an elliptic curve over a finite field F_p, G be a base point of order n, d be a private key, Q = dG and be a public key. To sign a message with hash h:
- A random
k ∈ [1, n-1](nonce) is generated. - The point is calculated
R = kG;r = x_R mod n. - Calculated
s = k⁻¹ (h + r·d) mod n. - Signature – pair
(r, s).
From the equation of the signature it follows directly:
k = s⁻¹ (h + r·d) mod n
Thus, knowledge k of at least one signature immediately yields the private key :
d = (s·k − h) · r⁻¹ mod n
2.2 Nonce-Related Vulnerabilities
ECDSA security critically depends on the quality of the nonce. The following classes of vulnerabilities are known:
| Vulnerability type | Mechanism | Consequence |
|---|---|---|
Reuse k | Two messages are signed with the same k, but different h | Immediate recovery d from a system of two equations[reference:1] |
Bias k | The most significant or least significant bits k have a non-zero correlation or are known | Hidden Number Pyramid (HNP) Attack Solvable by Lattice Methods[reference:2] |
Low entropy k | PRNG generates predictable sequences | Statistical analysis allows you to narrow your search space |
| Affine dependence | k₂ = a·k₁ + b for famous a, b | Recovering a key from two signatures[reference:3] |
2.3. Hidden Number Problem (HNP)
If m the most significant bits of each signature are known for a set of signatures k_i, the problem reduces to HNP: find d such that
| (s_i⁻¹ (h_i + r_i·d) mod n) − a_i | < 2^(L−m)
where a_i are the known most significant bits, L and is the bit depth n. Solving HNP is usually accomplished using the LLL-reduced lattice basis (Lenstra–Lenstra–Lovász)[reference:4]. However, detecting the bias itself —that is, determining that k the generated λ are not uniform—is a statistical problem , and this is where the apparatus of Gursky’s collection proves indispensable.
3. The structure and content of Gursky’s collection
E. I. Gursky’s collection (2nd edition, 1975) includes the following main sections, each of which is directly related to nonce cryptanalysis:
- Random events and probabilities. Combinatorics, Bayes’ formula, independence of events.
- Random variables. Discrete and continuous distributions, distribution function, probability density, mathematical expectation, variance.
- Basic distribution laws. Binomial, Poisson, uniform, normal, exponential, gamma, χ², Student’s, Fisher’s.
- Multivariate random variables. Covariance, correlation, conditional distributions.
- Law of large numbers and limit theorems. Central limit theorem, Moivre–Laplace theorem, Chebyshev inequality.
- Mathematical statistics. Sampling method, parameter estimation (method of moments, maximum likelihood method), hypothesis testing (Pearson, Kolmogorov, and Student’s goodness-of-fit tests), analysis of variance, regression, and correlation.
- Random functions. Stationary processes, correlation functions, spectral analysis.
Below, we will detail how each of these sections can be applied to the analysis of nonce sequences extracted from the Bitcoin blockchain.
4. Statistical methods applicable to nonce analysis
4.1 Testing the hypothesis of uniform distribution k
Primary hypothesis H₀: nonces k are uniformly distributed on [1, n-1]. Alternative : the distribution is skewed. Pearson’s χ² goodness-of-fit testH₁ is used for testing .
Procedure:
NA sample of observed valuesk_i(or parts of them, such as the most significant bits) extracted from the signatures is collected .- The interval
[1, n-1]is divided intomequal subintervals. - The observed frequencies
O_jof occurrence in each subinterval are calculated. - Expected frequencies
E_j = N/m. - Criterion statistics:
χ² = Σ (O_j − E_j)² / E_j. - Comparison with critical value
χ²_{α, m−1}at significance levelα.
In Gursky’s collection, problems involving the χ² test are presented in the chapter “Testing Statistical Hypotheses” (problems #18.001–18.120 and beyond). A typical problem is formulated as follows: “Given a sample size, n test the hypothesis of a uniform distribution of the general population at a significance level of 0.05.” This methodology is directly applicable to nonce analysis.
4.2. Testing the normality of residual distribution
If the deterministic component (e.g., a linear regression prediction) is subtracted from the nonce sequence, the residuals should be normally distributed with zero mean if the PRNG is free of systematic defects. The following are used for verification:
- The Kolmogorov–Smirnov test is a comparison of the empirical distribution function with the theoretical normal one.
- The Shapiro–Wilk test is more powerful for small samples.
- Asymmetry and kurtosis are sample moments of the third and fourth order.
In Gursky’s collection, the section “Elements of Mathematical Statistics” is devoted to these issues, where problems on constructing confidence intervals for the parameters of a normal distribution and testing hypotheses about the type of distribution are considered.
4.3 Autocorrelation analysis of a nonce sequence
If the PRNG has memory (e.g., a linear congruential generator or a Mersenne vortex with improper initialization), successive values k_i may be correlated. The autocorrelation function (ACF) of a sample sequence is:
r_τ = (1/(N−τ)) Σ_{i=1}^{N−τ} (k_i − k̄)(k_{i+τ} − k̄) / σ²
allows one to detect periodicities and dependencies. In Gursky’s collection, problems on correlation analysis are presented in the chapter “Elements of Correlation Theory” (problems nos. 19.001–19.080). This chapter discusses calculating the sample correlation coefficient, testing its significance, and constructing confidence intervals.
4.4 Regression analysis of dependence k on known parameters
If a nonce is generated deterministically based on some input data (e.g. message hash, timestamp, counter), a regression model can be built:
k_i = β₀ + β₁·h_i + β₂·t_i + ε_i
where h_i is the message hash, t_i is the timestamp, and ε_i is the random error. The ordinary least squares (OLS) method, discussed in detail in Gursky’s collection (chapter “Elements of Regression Analysis”), allows one to estimate the coefficients β_j and test their significance using tStudent’s t-test and FFisher’s t-test.
Practical value. If the regression model explains a significant proportion of the variance k (high R²), this means that the nonces are predictable , and the search space for the private key is sharply reduced. In the extreme case where ε_i ≈ 0, the values k_i are calculated exactly, and the private key is recovered directly.
4.5. Maximum Likelihood Method for Estimating Nonce Distribution Parameters
If there is reason to believe that k the distribution is not uniform, but follows some parametric law (e.g., normal, exponential, or gamma), the maximum likelihood method (MLM) allows one to estimate the parameters of this distribution. Gursky’s collection of articles on MLM devotes a separate section to the chapter on statistical estimation.
Example: If nonces are normally distributed N(μ, σ²) with mean μ ≠ (n−1)/2, this indicates systematic bias. The MMP estimates:
μ̂ = (1/N) Σ k_i, σ̂² = (1/N) Σ (k_i − μ̂)²
The hypothesis is tested H₀: μ = (n−1)/2 against H₁: μ ≠ (n−1)/2 using tthe Student’s t-test. If the hypothesis is rejected, the bias is confirmed.
4.6. Nonce Time Series Analysis
A sequence of nonces, ordered by the time transactions appeared in the blockchain, forms a time series. Gursky’s book contains a chapter, “Random Functions,” which discusses stationary random processes, correlation functions, and spectral densities. The application of these methods allows:
- Detect periodic components in a nonce sequence (spectral analysis).
- Check the stationarity of the series (test of series, test of ascending and descending trends).
- Build an autoregressive moving average (ARMA) model to predict the next values
k.
4.7. Bayesian approach to estimating the probability of key recovery
Bayes’s formula, which is dedicated to a separate section in Gursky’s collection, allows one to recalculate the posterior probability of a hypothesis about a value k as new data becomes available. If the prior distribution k is known (for example, from statistical analysis), then for each new signature one can calculate:
P(k | r, s, h) ∝ P(r, s, h | k) · P(k)
This makes it possible to rank candidates k in descending likelihood and sequentially check the most likely values, which dramatically reduces the computational complexity compared to exhaustive search.
5. Practical Application: From Statistics to Key Recovery
5.1. Attack Scenario
Let’s consider a realistic scenario, reproduced for educational purposes. Assume that a certain wallet uses a PRNG with a known flaw: the least significant m bits of the nonce are always zero (or have low entropy). This means that
k_i = 2^m · u_i, где u_i ∈ [1, 2^(256−m) − 1]
Then, k_i are distributed not over the entire interval [1, n-1], but over a subset that is a multiple of 2^m. The χ² statistical test for uniformity will easily detect this bias: the frequencies of occurrence in subintervals that are not multiples of 2^mwill be zero.
5.2 Step-by-step methodology
Step 1: Data Collection
All ECDSA signatures for a given public key are extracted from the blockchain Q. Each signature is a triple (r, s, h), where h is the hash of the signed message.
Step 2. Primary statistical processing
The sampling distribution of the values of r and is calculated s. The hypothesis of the uniformity of r and is tested s (they should be uniform if k they are uniform). Histograms are constructed, and sample moments are calculated.
Step 3. Testing the hypothesis of uniformity k
Since k α is not directly observable, an indirect test is used. If k α is biased, then α r = x(kG) mod n will also be biased, although nonlinearly related to α k. To detect bias, the χ² test is applied to the values of α r.
Important: Bias k does not always manifest itself as bias r due to nonlinearity in the mapping k ↦ x(kG). Therefore, more sophisticated methods are needed for reliable detection, such as joint distribution analysis (r, s) or the use of lattice methods for reconstruction, k followed by verification of their statistical properties.
Step 4. Estimating the entropy of nonce
The sample Shannon entropy is calculated for the observed values k (or their approximations). If the entropy is significantly lower log₂(n), this indicates low randomness. In Gursky’s collection, problems on entropy and information are contained in the section “Elements of Information Theory.”
Step 5. Regression analysis and construction of a predictive model
If even approximate values can be obtained k_i (for example, through a lattice attack with a small number of known bits), a regression model is constructed based k on the available features: transaction index, timestamp, and hash. Significant regression coefficients indicate a deterministic component in nonce generation.
Step 6. HNP formulation and lattice solution
Based on statistical inferences about bias, the HNP problem is formulated: for each i , it is known that k_i = a_i + e_i, where a_i is a known part (e.g., the most significant bits), |e_i| < 2^b. A lattice of dimensions is constructed N+1 and the LLL algorithm is applied to find d.
Step 7. Verifying the found key
The found private key d is verified: for each signature, is recovered k_i = s_i⁻¹ (h_i + r_i·d) mod n, and it is verified that x(k_i G) mod n = r_i. If all checks are passed, the key is valid.
5.3. Example: Key recovery with known least significant bits
Suppose that it is known from statistical analysis that k_i ≡ 0 mod 2^8 for all i. Then k_i = 256 · u_i. The signature equation is:
256 · u_i = s_i⁻¹ (h_i + r_i·d) mod n
Multiplying by s_i:
256 · u_i · s_i − h_i = r_i · d mod n
This is a linear comparison with respect to d and u_i. Given two signatures with different values, h_i the system is solved with respect to d elimination u_i. However, in practice u_i , are unknown, and either more signatures or a lattice method is required.
6. Step-by-step algorithm of cryptanalytic research
Below is a generalized algorithm that combines statistical methods from Gursky’s collection with cryptanalytic techniques.
АЛГОРИТМ: Статистический криптоанализ nonce в ECDSA
─────────────────────────────────────────────────────────────
ВХОД: Множество подписей S = {(r_i, s_i, h_i)}_{i=1}^N
Публичный ключ Q
ВЫХОД: Приватный ключ d (или доказательство невозможности)
1. ПРЕДВАРИТЕЛЬНАЯ ОБРАБОТКА
1.1. Нормализовать все значения по модулю n.
1.2. Вычислить z_i = s_i⁻¹ · h_i mod n, w_i = s_i⁻¹ · r_i mod n.
1.3. Составить уравнение: k_i = z_i + w_i · d mod n.
2. СТАТИСТИЧЕСКИЙ АНАЛИЗ (методы Гурского)
2.1. Проверить равномерность r_i с помощью χ²-критерия.
2.2. Проверить автокорреляцию последовательности r_i.
2.3. Построить гистограмму распределения младших битов r_i.
2.4. Если обнаружено смещение — перейти к шагу 3.
Иначе — увеличить выборку или перейти к шагу 5.
3. ОЦЕНКА ПАРАМЕТРОВ СМЕЩЕНИЯ
3.1. Определить, какие биты k_i имеют низкую энтропию.
3.2. Оценить вероятность каждого значения смещённых битов.
3.3. Построить регрессионную модель k_i = f(признаки) + ε_i.
3.4. Оценить остаточную дисперсию σ²_ε.
4. ФОРМУЛИРОВКА HNP
4.1. Для каждого i записать: k_i = a_i + e_i,
где a_i — известная (смещённая) часть,
|e_i| < 2^b — неизвестная часть.
4.2. Подставить в уравнение подписи:
a_i + e_i = z_i + w_i · d mod n.
4.3. Перегруппировать:
e_i − w_i · d = z_i − a_i mod n.
5. РЕШЕНИЕ РЕШЁТКОЙ (LLL)
5.1. Построить решётку размерности (N+1) с базисом:
[n, 0, …, 0, 0]
[0, n, …, 0, 0] …
[w_1, w_2, …, w_N, 1/2^b]
5.2 Apply LLL basis reduction. 5.3 Find the short vector corresponding to e_i and d. 6. VERIFICATION 6.1 For the found d, calculate k_i = z_i + w_i · d mod n. 6.2 Check: x(k_i · G) mod n = r_i for all i. 6.3 If the check is passed, return d. Otherwise, return to step 3 with different parameters. 7. OUTPUT
7. Conclusion
E. I. Gursky’s collection of problems in probability theory and mathematical statistics, created almost half a century ago, retains its methodological value even in the era of blockchain technologies. Statistical hypothesis testing, parameter estimation methods, regression and correlation analysis—all these tools find direct application in auditing ECDSA nonce generators. They allow one to detect randomness defects, assess their scale, and formulate the cryptanalytic problem in terms that can be solved using lattice methods.
Key takeaway: statistical analysis of the nonce does not directly recover the private key, but it narrows the search space and provides the necessary input for an HNP attack. The combination of classical mathematical statistics (Gursky) and modern algebraic cryptography (LLL, HNP) forms a powerful tandem that should be considered when designing secure cryptographic systems.
A practical recommendation for developers: Regularly conduct statistical testing of the nonce generator (χ², autocorrelation, spectral analysis) in your wallets and HSMs. Detecting bias early on prevents key compromise before an attacker has collected a sufficient sample of signatures.
8. Directions for further research for cryptanalysis based on this area
The integration of the apparatus of mathematical statistics (in the spirit of Gursky’s collection) with modern methods of cryptanalysis opens up the following promising directions:
- Developing adaptive statistical tests for online nonce monitoring. Creating sequential probability ratio tests (SPRTs) that enable real-time detection of generation anomalies
kas new transactions enter the mempool. - Bayesian methods for posterior distribution estimation
k. Construction of hierarchical Bayesian models in which the prior distributionkis refined as data accumulates, followed by sampling (MCMC) to obtain confidence intervals for the valued. - Application of multivariate statistical analysis methods. Using cluster analysis (k-means, hierarchical clustering) to group signatures by similar nonce patterns, which can identify groups of transactions signed by the same faulty PRNG.
- Spectral analysis of nonce sequences. Using fast Fourier transform (FFT) and wavelet analysis to detect hidden periodicities in the sequence
k_i, which may be related to the processor clock rate or system timer. - Hybrid statistical-lattice algorithms. Developing methods that directly use statistical estimates of bias parameters (obtained, for example, by maximum likelihood) to construct an HNP lattice with adaptive weights, which increases the probability of successful key recovery with small samples.
- Analysis of nonlinear dependencies between nonce and transaction parameters. Application of nonparametric regression (kernel smoothing, splines) and machine learning methods (random forest, gradient boosting) to identify complex nonlinear relationships between
kand PRNG input data. - A study of nonce entropy characteristics in various wallet implementations. A systematic comparison of the Shannon entropy, Rényi entropy, and min-entropy for nonces generated by hardware and software wallets (Bitcoin Core, Electrum, Ledger, Trezor) to identify the least secure implementations.
- Developing statistical criteria for detecting affine relationships between nonces. Creating tests sensitive to relationships of the form
k₂ = a·k₁ + b mod n, which can arise when using linear congruential generators or when compromised through side-channels. - Application of extreme value theory. Analysis of the distribution of maxima and minima of nonce sequences to identify deviations from uniformity in the tails of the distribution, which is especially important for detecting rare but critical PRNG defects.
- Cross-correlation analysis of nonces from different users. Testing the hypothesis of independence of nonce sequences generated by different wallets in order to detect systemic flaws inherent to specific libraries or hardware platforms.
Each of these areas is based on fundamental statistical concepts systematically presented in Gursky’s collection and can be implemented as practical tools for auditing the security of blockchain transactions.
This document is prepared for educational purposes. All methods described are intended for auditing your own cryptographic systems and improving their security.
This material is distributed in accordance with the principles of responsible disclosure.
