Skip to content

Commit 712c009

Browse files
JorropoFiloSottile
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Filippo Valsorda <[email protected]> Reviewed-by: Damien Neil <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]>
1 parent 505325c commit 712c009

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/crypto/internal/edwards25519/edwards25519.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ type projP2 struct {
2626
//
2727
// The zero value is NOT valid, and it may be used only as a receiver.
2828
type Point struct {
29-
// The point is internally represented in extended coordinates (X, Y, Z, T)
30-
// where x = X/Z, y = Y/Z, and xy = T/Z per https://eprint.iacr.org/2008/522.
31-
x, y, z, t field.Element
32-
3329
// Make the type not comparable (i.e. used with == or as a map key), as
3430
// equivalent points can be represented by different Go values.
3531
_ incomparable
32+
33+
// The point is internally represented in extended coordinates (X, Y, Z, T)
34+
// where x = X/Z, y = Y/Z, and xy = T/Z per https://eprint.iacr.org/2008/522.
35+
x, y, z, t field.Element
3636
}
3737

3838
type incomparable [0]func()

0 commit comments

Comments
 (0)