ProtonMail / go-crypto

Fork of go/x/crypto, providing an up-to-date OpenPGP implementation
https://pkg.go.dev/github.com/ProtonMail/go-crypto
BSD 3-Clause "New" or "Revised" License
328 stars 99 forks source link

eddsa.GenerateKey uses internal parameter #176

Open Alkorin opened 1 year ago

Alkorin commented 1 year ago

I try to generate a private Ed25519 Key, but eddsa.GenerateKey expects an ecc.EdDSACurve and NewEd25519 is inside an internal package :/

Is there a way to generate a private Ed25519 Key like in https://github.com/ProtonMail/go-crypto/blob/7e9e0395ebec101954178e9a81d936121bf999c5/openpgp/packet/private_key_test.go#L401 ?

lubux commented 1 year ago

Hi 👋 Thanks for pointing this out. It is possible to generate an Ed25519 PGP key as follows:

config := &packet.Config{
    Algorithm: packet.PubKeyAlgoEdDSA,
}
entity, err := openpgp.NewEntity("test", "", "test@test.test", config)

The primary private key entity.PrivateKey is an Ed25519 private key.

smlx commented 1 year ago

This PR solves a similar issue: https://github.com/ProtonMail/go-crypto/pull/157