Vendors/ledgerwallet: curve parsers and pretty-printers

This commit is contained in:
Vincent Bernardoff 2018-10-04 19:34:51 +08:00 committed by Benjamin Canou
parent 0b7155ca91
commit 50f367e27b
No known key found for this signature in database
GPG Key ID: 73607948459DC5F8
2 changed files with 21 additions and 0 deletions

View File

@ -82,6 +82,23 @@ type curve =
| Secp256k1
| Secp256r1
let pp_curve ppf = function
| Ed25519 -> Format.pp_print_string ppf "ed25519"
| Secp256k1 -> Format.pp_print_string ppf "secp256k1"
| Secp256r1 -> Format.pp_print_string ppf "P-256"
let pp_curve_short ppf = function
| Ed25519 -> Format.pp_print_string ppf "ed"
| Secp256k1 -> Format.pp_print_string ppf "secp"
| Secp256r1 -> Format.pp_print_string ppf "p2"
let curve_of_string str =
match String.lowercase_ascii str with
| "ed" | "ed25519" -> Some Ed25519
| "secp256k1" -> Some Secp256k1
| "p256" | "p-256" | "secp256r1" -> Some Secp256r1
| _ -> None
let int_of_curve = function
| Ed25519 -> 0x00
| Secp256k1 -> 0x01

View File

@ -26,6 +26,10 @@ type curve =
| Secp256k1
| Secp256r1
val curve_of_string : string -> curve option
val pp_curve : Format.formatter -> curve -> unit
val pp_curve_short : Format.formatter -> curve -> unit
val get_version :
?pp:Format.formatter -> ?buf:Cstruct.t ->
Hidapi.t -> (Version.t, Transport.error) result