Alpha: add Seed_repr.deterministic_seed
This commit is contained in:
parent
0ad4f8f6e6
commit
46d053fdb3
@ -91,12 +91,13 @@ let check_hash nonce hash =
|
|||||||
|
|
||||||
let nonce_hash_key_part = Nonce_hash.to_path
|
let nonce_hash_key_part = Nonce_hash.to_path
|
||||||
|
|
||||||
let initial_nonce_0 =
|
let initial_nonce_0 = zero_bytes
|
||||||
MBytes.of_string (String.make Constants_repr.nonce_length '\000')
|
|
||||||
|
|
||||||
let initial_nonce_hash_0 =
|
let initial_nonce_hash_0 =
|
||||||
hash initial_nonce_0
|
hash initial_nonce_0
|
||||||
|
|
||||||
|
let deterministic_seed seed = nonce seed zero_bytes
|
||||||
|
|
||||||
let initial_seeds n =
|
let initial_seeds n =
|
||||||
let rec loop acc elt i =
|
let rec loop acc elt i =
|
||||||
if Compare.Int.(i = 1) then
|
if Compare.Int.(i = 1) then
|
||||||
@ -104,7 +105,6 @@ let initial_seeds n =
|
|||||||
else
|
else
|
||||||
loop
|
loop
|
||||||
(elt :: acc)
|
(elt :: acc)
|
||||||
(nonce elt
|
(deterministic_seed elt)
|
||||||
(MBytes.of_string (String.make Constants_repr.nonce_length '\000')))
|
|
||||||
(i-1) in
|
(i-1) in
|
||||||
loop [] (B (State_hash.hash_bytes [])) n
|
loop [] (B (State_hash.hash_bytes [])) n
|
||||||
|
@ -44,6 +44,9 @@ val take_int32 : sequence -> int32 -> int32 * sequence
|
|||||||
|
|
||||||
val empty : seed
|
val empty : seed
|
||||||
|
|
||||||
|
(** Returns a new seed by hashing the one passed with a constant. *)
|
||||||
|
val deterministic_seed : seed -> seed
|
||||||
|
|
||||||
(** [intial_seeds n] generates the first [n] seeds for which there are no nonces.
|
(** [intial_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)
|
The first seed is a constant value. The kth seed is the hash of seed (k-1)
|
||||||
concatenated with a constant. *)
|
concatenated with a constant. *)
|
||||||
|
Loading…
Reference in New Issue
Block a user