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-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
module Request = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
type t = {
|
2018-05-26 14:51:51 +04:00
|
|
|
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
|
2018-05-26 14:51:51 +04:00
|
|
|
(fun { pkh ; data } ->
|
|
|
|
(pkh, data))
|
|
|
|
(fun (pkh, data) ->
|
|
|
|
{ pkh ; data })
|
2018-05-22 20:04:37 +04:00
|
|
|
(obj2
|
2018-05-26 14:51:51 +04:00
|
|
|
(req "pkh" Signature.Public_key_hash.encoding)
|
2018-05-22 20:04:37 +04:00
|
|
|
(req "data" bytes))
|
2018-05-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Response = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
|
|
|
type t = Signature.t
|
2018-05-22 20:04:37 +04:00
|
|
|
|
|
|
|
let encoding =
|
2018-05-26 14:51:51 +04:00
|
|
|
Data_encoding.(obj1 (req "signature" Signature.encoding))
|
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
2018-05-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Public_key = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
module Request = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
|
|
|
type t = Signature.Public_key_hash.t
|
2018-05-22 20:04:37 +04:00
|
|
|
|
|
|
|
let encoding =
|
2018-05-26 14:51:51 +04:00
|
|
|
Data_encoding.(obj1 (req "pkh" Signature.Public_key_hash.encoding))
|
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Response = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
|
|
|
type t = Signature.Public_key.t
|
2018-05-22 20:04:37 +04:00
|
|
|
|
|
|
|
let encoding =
|
2018-05-26 14:51:51 +04:00
|
|
|
Data_encoding.(obj1 (req "pubkey" Signature.Public_key.encoding))
|
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
2018-05-26 14:51:51 +04:00
|
|
|
|
2018-05-22 20:04:37 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Request = struct
|
2018-05-26 14:51:51 +04:00
|
|
|
|
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
|
2018-05-26 14:51:51 +04:00
|
|
|
union [
|
|
|
|
case (Tag 0)
|
2018-06-01 01:19:43 +04:00
|
|
|
~title:"Sign"
|
2018-05-26 14:51:51 +04:00
|
|
|
(merge_objs
|
|
|
|
(obj1 (req "kind" (constant "sign")))
|
|
|
|
Sign.Request.encoding)
|
|
|
|
(function Sign req -> Some ((), req) | _ -> None)
|
|
|
|
(fun ((), req) -> Sign req) ;
|
|
|
|
case (Tag 1)
|
2018-06-01 01:19:43 +04:00
|
|
|
~title:"Public_key"
|
2018-05-26 14:51:51 +04:00
|
|
|
(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
|