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>
7 files changed
tree: eef6038f9a9b7cf1b6079717ef6f89dc0416bf29
  1. .github/
  2. api/
  3. doc/
  4. lib/
  5. misc/
  6. src/
  7. test/
  8. .gitattributes
  9. .gitignore
  10. AUTHORS
  11. codereview.cfg
  12. CONTRIBUTING.md
  13. CONTRIBUTORS
  14. LICENSE
  15. PATENTS
  16. README.md
  17. SECURITY.md
README.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://golang.org/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.