Module Webs_authenticatable.Private_key

Private keys.

type crypto_random = int -> string

The type for cryptographically secure random bytes generation. Calling the function with n must return n cryptographically secure random bytes.

type t = [
  1. | `Hs256 of string
    (*

    Used with HMAC-SHA-256, hence should be at least 32 bytes.

    *)
]

The type for private keys. This defines both a key and a correspoding authentification scheme.

val random_hs256 : ?crypto_random:crypto_random -> unit -> t

random_hs256 () are 64 random bytes sourced from the generator crypto_rantom (defaults to Webs_cryptorand.get_random).

val to_ascii_string : t -> string

to_ascii_string k encodes k to an URL safe US-ASCII scheme that can be read back by of_ascii_string.

val of_ascii_string : string -> (t, string) Stdlib.result

of_ascii_string s reads back the encoding of to_ascii_string.