Commit graph

200 commits

Author SHA1 Message Date
DataHoarder e2f706cb5c
Added PointTablePrecompute / UnsafeVarTimeScalarMultPrecomputed 2024-04-05 10:51:08 +02:00
DataHoarder a67b1e9d0a
Faster UnsafeVarTimeScalarBaseMult 2024-04-05 10:16:06 +02:00
DataHoarder b67b282d40
Added unsafe VarTime methods for ScalarMult, ScalarBaseMult 2024-04-05 09:03:06 +02:00
DataHoarder f0596f127a
Replace package name with git.gammaspectra.live/P2Pool/edwards25519 2024-04-05 09:03:06 +02:00
Daniel Bourdrez a7dfd8e4e6
extra: rectify pow2k function comment (#35) 2023-12-10 14:26:02 -05:00
Filippo Valsorda 325f520de7 all: update Go version 2023-12-10 20:13:24 +01:00
Dmitri Shuralyov c0501e42ed all: drop old +build lines
Running 'go fix' on the cmd+std packages handled much of this change.

Also update code generators to use only the new go:build lines,
not the old +build ones.

For golang/go#41184.
For golang/go#60268.

Change-Id: If35532abe3012e7357b02c79d5992ff5ac37ca23
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/536237
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-10 20:10:48 +01:00
Jes Cok 23384ff85b all: use the indefinite article an in comments
This is a follow up of CL 530120.

Change-Id: Ifa0bd1c3bb9bb1202568eaae27500bcea376f56b
GitHub-Last-Rev: b4154fa1fc205a6a1af050ab49a4738f73b3c32a
GitHub-Pull-Request: golang/go#63228
Reviewed-on: https://go-review.googlesource.com/c/go/+/531136
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-12-10 20:10:48 +01:00
Bryan C. Mills 16197b4051 crypto/internal/edwards25519: shorten quick.Check tests in short mode
The edwards25519 tests can be quite slow on platforms without a
well-optimized implementation, especially if the race detector is also
enabled. Since these tests aren't checking for specific inputs anyway,
the extra coverage of a more aggressive quick.Config does not seem
worth wasting extra time on slow CI builders and TryBots.

For #60109.

Change-Id: I530e75a0b76725585df5a2f5ded6705ab1b9da51
Reviewed-on: https://go-review.googlesource.com/c/go/+/522715
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
2023-12-10 20:10:48 +01:00
cui fliter 6387a56aa6 all: fix misuses of "a" vs "an"
Fixes the misuse of "a" vs "an", according to English grammatical
expectations and using https://www.a-or-an.com/

Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47
Reviewed-on: https://go-review.googlesource.com/c/go/+/480536
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-12-10 20:10:48 +01:00
Jorropo c901e5ec3c crypto/internal/edwards25519: reduce Point size by reordering fields
Updates #58483

Tested on Linux amd64:
  type Element struct {
    l0, l1, l2, l3, l4 uint64
  }

  type PointAfter struct {
    x, y, z, t Element
    _          incomparable
  }

  type PointBefore struct {
    _          incomparable
    x, y, z, t Element
  }

  type incomparable [0]func()

  func main() {
    fmt.Println(unsafe.Sizeof(PointAfter{})) // 168
    fmt.Println(unsafe.Sizeof(PointBefore{})) // 160
  }

Change-Id: I6c4fcb586bbf3febf62b6e54608496ff81685e43
Reviewed-on: https://go-review.googlesource.com/c/go/+/467616
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
2023-12-10 20:10:48 +01:00
cui fliter daffb31912 all: fix problematic comments
Change-Id: If092ae7c72b66f172ae32fa6c7294a7ac250362e
Reviewed-on: https://go-review.googlesource.com/c/go/+/463995
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2023-12-10 20:10:48 +01:00
Michael Pratt 5caf132ffa all: give nested modules fully-qualified names
The two crypto modules are both named "asm". If both are included in a
single go.work (e.g., from `go work use -r .` in the repo), builds break
from "module asm appears multiple times in workspace".

Give these modules fully-qualified names to avoid conflicts. While we
are here, also expand the name of two other testdata modules. Those
modules don't currently conflict, but they have vague names at risk of
future conflicts.

Fixes golang/go#57769.

Change-Id: I2bd8a505051e92348d49560ec698ed921f2c81be
Reviewed-on: https://go-review.googlesource.com/c/go/+/461896
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2023-12-10 20:10:48 +01:00
Filippo Valsorda 4bafd0bab4 edwards25519: gofmt scalar_fiat.go 2023-12-10 20:04:13 +01:00
Dan Kortschak 40637db7b9 all: fix comment typos
Change-Id: Ic16824482142d4de4d0b949459e36505ee944ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/448175
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dan Kortschak <dan@kortschak.io>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-12-10 20:00:32 +01:00
Cuong Manh Le f25ca2c5f0 edwards25519: drop Go builders noopt check 2023-12-10 20:00:03 +01:00
Steve Thomas 8c58ed0e35
extra: fix Scalar.Invert comment (#31) 2022-08-03 12:59:37 -04:00
Filippo Valsorda 5c60041eec all: stop testing on unsupported Go 1.16 2022-07-31 17:08:28 -04:00
Filippo Valsorda 63e0935134 scalar: replace wide reduction with limbed operations 2022-07-31 17:08:28 -04:00
Filippo Valsorda 467a92bcfd scalar: document and update fiat generation code 2022-07-31 17:08:28 -04:00
Filippo Valsorda 50a0a9e22d scalar: clean up fiat wrapper 2022-07-31 17:08:28 -04:00
Filippo Valsorda 755954a498 scalar: fix aliasing of MultiplyAdd addend and receiver 2022-07-31 17:08:28 -04:00
George Tankersley 589b96254b scalar: update fiat code to v0.0.12-f4c7f3717364cf39b716170bf39f81b78acf544e 2022-07-31 17:08:28 -04:00
George Tankersley 8b9f5baf25 scalar: fix the loop in notZeroScalar.Generate 2022-07-31 17:08:28 -04:00
George Tankersley e69bd0a524 scalar: remove the Christmas tree 2022-07-31 17:08:28 -04:00
George Tankersley 306e451b8b scalar: replace the Christmas tree with a fiat-crypto generated scalar field 2022-07-31 17:08:28 -04:00
George Tankersley 51f382caa1 scalar: add benchmarks for scalar operations 2022-07-31 17:08:28 -04:00
Filippo Valsorda 37b8fb5359
extra: explain the absence of SetMontgomeryBytes (#30) 2022-07-26 10:28:42 -04:00
Filippo Valsorda 383e08737b edwards25519: sync with upstream
Minor doc, names, go:build directive changes.
2022-05-25 01:39:14 +02:00
Filippo Valsorda 7873dc1956 edwards25519: extend benchmarks 2022-05-24 17:21:59 +02:00
Ludi Rehak 36a90d6b20 all: rename type *testing.B variable to 'b'
Reserve 't' for type *testing.T variables.

Change-Id: I037328df59d3af1aa28714f9efe15695b6fd62a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/400826
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-24 17:21:59 +02:00
Filippo Valsorda 17a0e597a6 field: fix heap escape in SqrtRatio
We were reusing a named return as a function variable name, which was
causing it to escape to the heap, and cause an allocation in Ed25519
verification.
2022-01-05 09:33:10 -05:00
Daniel Bourdrez 18ef51f6b0
field: fix typo in SetBytes docs 2021-07-27 20:35:29 +02:00
Filippo Valsorda 390f27c3be field: add Element.SetWideBytes
Fixes #17
2021-07-21 19:47:08 +02:00
Filippo Valsorda 3b510035a8 README: update relationship with upstream 2021-07-21 19:45:29 +02:00
Filippo Valsorda edec5b9454 field: fix SqrtRatio when arguments and receiver alias
Fixes #19
2021-07-21 19:44:38 +02:00
Filippo Valsorda 26ce6fc341 edwards25519: expand the SetUniformBytes docs 2021-06-07 01:08:54 +02:00
Filippo Valsorda ed0a5aec82 extra: add ExtendedCoordinates and SetExtendedCoordinates 2021-06-05 01:17:53 +02:00
Filippo Valsorda c1c1311e51 edwards25519: make Scalar and field.Element setters return errors
Accepting a short value from an attacker and passing it to a setter is
an easy way to end up with a panic. Return errors instead.
2021-06-04 16:57:44 +02:00
Filippo Valsorda 0307d66a90 extra: make Scalar.Invert(0) return 0
We don't want panics scattered around.
2021-06-04 16:55:16 +02:00
Filippo Valsorda dd0c73fa20 all: sync with landed standard library upstream 2021-05-26 18:09:02 +02:00
Filippo Valsorda 8e7780424d asm: upgrade avo and regenerate fe_amd64.s
Fixes #16
2021-04-19 00:45:35 -04:00
Filippo Valsorda c6be47d677 edwards25519: update TestScalarSetBytesWithClamping
With jedisct1/libsodium.js#256 fixed, use non-Montgomery representation.
2021-04-05 23:14:53 +02:00
Filippo Valsorda c882e8e8ab edwards25519: rewrite amd64 assembly with avo
Mapping almost 1:1 from generic Go lines to Avo lines.

Again a little faster, as a treat. (Probably due to better pipelining of
the reduction chains.)

name                    old time/op  new time/op  delta
Add-4                   7.87ns ± 2%  7.93ns ± 1%    ~     (p=0.065 n=10+9)
Mul-4                   18.9ns ± 2%  18.4ns ± 1%  -2.20%  (p=0.000 n=10+9)
Mul32-4                 7.22ns ± 1%  7.19ns ± 1%    ~     (p=0.128 n=10+9)
BasepointMul-4          21.4µs ± 1%  21.1µs ± 1%  -1.54%  (p=0.000 n=10+10)
ScalarMul-4             67.3µs ± 2%  67.2µs ± 1%    ~     (p=0.579 n=10+10)
VartimeDoubleBaseMul-4  62.5µs ± 2%  62.9µs ± 1%    ~     (p=0.436 n=10+10)
MultiscalarMulSize8-4    246µs ± 0%   246µs ± 1%    ~     (p=0.631 n=10+10)
2021-04-05 15:05:07 -04:00
Filippo Valsorda 8eb02eb997 edwards25519: refactor feMulGeneric and feSquareGeneric
Also a little faster, as a treat.

name                    old time/op  new time/op  delta
Add-8                   5.25ns ± 1%  5.25ns ± 1%    ~     (p=0.472 n=10+8)
Mul-8                   20.1ns ± 0%  19.0ns ± 0%  -5.63%  (p=0.000 n=8+9)
Mul32-8                 4.78ns ± 0%  4.79ns ± 0%  +0.35%  (p=0.000 n=9+10)
BasepointMul-8          15.2µs ± 1%  14.8µs ± 1%  -2.58%  (p=0.000 n=9+9)
ScalarMul-8             51.9µs ± 1%  50.0µs ± 1%  -3.68%  (p=0.000 n=8+9)
VartimeDoubleBaseMul-8  49.1µs ± 0%  47.5µs ± 1%  -3.30%  (p=0.000 n=10+10)
MultiscalarMulSize8-8    181µs ± 1%   177µs ± 1%  -2.12%  (p=0.000 n=10+10)
2021-04-05 15:05:07 -04:00
Filippo Valsorda 8afd860d6f edwards25519: remove Go 1.12 compatibility hack 2021-04-05 15:05:07 -04:00
Filippo Valsorda 1765c13863 edwards25519: don't clobber BP in amd64 assembly
Fixes #11
2021-02-06 18:43:24 +01:00
Adrian Hamelink b73a7c8249
edwards25519: fix ScalarMult when receiver is not the identity (#12)
Calling v.ScalarMult on a receiver v that is not the identity point results in an incorrect operation.
This was fixed by setting v to the identity point in ScalarMult.

A simple test was added to check this behaviour.
2021-02-03 23:49:06 +01:00
Filippo Valsorda 32a46d7b75
edwards25519: document why this can't implement X25519
Thanks to @hdevalence for pointing out the issue with points on the twist.
2021-01-31 15:10:24 +01:00
Filippo Valsorda c5477978af edwards25519: make SqrtRatio slightly more efficient
Inspired by https://twitter.com/jxxf/status/1339930877497925632.
2020-12-18 15:04:48 +01:00