secp256k1

Elliptic curve library secp256k1 wrapper for Ocaml
IN THIS PACKAGE
Module Secp256k1 . Context
type flag =
| Verify
| Sign(*

which parts of the context to initialize.

*)
type t

Opaque data structure that holds context information (precomputed tables etc.).

Do not create a new context object for each operation, as construction is far slower than all other API calls (~100 times slower than an ECDSA verification).

A constructed context can safely be used from multiple threads simultaneously, but API call that take a non-const pointer to a context need exclusive access to it. In particular this is the case for secp256k1_context_destroy and secp256k1_context_randomize.

Regarding randomization, either do it once at creation time (in which case you do not need any locking for the other calls), or use a read-write lock.

val create : flag list -> t

Create a secp256k1 context object.

val clone : t -> t

Copies a secp256k1 context object.

val randomize : t -> buffer -> bool

While secp256k1 code is written to be constant-time no matter what secret values are, it's possible that a future compiler may output code which isn't, and also that the CPU may not emit the same radio frequencies or draw the same amount power for all values.

This function provides a seed which is combined into the blinding value: that blinding value is added before each multiplication (and removed afterwards) so that it does not affect function results, but shields against attacks which rely on any input-dependent behaviour.

You should call this after secp256k1_context_create or secp256k1_context_clone, and may call this repeatedly afterwards.