NewPublicKeyFromBytes() creates a new PublicKeyI interface from a byte slice
(bz []byte)
| 85 | |
| 86 | // NewPublicKeyFromBytes() creates a new PublicKeyI interface from a byte slice |
| 87 | func NewPublicKeyFromBytes(bz []byte) (PublicKeyI, error) { |
| 88 | switch len(bz) { |
| 89 | case Ed25519PubKeySize: |
| 90 | return BytesToED25519Public(bz), nil |
| 91 | case ETHSECP256K1PubKeySize, ETHSECP256K1PubKeySize + 1: |
| 92 | return BytesToEthSECP256K1Public(bz) |
| 93 | case SECP256K1PubKeySize: |
| 94 | return BytesToSECP256K1Public(bz) |
| 95 | case BLS12381PubKeySize: |
| 96 | return BytesToBLS12381Public(bz) |
| 97 | } |
| 98 | return nil, fmt.Errorf("unrecognized public key format") |
| 99 | } |
| 100 | |
| 101 | // PrivateKeyToFile() writes a private key to a file located at filepath |
| 102 | func PrivateKeyToFile(key PrivateKeyI, filepath string) error { |