aboutsummaryrefslogtreecommitdiffstats
path: root/lib/concepts/Hash.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/concepts/Hash.ml7
-rw-r--r--lib/concepts/Hash.mli8
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/concepts/Hash.ml b/lib/concepts/Hash.ml
index aac7428..ae0a178 100644
--- a/lib/concepts/Hash.ml
+++ b/lib/concepts/Hash.ml
@@ -7,17 +7,16 @@ let size = 256/8
let compare h1 h2 = Digestif.SHA256.unsafe_compare h1 h2
|> Ordering.of_int
-let hash_of_value (v : Value.value) =
- Representation.(blob_of_value v |> bytes_of_blob) |> Digestif.SHA256.digest_bytes
-
let hash_of_bytes bytes = Digestif.SHA256.digest_bytes bytes
-let hash_of_blob blob = Representation.bytes_of_blob blob |> Digestif.SHA256.digest_bytes
+let hash_of_blob blob = Blob.bytes_of_blob blob |> Digestif.SHA256.digest_bytes
let to_raw_string hash = Digestif.SHA256.to_raw_string hash
let of_raw_string str = Digestif.SHA256.of_raw_string str
+let to_hum_string hash = Digestif.SHA256.to_hex hash
+
let hash_equals = Digestif.SHA256.equal
let bytes_of_hash (h : hash) = Bytes.of_string (Digestif.SHA256.to_raw_string h)
diff --git a/lib/concepts/Hash.mli b/lib/concepts/Hash.mli
index 44fb3d0..b3ae2dc 100644
--- a/lib/concepts/Hash.mli
+++ b/lib/concepts/Hash.mli
@@ -4,14 +4,11 @@ type hash
(** the size of a hash, in bytes *)
val size : int
-(** given a value, compute it's hash *)
-val hash_of_value : Value.value -> hash
-
(** given a bag of bytes, compute it's hash *)
val hash_of_bytes : bytes -> hash
(** given a blob, compute it's hash *)
-val hash_of_blob : Representation.blob -> hash
+val hash_of_blob : Blob.t -> hash
(** given a hash, return a representation of it as a string (/not/ the usual hex representation!) *)
val to_raw_string : hash -> string
@@ -19,6 +16,9 @@ val to_raw_string : hash -> string
(** given a string containing a representation of a hash (as per `to_raw_string`), return the corresponding hash *)
val of_raw_string : string -> hash
+(** given a hash, return a representation of it as a string suitable for being displayed to humans *)
+val to_hum_string : hash -> string
+
(** compare two hashes lexicographically *)
val compare : hash -> hash -> Ordering.ordering