diff --git a/src/lib_base/chain_id.ml b/src/lib_base/chain_id.ml index a902e5861..eae5d23ac 100644 --- a/src/lib_base/chain_id.ml +++ b/src/lib_base/chain_id.ml @@ -16,8 +16,8 @@ module Raw = struct let extract bh = MBytes.substring (Block_hash.to_bytes bh) 0 4 - let hash_bytes l = extract (Block_hash.hash_bytes l) - let hash_string l = extract (Block_hash.hash_string l) + let hash_bytes ?key l = extract (Block_hash.hash_bytes ?key l) + let hash_string ?key l = extract (Block_hash.hash_string ?key l) let size = 4 diff --git a/src/lib_crypto/blake2B.ml b/src/lib_crypto/blake2B.ml index 19eebf91b..a44cdb2b3 100644 --- a/src/lib_crypto/blake2B.ml +++ b/src/lib_crypto/blake2B.ml @@ -73,13 +73,15 @@ module Make_minimal (K : Name) = struct let read src off = of_bytes_exn @@ MBytes.sub src off size let write dst off h = MBytes.blit (to_bytes h) 0 dst off size - let hash_bytes l = - let state = Blake2b.init size in + let hash_bytes ?key l = + let key = Option.map ~f:Cstruct.of_bigarray key in + let state = Blake2b.init ?key size in List.iter (fun b -> Blake2b.update state (Cstruct.of_bigarray b)) l ; Blake2b.final state - let hash_string l = - let state = Blake2b.init size in + let hash_string ?key l = + let key = Option.map ~f:Cstruct.of_string key in + let state = Blake2b.init ?key size in List.iter (fun s -> Blake2b.update state (Cstruct.of_string s)) l ; Blake2b.final state diff --git a/src/lib_crypto/s.ml b/src/lib_crypto/s.ml index 04ed704f3..1d143b82e 100644 --- a/src/lib_crypto/s.ml +++ b/src/lib_crypto/s.ml @@ -23,8 +23,8 @@ module type MINIMAL_HASH = sig val name: string val title: string - val hash_bytes: Cstruct.buffer list -> t - val hash_string: string list -> t + val hash_bytes: ?key:Cstruct.buffer -> Cstruct.buffer list -> t + val hash_string: ?key:string -> string list -> t val size: int (* in bytes *) val compare: t -> t -> int val equal: t -> t -> bool diff --git a/src/lib_protocol_environment/sigs/v1/s.mli b/src/lib_protocol_environment/sigs/v1/s.mli index 38e6c4505..edc048b43 100644 --- a/src/lib_protocol_environment/sigs/v1/s.mli +++ b/src/lib_protocol_environment/sigs/v1/s.mli @@ -49,8 +49,8 @@ module type MINIMAL_HASH = sig val name: string val title: string - val hash_bytes: MBytes.t list -> t - val hash_string: string list -> t + val hash_bytes: ?key:MBytes.t -> MBytes.t list -> t + val hash_string: ?key:string -> string list -> t val size: int (* in bytes *) val compare: t -> t -> int val equal: t -> t -> bool