Module Bls12_381_signature

Follow the BLS signature draft of CFRG, version 4

type sk

Type of the secret keys.

val sk_size_in_bytes : int

The size of a serialized value sk

val sk_of_bytes_exn : Stdlib.Bytes.t -> sk

sk_of_bytes_exn bs attempts to deserialize bs into a secret key. bs must be the little endian representation of the secret key. In this case, secret keys are scalars of BLS12-381 and are encoded on 32 bytes. The bytes sequence might be less of 32 bytes and in this case, the bytes sequence is padded on the right by 0's.

  • raises Invalid_argument

    if the bytes sequence is longer than 32 bytes

val sk_of_bytes_opt : Stdlib.Bytes.t -> sk option

sk_of_bytes_opt bs is the same than sk_of_bytes_exn but returns an option instead of an exception.

val sk_to_bytes : sk -> Stdlib.Bytes.t

sk_to_bytes sk serialises the secret key into the little endian representation.

val generate_sk : ?key_info:Stdlib.Bytes.t -> Stdlib.Bytes.t -> sk

generate_sk ?key_info ikm generates a new (random) secret key. ikm must be at least 32 bytes (otherwise, raise Invalid_argument). The default value of key_info is the empty bytes sequence.

val share_secret_key : sk list -> n:int -> (int * sk) list

share_secret_key [s_0;...;s_{m-1}] n shares a secret key s_0 between n participants so that any m participants can collaboratively sign messages, while fewer than m participants cannot produce a valid signature. Other coefficients s_i are random secrets. Each participant is assigned a unique identifier id_i in range 1; n.

Precondition: 1 < m and m <= n.

module MinPk : sig ... end

BLS signatures instantiation minimizing the size of the public keys (48 bytes) but use longer signatures (96 bytes).

module MinSig : sig ... end

BLS signatures instantiation minimizing the size of the signatures (48 bytes) but use longer public keys (96 bytes).