2018-02-01 17:31:08 +01:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-05 21:17:03 +01:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2018-02-01 17:31:08 +01:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open Client_keys
|
|
|
|
|
|
|
|
module Unencrypted_signer : SIGNER = struct
|
|
|
|
let scheme = "unencrypted"
|
|
|
|
|
2018-02-01 22:43:09 +01:00
|
|
|
let title =
|
|
|
|
"Built-in signer using raw unencrypted keys."
|
|
|
|
|
|
|
|
let description =
|
2018-02-16 01:26:24 +01:00
|
|
|
"Do not use this signer except for playing on the test chain.\n\
|
2018-02-01 22:43:09 +01:00
|
|
|
The format for importing secret keys is either no argument (will \
|
|
|
|
generate a key) or the raw Base58-encoded key (starting with \
|
|
|
|
'edsk').\n\
|
|
|
|
The format for importing public keys is the raw Base58-encoded \
|
|
|
|
key (starting with 'edpk')."
|
|
|
|
|
2018-04-05 17:35:35 +02:00
|
|
|
type secret_key = Signature.Secret_key.t
|
|
|
|
type public_key = Signature.Public_key.t
|
2018-02-01 17:31:08 +01:00
|
|
|
|
2018-02-08 19:00:01 +01:00
|
|
|
let init _wallet = return ()
|
|
|
|
|
2018-02-01 17:31:08 +01:00
|
|
|
let sk_locator_of_human_input _cctxt = function
|
|
|
|
| sk :: _ ->
|
|
|
|
return (Secret_key_locator.create ~scheme ~location:sk)
|
|
|
|
| [] ->
|
|
|
|
let _, _, sk = Ed25519.generate_key () in
|
|
|
|
return (Secret_key_locator.create ~scheme
|
|
|
|
~location:(Ed25519.Secret_key.to_b58check sk))
|
|
|
|
|
|
|
|
let pk_locator_of_human_input _cctxt = function
|
|
|
|
| [] -> failwith "Missing public key argument"
|
|
|
|
| pk :: _ -> return (Public_key_locator.create ~scheme ~location:pk)
|
|
|
|
|
|
|
|
let sk_of_locator (Sk_locator { location }) =
|
2018-04-05 17:35:35 +02:00
|
|
|
Lwt.return (Signature.Secret_key.of_b58check location)
|
2018-02-01 17:31:08 +01:00
|
|
|
|
|
|
|
let pk_of_locator (Pk_locator { location }) =
|
2018-04-05 17:35:35 +02:00
|
|
|
Lwt.return (Signature.Public_key.of_b58check location)
|
2018-02-01 17:31:08 +01:00
|
|
|
|
|
|
|
let sk_to_locator sk =
|
|
|
|
Secret_key_locator.create
|
2018-04-05 17:35:35 +02:00
|
|
|
~scheme ~location:(Signature.Secret_key.to_b58check sk) |>
|
2018-02-01 17:31:08 +01:00
|
|
|
Lwt.return
|
|
|
|
|
|
|
|
let pk_to_locator pk =
|
|
|
|
Public_key_locator.create
|
2018-04-05 17:35:35 +02:00
|
|
|
~scheme ~location:(Signature.Public_key.to_b58check pk) |>
|
2018-02-01 17:31:08 +01:00
|
|
|
Lwt.return
|
|
|
|
|
2018-04-05 17:35:35 +02:00
|
|
|
let neuterize x = Lwt.return (Signature.Secret_key.to_public_key x)
|
2018-02-01 17:31:08 +01:00
|
|
|
let public_key x = Lwt.return x
|
2018-04-05 17:35:35 +02:00
|
|
|
let public_key_hash x = Lwt.return (Signature.Public_key.hash x)
|
|
|
|
let sign t buf = return (Signature.sign t buf)
|
2018-02-01 17:31:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
let () =
|
|
|
|
register_signer (module Unencrypted_signer)
|