Module secp256k1::ffi

source ·
Expand description

FFI bindings

Direct bindings to the underlying C library functions. These should not be needed for most users.

Structs

A Secp256k1 context, containing various precomputed values and such needed to do elliptic curve computations. If you create one of these with secp256k1_context_create you MUST destroy it with secp256k1_context_destroy, or else you will have a memory leak.
Library-internal representation of a Secp256k1 public key
Library-internal representation of a Secp256k1 signature + recovery ID
Library-internal representation of an ECDH shared secret
Library-internal representation of a Secp256k1 signature

Constants

Flag for keys to indicate compressed serialization format
Flag for keys to indicate uncompressed serialization format
Flag for context to enable no precomputation
Flag for context to enable signing precomputation
Flag for context to enable verification precomputation

Statics

Functions

Copies a dummy context
Creates a dummy context, tracking flags to ensure proper calling semantics
Frees a dummy context
Asserts that cx is properly initialized
Copies the first 16 bytes of tweak into the last 16 bytes of sk
Copies the last 16 bytes of tweak into the last 16 bytes of sk
Sets pk to sk||sk
Parse 33/65 byte pubkey into PublicKey, losing compressed information
Serialize PublicKey back to 33/65 byte pubkey
The PublicKey equivalent of secp256k1_ec_privkey_tweak_add
The PublicKey equivalent of secp256k1_ec_privkey_tweak_mul
Checks that sk != 0xffff…ffff
Sets out to point[0..16]||scalar[0..16]
Sets sig to msg32||sk
Sets sig to (2|3)||msg32||sk
Copies input64 to sig, checking the pubkey part is valid
Copies up to 72 bytes into output from sig
Verifies that sig is msg32||pk[0..32]
Checks that pk != 0xffff…ffff and pk[0..32] == pk[32..64]

Type Definitions

A nonce generation function. Ordinary users of the library never need to see this type; only if you need to control nonce generation do you need to use it. I have deliberately made this hard to do: you have to write your own wrapper around the FFI functions to use it. And it’s an unsafe type. Nonces are generated deterministically by RFC6979 by default; there should be no need to ever change this.