This commit is contained in:
parent
1674e338ac
commit
985a87ebfa
4 changed files with 20 additions and 11 deletions
15
src/types.ml
15
src/types.ml
|
|
@ -84,13 +84,18 @@ end = struct
|
|||
(* mirage_crypto: "The result is the concatenation of r and s, as specified in RFC 8032." *)
|
||||
Mirage_crypto_ec.Ed25519.sign ~key s
|
||||
|
||||
let of_b32 s = B32.decode s
|
||||
let check_size t =
|
||||
match String.length t = 64 with
|
||||
| false -> Error "EddsaSignature: invalid string length"
|
||||
| true -> Ok ()
|
||||
|
||||
let to_b32 t =
|
||||
let s = B32.encode t in
|
||||
assert (String.length s = 64);
|
||||
s
|
||||
let of_b32 s =
|
||||
let open Syntax in
|
||||
let* t = B32.decode s in
|
||||
let+ () = check_size t in
|
||||
t
|
||||
|
||||
let to_b32 = B32.encode
|
||||
let jsont = Jsont.of_of_string ~kind:"EddsaSignature" of_b32 ~enc:to_b32
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue