You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that 364272609 - 360086499 = 4186110 = 2 * (0x8000_0000 - 0x7fe0_1001). Performing two conditional subtractions at the conclusion of the algorithm, rather than one, would have given the correct result. (Unfortunately, there are not enough bits in the intermediate result to see that two conditional subtractions are necessary.)
The possible need for two conditional subtractions was noted in Barrett's paper ("Our calculations show that the result x so obtained will always be in the range 0 to 3M - 1") and is also captured in https://eprint.iacr.org/2015/785 ("approximates the result $c = d \bmod n$ by a quasi-reduced number $c + \epsilon n$ where $0 \le \epsilon \le 2$"), but is omitted by the presentation in https://arxiv.org/abs/2103.16400.
If step 1 of the algorithm is "d >> X", I calculate that one subtraction will be sufficient if:
$$\frac{d}{2^L} + \frac{2^X}{p} < 1$$
But, for a 31-bit prime, that increases the size of the multiplication beyond 32 bits.
The text was updated successfully, but these errors were encountered:
I have found that the implementation of Barrett reduction can give incorrect results in some cases. Here is an example:
The output is:
Note that 364272609 - 360086499 = 4186110 = 2 * (0x8000_0000 - 0x7fe0_1001). Performing two conditional subtractions at the conclusion of the algorithm, rather than one, would have given the correct result. (Unfortunately, there are not enough bits in the intermediate result to see that two conditional subtractions are necessary.)
The possible need for two conditional subtractions was noted in Barrett's paper ("Our calculations show that the result x so obtained will always be in the range 0 to 3M - 1") and is also captured in https://eprint.iacr.org/2015/785 ("approximates the result$c = d \bmod n$ by a quasi-reduced number $c + \epsilon n$ where $0 \le \epsilon \le 2$ "), but is omitted by the presentation in https://arxiv.org/abs/2103.16400.
If step 1 of the algorithm is "d >> X", I calculate that one subtraction will be sufficient if:
But, for a 31-bit prime, that increases the size of the multiplication beyond 32 bits.
The text was updated successfully, but these errors were encountered: