2018-05-26 14:03:12 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
let log = Logging.Client.Sign.lwt_log_notice
|
|
|
|
|
2018-05-26 14:51:51 +04:00
|
|
|
let sign (cctxt : #Client_context.wallet) pkh data =
|
|
|
|
log "Request for signing %d bytes of data for key %a, magic byte = %02X"
|
2018-05-26 14:03:12 +04:00
|
|
|
(MBytes.length data)
|
2018-05-26 14:51:51 +04:00
|
|
|
Signature.Public_key_hash.pp pkh
|
2018-05-26 14:03:12 +04:00
|
|
|
(MBytes.get_uint8 data 0) >>= fun () ->
|
2018-05-26 14:51:51 +04:00
|
|
|
Client_keys.get_key cctxt pkh >>=? fun (name, _pkh, sk_uri) ->
|
|
|
|
log "Signing data for key %s" name >>= fun () ->
|
|
|
|
Client_keys.sign cctxt sk_uri data >>=? fun signature ->
|
|
|
|
return signature
|
2018-05-26 14:03:12 +04:00
|
|
|
|
2018-05-26 14:51:51 +04:00
|
|
|
let public_key (cctxt : #Client_context.wallet) pkh =
|
|
|
|
log "Request for public key %a"
|
|
|
|
Signature.Public_key_hash.pp pkh >>= fun () ->
|
|
|
|
Client_keys.get_public_key cctxt pkh >>=? fun (name, pk) ->
|
|
|
|
log "Found public key for hash %a (name: %s)"
|
|
|
|
Signature.Public_key_hash.pp pkh name >>= fun () ->
|
|
|
|
return pk
|