package secp256k1-internal

  1. Overview
  2. Docs

Module Internal.ScalarSource

Sourcetype t

A scalar modulo the group order of the secp256k1 curve.

Sourceval zero : unit -> t
Sourceval one : unit -> t
Sourceval copy : t -> t
Sourceval const : ?d7:int32 -> ?d6:int32 -> ?d5:int32 -> ?d4:int32 -> ?d3:int32 -> ?d2:int32 -> ?d1:int32 -> ?d0:int32 -> unit -> t
Sourceval clear : t -> unit

Clear a scalar to prevent the leak of sensitive data.

Sourceval get_bits : t -> int -> int -> int

get_bits a offset count Access bits from a scalar. All requested bits must belong to the same 32-bit limb.

Sourceval get_bits_var : t -> int -> int -> int

get_bits a offset count Access bits from a scalar. Not constant time.

Sourceval set_b32 : t -> Cstruct.t -> bool

Set a scalar from a big endian byte array.

Sourceval set_int : t -> int -> unit

Set a scalar to an unsigned integer.

Sourceval get_b32 : Cstruct.t -> t -> unit

Convert a scalar to a byte array.

Sourceval add : t -> t -> t -> bool

add r a b Add two scalars together (modulo the group order). Returns whether it overflowed.

Sourceval cadd_bit : t -> int -> bool -> unit

cadd_bit r bit flag Conditionally add a power of two to a scalar. The result is not allowed to overflow.

Sourceval mul : t -> t -> t -> unit

mul r a b Multiply two scalars (modulo the group order).

Sourceval shr_int : t -> int -> int

Shift a scalar right by some amount strictly between 0 and 16, returning the low bits that were shifted off

Sourceval sqr : t -> t -> unit

sqr r a Compute the square of a scalar (modulo the group order).

Sourceval inverse : t -> t -> unit

inverse r a Compute the inverse of a scalar (modulo the group order).

Sourceval inverse_var : t -> t -> unit

inverse_var r a Compute the inverse of a scalar (modulo the group order), without constant-time guarantee.

Sourceval negate : t -> t -> unit

negate r a Compute the complement of a scalar (modulo the group order).

Sourceval is_zero : t -> bool

Check whether a scalar equals zero.

Sourceval is_one : t -> bool

Check whether a scalar equals one.

Sourceval is_even : t -> bool

Check whether a scalar, considered as an nonnegative integer, is even.

Sourceval is_high : t -> bool

Check whether a scalar is higher than the group order divided by 2.

Sourceval cond_negate : t -> bool -> bool

Conditionally negate a number, in constant time. Returns true if the number was negated, false otherwise

Sourceval get_num : Num.t -> t -> unit

Convert a scalar to a number.

Sourceval order_get_num : Num.t -> unit

Get the order of the group as a number.

Sourceval equal : t -> t -> bool

Compare two scalars.

Sourceval mul_shift_var : t -> t -> t -> int -> unit

Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer. Shift must be at least 256.

OCaml

Innovation. Community. Security.