You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
What did you do?
Consistency needed: Change GenerateKey() to return only private key with error because it seems awkward that it returns both public key and private key while NewKeyFromSeed() returns only private key. In addition, it is so confused for someone who are not familiar with crypto/ed25519 package
I know there might be a huge side effect when standard package is changed, but my opinion is that it worth modifying it right now, considering the current increase of gophers. As more gophers mean that more go code will be, this is perfect time to change it
As-is
// GenerateKey generates a public/private key pair using entropy from rand.// If rand is nil, crypto/rand.Reader will be used.funcGenerateKey(rand io.Reader) (PublicKey, PrivateKey, error) {
ifrand==nil {
rand=cryptorand.Reader
}
seed:=make([]byte, SeedSize)
if_, err:=io.ReadFull(rand, seed); err!=nil {
returnnil, nil, err
}
privateKey:=NewKeyFromSeed(seed)
publicKey:=make([]byte, PublicKeySize)
copy(publicKey, privateKey[32:])
returnpublicKey, privateKey, nil
}
To-be
// GenerateKey generates a private pair using entropy from rand.// If rand is nil, crypto/rand.Reader will be used.funcGenerateKey(rand io.Reader) (PrivateKey, error) {
ifrand==nil {
rand=cryptorand.Reader
}
seed:=make([]byte, SeedSize)
if_, err:=io.ReadFull(rand, seed); err!=nil {
returnnil, nil, err
}
privateKey:=NewKeyFromSeed(seed)
returnprivateKey, nil
}
I don't necessarily disagree that it would be cleaner to return just the PrivateKey, but unfortunately the API is now locked in by the Go 1 Compatibility Promise.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: