1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:54:42 -07:00

internal/edwards25519: skip zero coef in VarTimeDoubleScalarBaseMult

The comment says "Find the first nonzero coefficient.", but actually
this code does nothing.

I fixed it to work correctly.

```
name                            old time/op  new time/op  delta
VarTimeDoubleScalarBaseMult-10  37.5µs ± 0%  36.9µs ± 0%  -1.48%  (p=0.000 n=19+16)
```
This commit is contained in:
ICHINOSE Shogo 2022-10-29 00:02:05 +09:00
parent 537c4354cb
commit a5fa9169d0
No known key found for this signature in database
GPG Key ID: E6BE27F39196B3F3

View File

@ -167,8 +167,8 @@ func (v *Point) VarTimeDoubleScalarBaseMult(a *Scalar, A *Point, b *Scalar) *Poi
// Find the first nonzero coefficient. // Find the first nonzero coefficient.
i := 255 i := 255
for j := i; j >= 0; j-- { for ; i >= 0; i-- {
if aNaf[j] != 0 || bNaf[j] != 0 { if aNaf[i] != 0 || bNaf[i] != 0 {
break break
} }
} }