From 72a4321b4eb0f94cdb61f91c452f1dce8f594e57 Mon Sep 17 00:00:00 2001 From: swrup Date: Sun, 7 Dec 2025 07:26:34 +0100 Subject: [PATCH] --- src/b32.ml | 4 +++- src/crypto.ml | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/b32.ml b/src/b32.ml index e22af9b8..29e73239 100644 --- a/src/b32.ml +++ b/src/b32.ml @@ -23,4 +23,6 @@ let decode s = | c -> c) s in - Base32.decode ~alphabet ~off:0 ~len:(String.length s) s + match Base32.decode ~alphabet ~off:0 ~len:(String.length s) s with + | Error (`Msg e) -> Error e + | Ok v -> Ok v diff --git a/src/crypto.ml b/src/crypto.ml index 29f85403..e7874606 100644 --- a/src/crypto.ml +++ b/src/crypto.ml @@ -25,7 +25,10 @@ module EddsaPublicKey = struct let of_b32 s = let open Syntax in let* octets = B32.decode s in - let* pub = of_octets octets in + let* pub = + of_octets octets + |> Result.map_error (fun e -> Fmt.str "%a" Mirage_crypto_ec.pp_error e) + in Ok pub let to_b32 t = B32.encode (to_octets t) @@ -61,8 +64,6 @@ module EddsaSignature : sig val sign : key:EddsaPrivateKey.t -> string -> t val verify : key:EddsaPublicKey.t -> t -> msg:string -> bool - val of_b32 : string -> (t, string) result - val to_b32 : t -> string val to_octets : t -> string val of_octets : string -> t val jsont : t Jsont.t @@ -145,8 +146,6 @@ module RsaSignature : sig val to_octets : t -> string val sign : key:Mirage_crypto_pk.Rsa.priv -> string -> t - val of_b32 : string -> (t, string) result - val to_b32 : t -> string val jsont : t Jsont.t end = struct type t = string