Crypto

object Crypto

Types

Link copied to clipboard
sealed class SchnorrTweak

Specify how private keys are tweaked when creating Schnorr signatures

Link copied to clipboard
sealed class TaprootTweak : Crypto.SchnorrTweak

Functions

Link copied to clipboard
fun checkPubKeyEncoding(    key: ByteArray,     flags: Int,     sigVersion: Int): Boolean
Link copied to clipboard
fun checkSignatureEncoding(sig: ByteArray, flags: Int): Boolean
Link copied to clipboard
fun compact2der(signature: ByteVector64): ByteVector
Link copied to clipboard
fun decodeSignatureLax(input: ByteArrayInput): Pair<ByteArray, ByteArray>
Link copied to clipboard
fun der2compact(signature: ByteArray): ByteVector64
Link copied to clipboard
fun ecdh(priv: PrivateKey, pub: PublicKey): ByteArray

Computes ecdh using secp256k1's variant: sha256(priv * pub serialized in compressed format)

Link copied to clipboard
fun hash160(input: ByteVector): ByteArray
fun hash160(input: ByteArray): ByteArray
fun hash160(    input: ByteArray,     offset: Int,     len: Int): ByteArray
Link copied to clipboard
fun hash256(input: ByteVector): ByteArray
fun hash256(input: ByteArray): ByteArray
fun hash256(    input: ByteArray,     offset: Int,     len: Int): ByteArray
Link copied to clipboard
fun hmac512(key: ByteArray, data: ByteArray): ByteArray
Link copied to clipboard
fun isDefinedHashTypeSignature(sig: ByteArray): Boolean
Link copied to clipboard
fun isDERSignature(sig: ByteArray): Boolean
Link copied to clipboard
fun isLowDERSignature(sig: ByteArray): Boolean
Link copied to clipboard
fun isPrivKeyValid(key: ByteArray): Boolean
Link copied to clipboard
fun isPubKeyCompressed(key: ByteArray): Boolean
Link copied to clipboard
fun isPubKeyCompressedOrUncompressed(key: ByteArray): Boolean
Link copied to clipboard
fun isPubKeyUncompressed(key: ByteArray): Boolean
Link copied to clipboard
fun isPubKeyValid(key: ByteArray): Boolean
Link copied to clipboard
fun normalize(signature: ByteArray): Pair<ByteVector64, Boolean>
Link copied to clipboard
fun recoverPublicKey(sig: ByteVector64, message: ByteArray): Pair<PublicKey, PublicKey>

Recover public keys from a signature and the message that was signed. This method will return 2 public keys, and the signature can be verified with both, but only one of them matches that private key that was used to generate the signature.

fun recoverPublicKey(    sig: ByteVector64,     message: ByteArray,     recid: Int): PublicKey

Recover public keys from a signature, the message that was signed, and the recovery id (i.e. the sign of the recovered public key)

Link copied to clipboard
fun ripemd160(input: ByteVector): ByteArray
fun ripemd160(input: ByteArray): ByteArray
fun ripemd160(    input: ByteArray,     offset: Int,     len: Int): ByteArray
Link copied to clipboard
fun sha1(input: ByteVector): ByteArray
Link copied to clipboard
fun sha256(input: ByteVector): ByteArray
fun sha256(input: ByteArray): ByteArray
fun sha256(    input: ByteArray,     offset: Int,     len: Int): ByteArray
Link copied to clipboard
fun sign(data: ByteVector32, privateKey: PrivateKey): ByteVector64

fun sign(data: ByteArray, privateKey: PrivateKey): ByteVector64

Sign data with a private key, using RCF6979 deterministic signatures

Link copied to clipboard
fun signSchnorr(    data: ByteVector32,     privateKey: PrivateKey,     schnorrTweak: Crypto.SchnorrTweak,     auxrand32: ByteVector32? = null): ByteVector64
Link copied to clipboard
fun taggedHash(input: ByteArray, tag: String): ByteVector32
Link copied to clipboard
fun verifySignature(    data: ByteArray,     signature: ByteVector64,     publicKey: PublicKey): Boolean
Link copied to clipboard
fun verifySignatureSchnorr(    data: ByteVector32,     signature: ByteVector,     publicKey: XonlyPublicKey): Boolean