2017-11-27 09:13:12 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2017-11-27 09:13:12 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
(** Tezos - Ed25519 cryptography *)
|
|
|
|
|
2018-04-03 13:44:11 +04:00
|
|
|
open Error_monad
|
|
|
|
|
2017-11-27 09:13:12 +04:00
|
|
|
(** {2 Hashed public keys for user ID} ***************************************)
|
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
module Public_key_hash : S.HASH
|
2017-11-27 09:13:12 +04:00
|
|
|
|
|
|
|
(** {2 Signature} ************************************************************)
|
|
|
|
|
|
|
|
module Public_key : sig
|
|
|
|
|
|
|
|
include Compare.S
|
2018-02-01 20:31:08 +04:00
|
|
|
val pp : Format.formatter -> t -> unit
|
2017-11-27 09:13:12 +04:00
|
|
|
|
|
|
|
val hash: t -> Public_key_hash.t
|
|
|
|
|
|
|
|
type Base58.data +=
|
|
|
|
| Public_key of t
|
|
|
|
|
|
|
|
val of_b58check_exn: string -> t
|
|
|
|
val of_b58check_opt: string -> t option
|
2018-04-03 13:44:11 +04:00
|
|
|
val of_b58check: string -> t tzresult
|
2017-11-27 09:13:12 +04:00
|
|
|
val to_b58check: t -> string
|
|
|
|
|
2018-01-15 18:03:13 +04:00
|
|
|
val to_hex: t -> Hex.t
|
|
|
|
val of_hex: Hex.t -> t option
|
|
|
|
val of_hex_exn: Hex.t -> t
|
|
|
|
|
2018-01-09 16:21:01 +04:00
|
|
|
val of_bytes_exn: MBytes.t -> t
|
|
|
|
val of_bytes_opt: MBytes.t -> t option
|
|
|
|
val to_bytes: t -> MBytes.t
|
2017-11-27 09:13:12 +04:00
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
val size: int
|
|
|
|
|
2018-04-03 13:44:11 +04:00
|
|
|
val encoding: t Data_encoding.t
|
|
|
|
val param:
|
|
|
|
?name:string ->
|
|
|
|
?desc:string ->
|
|
|
|
('a, 'b) Clic.params ->
|
|
|
|
(t -> 'a, 'b) Clic.params
|
|
|
|
|
2017-11-27 09:13:12 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Secret_key : sig
|
|
|
|
|
|
|
|
type t
|
2018-02-01 20:31:08 +04:00
|
|
|
val pp : Format.formatter -> t -> unit
|
2017-11-27 09:13:12 +04:00
|
|
|
|
|
|
|
val to_public_key: t -> Public_key.t
|
|
|
|
|
|
|
|
type Base58.data +=
|
|
|
|
| Secret_key of t
|
|
|
|
|
|
|
|
val of_b58check_exn: string -> t
|
|
|
|
val of_b58check_opt: string -> t option
|
2018-04-03 13:44:11 +04:00
|
|
|
val of_b58check: string -> t tzresult
|
2017-11-27 09:13:12 +04:00
|
|
|
val to_b58check: t -> string
|
|
|
|
|
2018-01-09 16:21:01 +04:00
|
|
|
val of_bytes_exn: MBytes.t -> t
|
|
|
|
val of_bytes_opt: MBytes.t -> t option
|
|
|
|
val to_bytes: t -> MBytes.t
|
2017-11-27 09:13:12 +04:00
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
val size: int
|
|
|
|
|
2018-04-03 13:44:11 +04:00
|
|
|
val encoding: t Data_encoding.t
|
|
|
|
val param:
|
|
|
|
?name:string ->
|
|
|
|
?desc:string ->
|
|
|
|
('a, 'b) Clic.params ->
|
|
|
|
(t -> 'a, 'b) Clic.params
|
|
|
|
|
2017-11-27 09:13:12 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Signature : sig
|
|
|
|
|
|
|
|
type t
|
2018-02-01 20:31:08 +04:00
|
|
|
val pp : Format.formatter -> t -> unit
|
2017-11-27 09:13:12 +04:00
|
|
|
|
|
|
|
type Base58.data +=
|
|
|
|
| Signature of t
|
|
|
|
|
|
|
|
val of_b58check_exn: string -> t
|
|
|
|
val of_b58check_opt: string -> t option
|
2018-04-03 13:44:11 +04:00
|
|
|
val of_b58check: string -> t tzresult
|
2017-11-27 09:13:12 +04:00
|
|
|
val to_b58check: t -> string
|
|
|
|
|
2018-01-09 16:21:01 +04:00
|
|
|
val of_bytes_exn: MBytes.t -> t
|
|
|
|
val of_bytes_opt: MBytes.t -> t option
|
|
|
|
val to_bytes: t -> MBytes.t
|
2017-11-27 09:13:12 +04:00
|
|
|
|
2018-04-03 13:44:11 +04:00
|
|
|
val encoding: t Data_encoding.t
|
|
|
|
val param:
|
|
|
|
?name:string ->
|
|
|
|
?desc:string ->
|
|
|
|
('a, 'b) Clic.params ->
|
|
|
|
(t -> 'a, 'b) Clic.params
|
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
val size: int
|
|
|
|
|
2018-02-24 01:12:03 +04:00
|
|
|
val zero: t
|
|
|
|
|
2018-02-04 21:39:34 +04:00
|
|
|
(** Check a signature *)
|
2017-11-27 09:13:12 +04:00
|
|
|
val check: Public_key.t -> t -> MBytes.t -> bool
|
|
|
|
|
|
|
|
(** Append a signature *)
|
|
|
|
val append: Secret_key.t -> MBytes.t -> MBytes.t
|
|
|
|
val concat: MBytes.t -> t -> MBytes.t
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
module Seed : sig
|
|
|
|
type t
|
|
|
|
val generate : unit -> t
|
|
|
|
val extract : Secret_key.t -> t
|
|
|
|
end
|
|
|
|
|
|
|
|
val sign: Secret_key.t -> MBytes.t -> Signature.t
|
|
|
|
|
|
|
|
val generate_key: unit -> (Public_key_hash.t * Public_key.t * Secret_key.t)
|
|
|
|
val generate_seeded_key: Seed.t -> (Public_key_hash.t * Public_key.t * Secret_key.t)
|
|
|
|
|