getPublicKey

fun getPublicKey(privateKey: ByteArray): ByteArray?

Derives the verifying key (public key) from a private key.

BIP-340 Public Key Format:

  • 32 bytes (x-only public key)

  • Y-coordinate is implicit (even)

  • NOT the same as uncompressed secp256k1 public key (33 or 65 bytes)

Usage Example:

val privateKey: ByteArray = ... // 32 bytes from BIP-32
val publicKey = TransactionSigner.getPublicKey(privateKey)

// publicKey is 32 bytes (BIP-340 x-only format)
val address = AddressFormatter.encodeAddress(publicKey)

Return

32-byte BIP-340 public key (x-only), or null on error

Parameters

privateKey

32-byte secp256k1 private key

Throws

if privateKey is not 32 bytes