Skip to content

Commit

Permalink
Remove one more use of ScalarMult from CE
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmiller committed Oct 3, 2024
1 parent e8a432c commit da0c934
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions helper/dhutil/dhutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da0c934

Please sign in to comment.