diff options
| author | Jorropo <jorropo.pgm@gmail.com> | 2023-02-13 01:48:57 +0100 |
|---|---|---|
| committer | Filippo Valsorda <filippo@golang.org> | 2023-02-13 19:21:54 +0000 |
| commit | 712c009cf90ad9365f70356fff7bc41323b6fdf0 (patch) | |
| tree | 1430a310c8de9856798c4b232c9c84699663d383 | |
| parent | 505325cf3027f2f2c5be47426867183b935ac85e (diff) | |
| download | go-712c009cf90ad9365f70356fff7bc41323b6fdf0.tar.xz | |
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>
| -rw-r--r-- | src/crypto/internal/edwards25519/edwards25519.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crypto/internal/edwards25519/edwards25519.go b/src/crypto/internal/edwards25519/edwards25519.go index 71e9c097a9..e162dc8cbd 100644 --- a/src/crypto/internal/edwards25519/edwards25519.go +++ b/src/crypto/internal/edwards25519/edwards25519.go @@ -26,13 +26,13 @@ type projP2 struct { // // The zero value is NOT valid, and it may be used only as a receiver. type Point struct { - // The point is internally represented in extended coordinates (X, Y, Z, T) - // where x = X/Z, y = Y/Z, and xy = T/Z per https://eprint.iacr.org/2008/522. - x, y, z, t field.Element - // Make the type not comparable (i.e. used with == or as a map key), as // equivalent points can be represented by different Go values. _ incomparable + + // The point is internally represented in extended coordinates (X, Y, Z, T) + // where x = X/Z, y = Y/Z, and xy = T/Z per https://eprint.iacr.org/2008/522. + x, y, z, t field.Element } type incomparable [0]func() |
