Skip to content

Instantly share code, notes, and snippets.

@amintalebi
Created September 7, 2022 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amintalebi/fad96d2f6082564de1fe816088349807 to your computer and use it in GitHub Desktop.
Save amintalebi/fad96d2f6082564de1fe816088349807 to your computer and use it in GitHub Desktop.
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