Secp256k1Native

Functions

Link copied to clipboard
open override fun cleanup()

Delete the secp256k1 context from dynamic memory.

Link copied to clipboard
open override fun compact2der(sig: ByteArray): ByteArray

Convert a compact ECDSA signature (64 bytes) to a der-encoded ECDSA signature.

Link copied to clipboard
open override fun ecdh(privkey: ByteArray, pubkey: ByteArray): ByteArray

Compute an elliptic curve Diffie-Hellman secret.

Link copied to clipboard
open override fun ecdsaRecover(sig: ByteArray, message: ByteArray, recid: Int): ByteArray

Recover a public key from an ECDSA signature.

Link copied to clipboard
open override fun musigNonceAgg(pubnonces: Array<ByteArray>): ByteArray

Aggregate public nonces from all participants of a signing session.

Link copied to clipboard
open override fun musigNonceGen(sessionRandom32: ByteArray, privkey: ByteArray?, pubkey: ByteArray, msg32: ByteArray?, keyaggCache: ByteArray?, extraInput32: ByteArray?): ByteArray

Generate a secret nonce to be used in a musig2 signing session. This nonce must never be persisted or reused across signing sessions. All optional arguments exist to enrich the quality of the randomness used, which is critical for security.

Link copied to clipboard
open override fun musigNonceGenCounter(nonRepeatingCounter: ULong, privkey: ByteArray, msg32: ByteArray?, keyaggCache: ByteArray?, extraInput32: ByteArray?): ByteArray

Alternative counter-based method for generating nonce. This nonce must never be persisted or reused across signing sessions. All optional arguments exist to enrich the quality of the randomness used, which is critical for security.

Link copied to clipboard
open override fun musigNonceProcess(aggnonce: ByteArray, msg32: ByteArray, keyaggCache: ByteArray): ByteArray

Create a signing session context based on the public information from all participants.

Link copied to clipboard
open fun musigNonceValidate(secretnonce: ByteArray, pubkey: ByteArray): Boolean

Check that a secret nonce was generated with a public key that matches the private key used for signing.

Link copied to clipboard
open override fun musigPartialSigAgg(session: ByteArray, psigs: Array<ByteArray>): ByteArray

Aggregate partial signatures from all participants into a single schnorr signature. If some of the partial signatures are invalid, this function will return an invalid aggregated signature without raising an error. It is recommended to use musigPartialSigVerify to verify partial signatures first.

Link copied to clipboard
open override fun musigPartialSign(secnonce: ByteArray, privkey: ByteArray, keyaggCache: ByteArray, session: ByteArray): ByteArray

Create a partial signature.

Link copied to clipboard
open override fun musigPartialSigVerify(psig: ByteArray, pubnonce: ByteArray, pubkey: ByteArray, keyaggCache: ByteArray, session: ByteArray): Int

Verify the partial signature from one of the signing session's participants.

Link copied to clipboard
open override fun musigPubkeyAgg(pubkeys: Array<ByteArray>, keyaggCache: ByteArray?): ByteArray

Aggregate public keys from all participants of a signing session.

Link copied to clipboard
open override fun musigPubkeyTweakAdd(keyaggCache: ByteArray, tweak32: ByteArray): ByteArray

Tweak the aggregated public key of a signing session.

Link copied to clipboard
open override fun musigPubkeyXonlyTweakAdd(keyaggCache: ByteArray, tweak32: ByteArray): ByteArray

Tweak the aggregated public key of a signing session, treating it as an x-only public key (e.g. when using taproot).

Link copied to clipboard
open override fun privKeyNegate(privkey: ByteArray): ByteArray

Negate the given private key.

Link copied to clipboard
open override fun privKeyTweakAdd(privkey: ByteArray, tweak: ByteArray): ByteArray

Tweak a private key by adding tweak to it.

Link copied to clipboard
open override fun privKeyTweakMul(privkey: ByteArray, tweak: ByteArray): ByteArray

Tweak a private key by multiplying it by a tweak.

Link copied to clipboard
open override fun pubKeyCombine(pubkeys: Array<ByteArray>): ByteArray

Add a number of public keys together. Returns the uncompressed public key (65 bytes).

Link copied to clipboard

Serialize a public key to compact form (33 bytes).

Link copied to clipboard
open override fun pubkeyCreate(privkey: ByteArray): ByteArray

Get the public key corresponding to the given private key. Returns the uncompressed public key (65 bytes).

Link copied to clipboard
open override fun pubKeyNegate(pubkey: ByteArray): ByteArray

Negate the given public key. Returns the uncompressed public key (65 bytes).

Link copied to clipboard
open override fun pubkeyParse(pubkey: ByteArray): ByteArray

Parse a serialized public key. Returns the uncompressed public key (65 bytes).

Link copied to clipboard
open override fun pubKeyTweakAdd(pubkey: ByteArray, tweak: ByteArray): ByteArray

Tweak a public key by adding tweak times the generator to it. Returns the uncompressed public key (65 bytes).

Link copied to clipboard
open override fun pubKeyTweakMul(pubkey: ByteArray, tweak: ByteArray): ByteArray

Tweak a public key by multiplying it by a tweak value. Returns the uncompressed public key (65 bytes).

Link copied to clipboard
open override fun secKeyVerify(privkey: ByteArray): Boolean

Verify the validity of a private key.

Link copied to clipboard
open override fun sign(message: ByteArray, privkey: ByteArray): ByteArray

Create a normalized ECDSA signature.

Link copied to clipboard

Convert an ECDSA signature to a normalized lower-S form (bitcoin standardness rule). Returns the normalized signature and a boolean set to true if the input signature was not normalized.

Link copied to clipboard
open override fun signSchnorr(data: ByteArray, sec: ByteArray, auxrand32: ByteArray?): ByteArray

Create a Schnorr signature.

Link copied to clipboard
open override fun verify(signature: ByteArray, message: ByteArray, pubkey: ByteArray): Boolean

Verify an ECDSA signature.

Link copied to clipboard
open override fun verifySchnorr(signature: ByteArray, data: ByteArray, pub: ByteArray): Boolean

Verify a Schnorr signature.