Secp256k1 pubkeys are 64 bytes. Strip btcec prefix byte

This commit is contained in:
Jae Kwon
2016-04-20 08:46:07 -07:00
parent c121163635
commit 7e767e9548
2 changed files with 4 additions and 4 deletions

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

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
}