mirror of
https://github.com/tendermint/tendermint.git
synced 2026-06-01 11:56:21 +00:00
Secp256k1 pubkeys are 64 bytes. Strip btcec prefix byte
This commit is contained in:
@@ -123,8 +123,8 @@ func (privKey PrivKeySecp256k1) Sign(msg []byte) Signature {
|
||||
|
||||
func (privKey PrivKeySecp256k1) PubKey() PubKey {
|
||||
_, pub__ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey[:])
|
||||
pub := [65]byte{}
|
||||
copy(pub[:], pub__.SerializeUncompressed())
|
||||
pub := [64]byte{}
|
||||
copy(pub[:], pub__.SerializeUncompressed()[1:])
|
||||
return PubKeySecp256k1(pub)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ func (pubKey PubKeyEd25519) Equals(other PubKey) bool {
|
||||
//-------------------------------------
|
||||
|
||||
// Implements PubKey
|
||||
type PubKeySecp256k1 [65]byte
|
||||
type PubKeySecp256k1 [64]byte
|
||||
|
||||
func (pubKey PubKeySecp256k1) Address() []byte {
|
||||
w, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
@@ -122,7 +122,7 @@ func (pubKey PubKeySecp256k1) Bytes() []byte {
|
||||
}
|
||||
|
||||
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool {
|
||||
pub__, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256())
|
||||
pub__, err := secp256k1.ParsePubKey(append([]byte{0x04}, pubKey[:]...), secp256k1.S256())
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user