Browse Source

Secp256k1 pubkeys are 64 bytes. Strip btcec prefix byte

pull/1782/head
Jae Kwon 9 years ago
parent
commit
7e767e9548
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      priv_key.go
  2. +2
    -2
      pub_key.go

+ 2
- 2
priv_key.go View File

@ -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)
}


+ 2
- 2
pub_key.go View File

@ -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
}


Loading…
Cancel
Save