package tezos-protocol-alpha

  1. Overview
  2. Docs
Tezos protocol alpha package

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-18.1.tar.gz
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a

doc/tezos_raw_protocol_alpha/Tezos_raw_protocol_alpha/Seed_repr/index.html

Module Tezos_raw_protocol_alpha.Seed_reprSource

Tezos Protocol Implementation - Random number generation

This is not expected to be a good cryptographic random number generator. In particular this is supposed to be used in situations where the seed is a globally known information.

The only expected property is: It should be difficult to find a seed such that the generated sequence is a given one.

Random Generation

Sourcetype t

The state of the random number generator

Sourcetype seed

A random seed, to derive random sequences from

Sourcetype sequence

A random sequence, to derive random values from

Sourceval compare_vdf_solution : vdf_solution -> vdf_solution -> int

Compare only the first element of two vdf_solution, that are of Vdf.result.

Sourceval generate_vdf_setup : seed_discriminant:seed -> seed_challenge:seed -> vdf_setup
Sourceval vdf_to_seed : seed -> vdf_solution -> seed
Sourceval initialize_new : seed -> bytes list -> t

initialize_new state ident returns a new generator

Sourceval sequence : t -> int32 -> sequence

sequence state n prepares the n-th sequence of a state

Sourceval take : sequence -> bytes * sequence

Generates the next random value in the sequence

Sourceval take_int32 : sequence -> int32 -> int32 * sequence

take_int32 s bound generates the next random value as a bounded int32

  • parameter bound

    must be a positive integer

  • raises Invalid_argument

    "Seed_repr.take_int32" if bound <= 0

Sourceval take_int64 : sequence -> int64 -> int64 * sequence

take_int64 s bound generates the next random value as a bounded int64

  • parameter bound

    must be a positive integer

  • raises Invalid_argument

    "Seed_repr.take_int64" if bound <= 0

Entropy

Sourcetype nonce

A nonce for adding entropy to the generator

Sourceval update_seed : seed -> nonce -> seed

Add entropy to the seed generator

Use a byte sequence as a nonce

Compute the hash of a nonce

Sourceval check_hash : nonce -> Nonce_hash.t -> bool

check_hash nonce hash is true if the nonce correspond to the hash

Sourceval nonce_hash_key_part : Nonce_hash.t -> string list -> string list

For using nonce hashes as keys in the hierarchical database

Sourceval deterministic_seed : seed -> seed

Returns a new seed by hashing the one passed with a constant.

Sourceval initial_seeds : ?initial_seed:State_hash.t -> int -> seed list

initial_seeds n generates the first n seeds for which there are no nonces. The first seed is a constant value. The kth seed is the hash of seed (k-1) concatenated with a constant. If an initial_seed is provided, the first seed is created using it as the first one.

Predefined nonce

Sourceval initial_nonce_0 : nonce
Sourceval initial_nonce_hash_0 : Nonce_hash.t

Serializers

Sourcetype seed_status =
  1. | RANDAO_seed
  2. | VDF_seed
OCaml

Innovation. Community. Security.