Skip to content

Commit 4532b06

Browse files
author
AJ ONeal
committed
fix: use correct magic byte prefix for public key
1 parent 54c3ee7 commit 4532b06

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

dashmsg.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,15 @@ func PublicKeyToAddress(magicVersion string, pub ecdsa.PublicKey) string {
186186
}
187187

188188
b := elliptic.Marshal(secp256k1crypto.S256(), pub.X, pub.Y)
189-
b[0] = byte(0x03)
189+
y := b[33:]
190+
lastY := len(y) - 1
191+
odd := 1 == y[lastY]%2
192+
if odd {
193+
b[0] = byte(0x03)
194+
} else {
195+
b[0] = byte(0x02)
196+
}
197+
190198
b = b[0:33]
191199
//fmt.Fprintf(os.Stderr, "PubKey Bytes: %d %v\n", len(b), hex.EncodeToString(b))
192200

0 commit comments

Comments
 (0)