+ wip
This commit is contained in:
parent
258db38b52
commit
3c45273308
1 changed files with 38 additions and 36 deletions
74
src/hash.ml
74
src/hash.ml
|
|
@ -8,6 +8,18 @@
|
|||
|
||||
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
|
||||
type t = SHA256.t
|
||||
|
||||
|
|
@ -74,42 +86,32 @@ module H64 = struct
|
|||
end
|
||||
|
||||
(* Hash over string + '\0' *)
|
||||
module H32_cstr = struct
|
||||
include H32
|
||||
module Cstring = struct
|
||||
module H32 = struct
|
||||
include H32
|
||||
|
||||
let hash s =
|
||||
let s = s ^ "\x00" in
|
||||
SHA256.(digest_string s)
|
||||
let hash s =
|
||||
let s = s ^ "\x00" in
|
||||
hash s
|
||||
end
|
||||
|
||||
module H64 = struct
|
||||
include H64
|
||||
|
||||
let hash s =
|
||||
let s = s ^ "\x00" in
|
||||
hash s
|
||||
end
|
||||
end
|
||||
|
||||
module H64_cstr = struct
|
||||
include H64
|
||||
|
||||
let hash s =
|
||||
let s = s ^ "\x00" in
|
||||
SHA512.(digest_string s)
|
||||
end
|
||||
|
||||
module type Hash_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 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
|
||||
module FullPaytoHash : S = H32
|
||||
module NormalizedPaytoHash : S = H32
|
||||
module DenominationHash : S = H64
|
||||
module PrivateContractHash : S = H64
|
||||
module ExtensionsPolicyHash : S = H64
|
||||
module MerchantWireHash : S = H64
|
||||
module AgeCommitmentHash : S = H64
|
||||
module BlindedCoinHash : S = H64
|
||||
module CoinPubHash : S = H64
|
||||
module OutputCommitmentHash : S = H64
|
||||
module HashPlanchetsP : S = H64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue