PrivateKey

data class PrivateKey(val value: ByteVector32)

A bitcoin private key. A private key is valid if it is not 0 and less than the secp256k1 curve order when interpreted as an integer (most significant byte first). The probability of choosing a 32-byte string uniformly at random which is an invalid private key is negligible, so this condition is not checked by default. However, if you receive a private key from an external, untrusted source, you should call isValid() before actually using it.

Constructors

Link copied to clipboard
fun PrivateKey(data: ByteArray)
Link copied to clipboard
fun PrivateKey(data: ByteVector)
Link copied to clipboard
fun PrivateKey(value: ByteVector32)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun compress(): ByteArray
Link copied to clipboard
fun isValid(): Boolean

A private key is valid if it is not 0 and less than the secp256k1 curve order when interpreted as an integer (most significant byte first). The probability of choosing a 32-byte string uniformly at random which is an invalid private key is negligible.

Link copied to clipboard
operator fun minus(that: PrivateKey): PrivateKey
Link copied to clipboard
operator fun plus(that: PrivateKey): PrivateKey
Link copied to clipboard
fun publicKey(): PublicKey
Link copied to clipboard
operator fun times(that: PrivateKey): PrivateKey
Link copied to clipboard
fun toBase58(prefix: Byte): String
Link copied to clipboard
fun toHex(): String
Link copied to clipboard
open override fun toString(): String

We avoid accidentally logging private keys. You should use an explicit method if you want to convert the private key to a string representation.

Link copied to clipboard
fun tweak(tweak: ByteVector32): PrivateKey
Link copied to clipboard
operator fun unaryMinus(): PrivateKey
Link copied to clipboard
fun xOnlyPublicKey(): XonlyPublicKey

Properties

Link copied to clipboard
val value: ByteVector32