Created
September 7, 2022 14:45
-
-
Save amintalebi/fad96d2f6082564de1fe816088349807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
btcsecp256k1 "github.com/btcsuite/btcd/btcec" | |
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | |
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | |
) | |
func BytesToPublicKey(bytes []byte) (cryptotypes.PubKey, error) { | |
pk, err := btcsecp256k1.ParsePubKey(bytes, btcsecp256k1.S256()) | |
if err != nil { | |
return nil, err | |
} | |
return &secp256k1.PubKey{Key: pk.SerializeCompressed()}, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment