Quick Summary
We code in the C programming language a Fourier Analysis approach to solving hidden number problems.

This is part of our series on Practical Hidden Number Problems for Programmers:
*These links are paywalled. (It’s how I’ll afford grad school lol)
Part 1: Quantum Computing and Intro to Hidden Number Problems
Part 2: Increasing Lattice Volume for Improved HNP Attacks
Part 3: Hidden Number Problems with Multiple Noise Holes
Part 4: Hidden Number Problems with Chosen Multipliers
Part 5: Hidden Number Problems with Chosen Errors
Part 6 : Solving Hidden Number Problems Without Lattices
Part 7 (we are here) : Fourier Analysis Attacks on HNPs
As usual, code is available on GitHub.
1.0 Introduction
The 2014 paper GLV/GLS Decomposition, Power Analysis, and Attacks on ECDSA Signatures with Single-Bit Nonce Bias (Aranha et al., 2014)1 demonstrates Bleichenbacher’s approach to solving hidden number problems (HNPs) using fourier analysis.

The lattice approaches explored in Part 1 to Part 5 can’t solve single-bit leaks because the corresponding HNP solultion will not be the closest vector even under the Gaussian Heuristic (Aranha et al., 2014).
1.1 Bleichenbacher’s Approach

Like every other HNP solution, Bleichenbacher’s approach assumes that the attacker has access to an oracle.
Bleichenbacher’s approach involves using a bias calculation and an inverse FFT to identify values near the secret key x, thus recovering the MSBs of x (Mulder et al, 2014)2 in a HNP of the form:
where:
hj - known observation (taken from the ECDSA signature)
cj - known multiplier (also obtained from the ECDSA signature)
x - secret key
kj - secret noise term (nonce)
2.0 Coding Guide
We shall implement Bleichenbacher’s attack on HNPs following algorithm 2 given above.
First, we’ll understand what the bias does. Next, we use the fast fourier transform to speed up the bias calculation.
2.1 Finding Bias Without FFT
The authors introduce bias as a metric for verifying randomness. If we know the number of leaked bits is 1, then the correct secret key should give a bias calculation close to a known target.
The bias is a statistical distinguisher that tells you if your guessed secret key is correct.
In C, using mpfr, the sampled bias can be calculated by:
Next, we write a function to test our magnitude computation:
For a 256-bit prime, where the bracketed number represents the number of fixed MSBs, we observe:
When 0 bits are fixed then the bias should be close to zero. Our results match Table 1:
*bias values may be different depending on your RNG
2.1.1 Making Bias Work With LSBs?
An interesting question arises: what if the LSBs, not the MSBs are fixed, will the bias calculation work?
We make the modification above to test it. We observe that the bias function’s results are close to zero for every value:
No, this bias definition is not applicable to fixed LSBs.
We modify the bias function to work with different fourier coefficients. Here’s the Python code for maximum readability:
Just like before, the biased LSB nonces are close to 1 while the random nonces are close to zero:
2.2 Connecting HNP to Bias
This is how I understood the connection between HNPs and bias calculations:
Say q is small.
We can generate a list of possible noise terms where noise = known observation + multiplier * secretKey.
Running this generated list through the bias calculator yields a number in the range [0 to 1].
The correct secret (or numbers close to the correct secret) show high bias magnitudes.
We use the Fast Fourier Transform as a shortcut to evaluate every possible secret key at once.
First, we write a function to generate a HNP dataset:
Running this function on a 13 bit prime yields this sample dataset:
Writing a bruteforcer to permits us grasp Bleichenbacher’s vision: guesses close to the actual secret key demonstrate rather high bias magnitudes.
The unknown secret key is 858 and we observe super large bias magnitudes around 858:
For contrast, the bias magnitudes observed away from 858 are pretty low:
So the bias magnitude tells us when we’re close to the actual secret key.
2.2.1 Range Reduction’s Effect on Bias
The sort and difference reduction algorithm permits us work with small cj (known multiplier). Each reduction iteration squares the bias. Hence, we can approximated the bias after multiple iterations with:
That’s the information Table 1 holds:
Interpret the table’s results as:
In a nutshell, we can’t run too many sort and difference iterations because the bias would be super small (and appear indistinguishable from the uniform distribution’s bias).
2.3 Using FFT for Fast Bias Calculations
Bruteforce bias search is impractical for large modulos. Instead, we run an n-point FFT on the (observation, multiplier) pair to find the MSB’s we desire.
One may borrow the inplace inverse FFT from (Perry, 2017)3. The FFT is merely a shortcut to finding the bias.
References
Aranha, D.F., Fouque, PA., Gérard, B., Kammerer, JG., Tibouchi, M., Zapalowicz, JC. (2014). GLV/GLS Decomposition, Power Analysis, and Attacks on ECDSA Signatures with Single-Bit Nonce Bias. In: Sarkar, P., Iwata, T. (eds) Advances in Cryptology – ASIACRYPT 2014. ASIACRYPT 2014. Lecture Notes in Computer Science, vol 8873. Springer, Berlin, Heidelberg. DOI.
































