ligo/src/lib_signer_services/signer_messages.ml

89 lines
2.1 KiB
OCaml
Raw Normal View History

2018-05-22 20:04:37 +04:00
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
module Sign = struct
2018-05-22 20:04:37 +04:00
module Request = struct
2018-05-22 20:04:37 +04:00
type t = {
pkh: Signature.Public_key_hash.t ;
2018-05-22 20:04:37 +04:00
data: MBytes.t ;
}
let encoding =
let open Data_encoding in
conv
(fun { pkh ; data } ->
(pkh, data))
(fun (pkh, data) ->
{ pkh ; data })
2018-05-22 20:04:37 +04:00
(obj2
(req "pkh" Signature.Public_key_hash.encoding)
2018-05-22 20:04:37 +04:00
(req "data" bytes))
2018-05-22 20:04:37 +04:00
end
module Response = struct
type t = Signature.t
2018-05-22 20:04:37 +04:00
let encoding =
Data_encoding.(obj1 (req "signature" Signature.encoding))
2018-05-22 20:04:37 +04:00
end
2018-05-22 20:04:37 +04:00
end
module Public_key = struct
2018-05-22 20:04:37 +04:00
module Request = struct
type t = Signature.Public_key_hash.t
2018-05-22 20:04:37 +04:00
let encoding =
Data_encoding.(obj1 (req "pkh" Signature.Public_key_hash.encoding))
2018-05-22 20:04:37 +04:00
end
module Response = struct
type t = Signature.Public_key.t
2018-05-22 20:04:37 +04:00
let encoding =
Data_encoding.(obj1 (req "pubkey" Signature.Public_key.encoding))
2018-05-22 20:04:37 +04:00
end
2018-05-22 20:04:37 +04:00
end
module Request = struct
2018-05-22 20:04:37 +04:00
type t =
| Sign of Sign.Request.t
| Public_key of Public_key.Request.t
let encoding =
let open Data_encoding in
union [
case (Tag 0)
(merge_objs
(obj1 (req "kind" (constant "sign")))
Sign.Request.encoding)
(function Sign req -> Some ((), req) | _ -> None)
(fun ((), req) -> Sign req) ;
case (Tag 1)
(merge_objs
(obj1 (req "kind" (constant "public_key")))
Public_key.Request.encoding)
(function Public_key req -> Some ((), req) | _ -> None)
(fun ((), req) -> Public_key req) ;
]
2018-05-22 20:04:37 +04:00
end