]> Cypherpunks repositories - gostls13.git/commit
crypto/elliptic: use a const string for precomputed P256 table
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 28 Jul 2021 18:59:01 +0000 (11:59 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 26 Oct 2021 23:06:10 +0000 (23:06 +0000)
commite5c512520bd0a51d59b39556795a47db888d69b5
treeeef6038f9a9b7cf1b6079717ef6f89dc0416bf29
parent80be4a4f90836a33ab5b3d09c6f529de8ee628ea
crypto/elliptic: use a const string for precomputed P256 table

Const strings can be marked readonly. This is particularly
important for this relatively large table (88kb).
This is a follow-up to CL 315189.

The generation script is a bit awkward. It needs access to crypto/elliptic
internals, but also needs to be package main. Work around this by
exporting those internals with the "tablegen" build tag.

This requires changing the function signature at the Go-asm bridge.
As long as we're here, shrink the point argument type as well;
the net result is three fewer words of params.

Performance impact is probably noise.

name                   old time/op    new time/op    delta
ScalarBaseMult/P256-8    11.4µs ± 2%    11.3µs ± 1%  -1.32%  (p=0.000 n=19+16)
ScalarBaseMult/P224-8     579µs ± 1%     577µs ± 0%  -0.30%  (p=0.024 n=19+20)
ScalarBaseMult/P384-8    2.31ms ± 4%    2.34ms ± 4%  +1.25%  (p=0.033 n=20+20)
ScalarBaseMult/P521-8    1.33ms ± 0%    1.33ms ± 1%    ~     (p=0.173 n=18+17)
ScalarMult/P256-8        42.7µs ± 0%    42.7µs ± 2%    ~     (p=0.989 n=20+20)
ScalarMult/P224-8         579µs ± 0%     579µs ± 0%    ~     (p=0.538 n=19+18)
ScalarMult/P384-8        2.32ms ± 3%    2.34ms ± 5%    ~     (p=0.235 n=19+20)
ScalarMult/P521-8        1.33ms ± 1%    1.34ms ± 2%    ~     (p=0.141 n=17+20)

Change-Id: I3bee56df34ae61ca8829791d2e67e058ecc8ddbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/339591
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
src/crypto/elliptic/export_generate.go [new file with mode: 0644]
src/crypto/elliptic/gen_p256_table.go [new file with mode: 0644]
src/crypto/elliptic/p256_asm.go
src/crypto/elliptic/p256_asm_amd64.s
src/crypto/elliptic/p256_asm_arm64.s
src/crypto/elliptic/p256_asm_table.go
src/crypto/elliptic/p256_asm_table_test.go