Skip to content

Commit

Permalink
fix: use correct magic byte prefix for public key
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Mar 16, 2022
1 parent 54c3ee7 commit 4532b06
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dashmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@ func PublicKeyToAddress(magicVersion string, pub ecdsa.PublicKey) string {
}

b := elliptic.Marshal(secp256k1crypto.S256(), pub.X, pub.Y)
b[0] = byte(0x03)
y := b[33:]
lastY := len(y) - 1
odd := 1 == y[lastY]%2
if odd {
b[0] = byte(0x03)
} else {
b[0] = byte(0x02)
}

b = b[0:33]
//fmt.Fprintf(os.Stderr, "PubKey Bytes: %d %v\n", len(b), hex.EncodeToString(b))

Expand Down

0 comments on commit 4532b06

Please sign in to comment.