3 ms·
Here's the new code: beta8.Mod(beta8, curve.P) x3.Sub(x3, beta8) if x3.Sign() == -1 { x3.Add(x3, curve.P) } x3.Mod(x3, curve.P) I
by Thorrez 8y ago
Here's the new code:
beta8.Mod(beta8, curve.P)
x3.Sub(x3, beta8)
if x3.Sign() == -1 {
x3.Add(x3, curve.P)
}
x3.Mod(x3, curve.P)
I don't understand it why it's all necessary. This is shorter and seems to do the exact same thing:
beta8.Mod(beta8, curve.P)
x3.Sub(x3, beta8)
x3.Mod(x3, curve.P)
Also, beta8 is never used after this code. So this should do the same thing as well:
x3.Sub(x3, beta8)
x3.Mod(x3, curve.P)
- lifthrasiir 8y agoI think you are right. Go `big.Mod` should be Euclidean (i.e. `x % y` follows `y`'s sign) so the code is redundant. It doesn't seem to be required to run in constant time (if so we won't have `if` at all), probably the committer wanted a minimal change?