Commit graph

23 commits

Author SHA1 Message Date
DataHoarder f0596f127a
Replace package name with git.gammaspectra.live/P2Pool/edwards25519 2024-04-05 09:03:06 +02: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
Filippo Valsorda 383e08737b edwards25519: sync with upstream
Minor doc, names, go:build directive changes.
2022-05-25 01:39:14 +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 dd0c73fa20 all: sync with landed standard library upstream 2021-05-26 18:09:02 +02:00
Filippo Valsorda 700f4f4a67 edwards25519: panic if an uninitialized Point is used 2020-12-17 19:15:22 +01:00
Filippo Valsorda 8cc8037b17 edwards25519: smooth a couple test coverage rough edges
Also, document the Pow22523 ladder. See also golang/go#39554.
2020-12-13 05:23:32 +01:00
Filippo Valsorda 9063a14176 edwards25519: test that operations cause zero heap allocations 2020-12-13 02:45:23 +01:00
Filippo Valsorda c1fe95af5a edwards25519: add MultByCofactor
The implementation is a bit of a hack, we can probably save some
operations by not doing the two projP2.FromP1xP1 conversions, but it's
unclear if the performance matters to anyone.

For hdevalence/ed25519consensus#5
2020-12-12 13:11:47 +01:00
Filippo Valsorda ffb3e31d83 edwards25519: specify the behavior of Invert(0) and I.BytesMontgomery() 2020-12-05 02:30:18 +01:00
Luke Champine 3b045f3ef7
edwards25519: outline (*Point).Bytes (#6) 2020-11-28 21:48:34 +01:00
Filippo Valsorda 77d7b3141c edwards25519: add (*Point).BytesMontgomery 2020-11-28 04:38:15 +01:00
Filippo Valsorda 6e8d645c8b edwards25519: implement (*Point).Bytes and (*Point).SetBytes 2020-11-28 04:38:15 +01:00
Filippo Valsorda 90c35a7f43 edwards25519: hide FieldElement and (*Point).ExtendedCoords
We'll need these for ristretto255, but we might want to expose them in a
separate package. Note how FieldElement was only exported for the
benefit of ExtendedCoords. For now, unexport FieldElement and delete
ExtendedCoords (since a proper FromExtendedCoords implementation would
check the curve equations anyway).
2020-11-23 05:27:48 +01:00
Filippo Valsorda 9c7303a0b2 edwards25519: remove (*Point).Identity and (*Point).Generator
I could not decide if they should be called SetIdentity/SetGenerator, so
instead I removed them. Turns out we only needed them in one place,
where Set(NewIdentityPoint()) inlines well enough that it should perform
the same.

Most the Identity calls were redundant as the value was overwritten
before being used next.
2020-11-23 04:58:26 +01:00
Filippo Valsorda daa250742f edwards25519: minor doc and string touch-ups 2020-11-23 03:51:42 +01:00
Filippo Valsorda f28d75ad5d edwards25519: change constructors
We now don't have a NewPoint which maybe helps imply there isn't a zero
value for a Point, and renamed Zero and One to Identity and Generator.
2020-11-23 02:57:28 +01:00
Filippo Valsorda feed48c532 edwards25519: cleanup the FieldElement API 2020-09-28 14:18:44 +02:00
Filippo Valsorda f6ee18761d edwards25519: make Point opaque 2020-09-28 14:18:44 +02:00
Filippo Valsorda c5c2e9e1ac edwards25519: rename ProjP3 to Point and unexport other point types 2020-09-28 14:18:44 +02:00
Filippo Valsorda 07a7683e64 edwards25519: hide some more exposed symbols 2020-09-28 14:18:44 +02:00
Filippo Valsorda d3569cbbb3 all: flatten the package and make FieldElement opaque
For the license changes, see gtank/ristretto255-private#28 and
gtank/ristretto255#32, that contribute all code in those repositories to
the Go project under the Google CLA.
2020-09-28 14:18:44 +02:00
Filippo Valsorda 6f5f5828e1 all: expose edwards25519, base, and scalar packages 2020-08-27 00:35:09 -04:00
Renamed from internal/edwards25519/edwards25519.go (Browse further)