func UnmarshalPrivateKey(keyDER []byte) (crypto.Signer, error) {
	key1, err1 := x509.ParseECPrivateKey(keyDER)
	if err1 == nil {
		return key1, nil
	}
	key2, err2 := x509.ParsePKCS8PrivateKey(keyDER)
	if err2 == nil {
		switch key2 := key2.(type) {
		case *ecdsa.PrivateKey:
			return key2, nil
		case *rsa.PrivateKey:
			return key2, nil
		case ed25519.PrivateKey:
			return key2, nil
		}
		return nil, fmt.Errorf("der: unsupported private key type: %T", key2)
	}
	key3, err3 := x509.ParsePKCS1PrivateKey(keyDER)
	if err3 == nil {
		return key3, nil
	}
	return nil, fmt.Errorf("der: could not parse private key as SEC1 (%v), PKCS8 (%v) or PKCS1 (%v)", err1, err2, err3)
}
UnmarshalPrivateKey reads a DER-encoded private key.
package der
import (
	"context"
	"crypto"
	"crypto/ecdsa"
	"crypto/rsa"
	"crypto/x509"
	"fmt"
	"github.com/google/trillian/crypto/keyspb"
	"golang.org/x/crypto/ed25519"
	"google.golang.org/protobuf/proto"
)
func FromProto(_ context.Context, pb proto.Message) (crypto.Signer, error) {
	if pb, ok := pb.(*keyspb.PrivateKey); ok {
		return UnmarshalPrivateKey(pb.GetDer())
	}
	return nil, fmt.Errorf("der: got %T, want *keyspb.PrivateKey", pb)
}