We have functions for parsing from []byte to key and marshaling key to PEM in the keygen package.
// ParsePrivateKey parses a PEM encoded private key.
func ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error)
// ParsePublicKey parses a PEM encoded public key
func ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error)
// PrivateKeyToPEM encodes the private key in PEM format.
func PrivateKeyToPEM(key hotstuff.PrivateKey) ([]byte, error)
// PublicKeyToPEM encodes the public key in PEM format.
func PublicKeyToPEM(key hotstuff.PublicKey) ([]byte, error)
However, these belong in their respective packages {ecdsa, eddsa, bls12}, since we must add code to these methods whenever we add a new crypto scheme and expose parsing details outside the package, which could be kept internal to the specific package.
That is, we should add these to the different crypto packages:
hotstuff.{Private|Public}Key should require key types to provide a MarshalToPEM() ([]byte, error) method.
We have functions for parsing from
[]byte
to key and marshaling key to PEM in thekeygen
package.However, these belong in their respective packages
{ecdsa, eddsa, bls12}
, since we must add code to these methods whenever we add a new crypto scheme and expose parsing details outside the package, which could be kept internal to the specific package.That is, we should add these to the different crypto packages:
hotstuff.{Private|Public}Key
should require key types to provide aMarshalToPEM() ([]byte, error)
method.ParsePublicKey(buf []byte) (key hotstuff.PublicKey, err error)
ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error)
Have I've overlooked something that makes this approach less desirable?