add secmod sign_with_xx

This commit is contained in:
swrup 2025-12-16 14:20:41 +01:00
parent f69f393abb
commit d2282cd135
6 changed files with 93 additions and 45 deletions

View file

@ -75,7 +75,9 @@ module EddsaSignature : sig
type t
val sign : key:EddsaPrivateKey.t -> string -> t
val verify : key:EddsaPublicKey.t -> t -> msg:string -> bool
(* Ok () on verification success *)
val verify : key:EddsaPublicKey.t -> t -> msg:string -> (unit, string) result
val to_octets : t -> string
val of_octets : string -> (t, string) result
val jsont : t Jsont.t
@ -90,7 +92,13 @@ end = struct
(* mirage_crypto: "The result is the concatenation of r and s, as specified in RFC 8032." *)
let sign ~key s = Mirage_crypto_ec.Ed25519.sign ~key s
let verify ~key s ~msg = Mirage_crypto_ec.Ed25519.verify ~key s ~msg
let verify ~key s ~msg =
let b = Mirage_crypto_ec.Ed25519.verify ~key s ~msg in
match b with
| false -> Error "signature verification failure: invalid signature"
| true -> Ok ()
let to_octets t = t
let of_octets v =