This commit is contained in:
parent
258db38b52
commit
d2a0ff93dc
1 changed files with 38 additions and 36 deletions
56
src/hash.ml
56
src/hash.ml
|
|
@ -8,6 +8,18 @@
|
||||||
|
|
||||||
open Digestif
|
open Digestif
|
||||||
|
|
||||||
|
module type S = sig
|
||||||
|
type t
|
||||||
|
|
||||||
|
val bin : t Bin.t
|
||||||
|
val caqti : t Caqti_type.t
|
||||||
|
val jsont : t Jsont.t
|
||||||
|
val hash : string -> t
|
||||||
|
val of_octets : string -> t
|
||||||
|
val to_octets : t -> string
|
||||||
|
val of_b32 : B32.t -> (t, string) result
|
||||||
|
end
|
||||||
|
|
||||||
module H32 = struct
|
module H32 = struct
|
||||||
type t = SHA256.t
|
type t = SHA256.t
|
||||||
|
|
||||||
|
|
@ -74,42 +86,32 @@ module H64 = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
(* Hash over string + '\0' *)
|
(* Hash over string + '\0' *)
|
||||||
module H32_cstr = struct
|
module Cstring = struct
|
||||||
|
module H32 = struct
|
||||||
include H32
|
include H32
|
||||||
|
|
||||||
let hash s =
|
let hash s =
|
||||||
let s = s ^ "\x00" in
|
let s = s ^ "\x00" in
|
||||||
SHA256.(digest_string s)
|
hash s
|
||||||
end
|
end
|
||||||
|
|
||||||
module H64_cstr = struct
|
module H64 = struct
|
||||||
include H64
|
include H64
|
||||||
|
|
||||||
let hash s =
|
let hash s =
|
||||||
let s = s ^ "\x00" in
|
let s = s ^ "\x00" in
|
||||||
SHA512.(digest_string s)
|
hash s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module type Hash_S = sig
|
module FullPaytoHash : S = H32
|
||||||
type t
|
module NormalizedPaytoHash : S = H32
|
||||||
|
module DenominationHash : S = H64
|
||||||
val bin : t Bin.t
|
module PrivateContractHash : S = H64
|
||||||
val caqti : t Caqti_type.t
|
module ExtensionsPolicyHash : S = H64
|
||||||
val jsont : t Jsont.t
|
module MerchantWireHash : S = H64
|
||||||
val hash : string -> t
|
module AgeCommitmentHash : S = H64
|
||||||
val of_octets : string -> t
|
module BlindedCoinHash : S = H64
|
||||||
val to_octets : t -> string
|
module CoinPubHash : S = H64
|
||||||
val of_b32 : B32.t -> (t, string) result
|
module OutputCommitmentHash : S = H64
|
||||||
end
|
module HashPlanchetsP : S = H64
|
||||||
|
|
||||||
module FullPaytoHash : Hash_S = H32
|
|
||||||
module NormalizedPaytoHash : Hash_S = H32
|
|
||||||
module DenominationHash : Hash_S = H64
|
|
||||||
module PrivateContractHash : Hash_S = H64
|
|
||||||
module ExtensionsPolicyHash : Hash_S = H64
|
|
||||||
module MerchantWireHash : Hash_S = H64
|
|
||||||
module AgeCommitmentHash : Hash_S = H64
|
|
||||||
module BlindedCoinHash : Hash_S = H64
|
|
||||||
module CoinPubHash : Hash_S = H64
|
|
||||||
module OutputCommitmentHash : Hash_S = H64
|
|
||||||
module HashPlanchetsP : Hash_S = H64
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue