secp256k1-internal

Bindings to secp256k1 internal functions (generic operations on the curve)
IN THIS PACKAGE

Signature

type plain
type recoverable
type _ t
val buffer : _ t -> Bigstring.t

buffer signature is the underlying buffer of signature. DO NOT MODIFY.

val plain_bytes : int

64 bytes

val recoverable_bytes : int

65 bytes

val msg_bytes : int

32 bytes

val equal : 'a t -> 'a t -> bool
val to_plain : Context.t -> _ t -> plain t

Input/Output

val read : Context.t -> Bigstring.t -> ( plain t, string ) result
val read_exn : Context.t -> Bigstring.t -> plain t
val read_der : Context.t -> Bigstring.t -> ( plain t, string ) result
val read_der_exn : Context.t -> Bigstring.t -> plain t
val read_recoverable : Context.t -> Bigstring.t -> ( recoverable t, string ) result

read_recoverable_exn ctx buf reads a recoverable signature in buf if everything goes well or return an error otherwise.

val read_recoverable_exn : Context.t -> Bigstring.t -> recoverable t

read_recoverable_exn ctx buf reads a recoverable signature in buf.

  • raises [Invalid_argument]

    if buf is less than 65 bytes long or buf does not contain a valid recoverable signature.

val write_exn : ?der:bool -> Context.t -> Bigstring.t -> _ t -> int
val write : ?der:bool -> Context.t -> Bigstring.t -> _ t -> ( int, string ) result
val to_bytes : ?der:bool -> Context.t -> _ t -> Bigstring.t

to_bytes ?der ctx signature writes the serialization of signature in a freshly allocated Bigstring.t, which is then returned.

Sign

val normalize : Context.t -> plain t -> plain t option

normalize ctx sig is the normalized lower-S form of Some normalized_sig if sig was not already in this form, or None otherwise.

Creation
val sign : Context.t -> sk:Key.secret Key.t -> Bigstring.t -> ( plain t, string ) result
val sign_exn : Context.t -> sk:Key.secret Key.t -> Bigstring.t -> plain t
val sign_recoverable : Context.t -> sk:Key.secret Key.t -> Bigstring.t -> ( recoverable t, string ) result
val sign_recoverable_exn : Context.t -> sk:Key.secret Key.t -> Bigstring.t -> recoverable t
Direct write
val write_sign : Context.t -> Bigstring.t -> sk:Key.secret Key.t -> msg:Bigstring.t -> ( int, string ) result

write_sign ctx buf ~sk ~msg writes signs msg with sk and writes the signature to buf at ?pos. It returns the number of bytes written (64) on success, or ar error message otherwise.

val write_sign_exn : Context.t -> Bigstring.t -> sk:Key.secret Key.t -> msg:Bigstring.t -> int

write_sign_exn ctx buf ~sk ~msg writes signs msg with sk and writes the signature to buf at ?pos. It returns the number of bytes written (64).

  • raises Invalid_argument

    if buf is not long enough to contain a signature or signing has failed.

val write_sign_recoverable : Context.t -> sk:Key.secret Key.t -> msg:Bigstring.t -> Bigstring.t -> ( int, string ) result
val write_sign_recoverable_exn : Context.t -> sk:Key.secret Key.t -> msg:Bigstring.t -> Bigstring.t -> int
Verification
val verify_exn : Context.t -> pk:Key.public Key.t -> msg:Bigstring.t -> signature:_ t -> bool
val verify : Context.t -> pk:Key.public Key.t -> msg:Bigstring.t -> signature:_ t -> ( bool, string ) result
Recovery
val recover_exn : Context.t -> signature:recoverable t -> Bigstring.t -> Key.public Key.t
val recover : Context.t -> signature:recoverable t -> Bigstring.t -> ( Key.public Key.t, string ) result