From da0c9349ca890941e76d2f4b2aeadb4987b34dcc Mon Sep 17 00:00:00 2001 From: "Scott G. Miller" Date: Thu, 3 Oct 2024 13:25:36 -0500 Subject: [PATCH] Remove one more use of ScalarMult from CE --- helper/dhutil/dhutil.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/helper/dhutil/dhutil.go b/helper/dhutil/dhutil.go index 7c14cb29fbca..fd20f89d5021 100644 --- a/helper/dhutil/dhutil.go +++ b/helper/dhutil/dhutil.go @@ -30,14 +30,17 @@ type Envelope struct { // generatePublicPrivateKey uses curve25519 to generate a public and private key // pair. func GeneratePublicPrivateKey() ([]byte, []byte, error) { - var scalar, public [32]byte + scalar := make([]byte, 32) - if _, err := io.ReadFull(rand.Reader, scalar[:]); err != nil { + if _, err := io.ReadFull(rand.Reader, scalar); err != nil { return nil, nil, err } - curve25519.ScalarBaseMult(&public, &scalar) - return public[:], scalar[:], nil + public, err := curve25519.X25519(curve25519.Basepoint, scalar) + if err != nil { + return nil, nil, err + } + return public, scalar, nil } // GenerateSharedSecret uses the private key and the other party's public key to