2018-06-29 14:08:08 +02:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
2018-02-01 17:31:08 +01:00
|
|
|
|
|
|
|
open Client_keys
|
|
|
|
|
2018-05-26 12:37:19 +02:00
|
|
|
let scheme = "unencrypted"
|
2018-02-01 17:31:08 +01:00
|
|
|
|
2018-05-26 12:37:19 +02:00
|
|
|
let title =
|
|
|
|
"Built-in signer using raw unencrypted keys."
|
2018-02-01 22:43:09 +01:00
|
|
|
|
2018-05-26 12:37:19 +02:00
|
|
|
let description =
|
2018-06-16 18:24:30 +02:00
|
|
|
"Please DO NOT USE this signer outside of test environments.\n\
|
|
|
|
Valid secret key URIs are of the form\n\
|
|
|
|
\ - unencrypted:<key>\n\
|
|
|
|
where <key> is the secret key in Base58.\n\
|
|
|
|
Valid public key URIs are of the form\n\
|
|
|
|
\ - unencrypted:<public_key>\n\
|
|
|
|
where <public_key> is the public key in Base58."
|
2018-02-01 22:43:09 +01:00
|
|
|
|
2018-05-26 13:22:47 +02:00
|
|
|
let secret_key sk_uri =
|
|
|
|
Lwt.return
|
|
|
|
(Signature.Secret_key.of_b58check (Uri.path (sk_uri : sk_uri :> Uri.t)))
|
2018-04-12 17:57:08 +02:00
|
|
|
|
2018-05-26 13:22:47 +02:00
|
|
|
let make_sk sk =
|
|
|
|
Client_keys.make_sk_uri
|
|
|
|
(Uri.make ~scheme ~path:(Signature.Secret_key.to_b58check sk) ())
|
2018-02-01 17:31:08 +01:00
|
|
|
|
2018-10-23 21:49:34 -04:00
|
|
|
let public_key ?interactive:(_) pk_uri =
|
2018-05-26 12:37:19 +02:00
|
|
|
Lwt.return
|
2018-05-26 13:22:47 +02:00
|
|
|
(Signature.Public_key.of_b58check (Uri.path (pk_uri : pk_uri :> Uri.t)))
|
2018-02-01 17:31:08 +01:00
|
|
|
|
2018-05-26 13:22:47 +02:00
|
|
|
let make_pk pk =
|
|
|
|
Client_keys.make_pk_uri
|
|
|
|
(Uri.make ~scheme ~path:(Signature.Public_key.to_b58check pk) ())
|
|
|
|
|
|
|
|
let neuterize sk_uri =
|
|
|
|
secret_key sk_uri >>=? fun sk ->
|
|
|
|
return (make_pk (Signature.Secret_key.to_public_key sk))
|
|
|
|
|
2018-10-23 21:49:34 -04:00
|
|
|
let public_key_hash ?interactive pk_uri =
|
|
|
|
public_key ?interactive pk_uri >>=? fun pk ->
|
2018-06-16 20:51:19 +02:00
|
|
|
return (Signature.Public_key.hash pk, Some pk)
|
2018-02-01 17:31:08 +01:00
|
|
|
|
2018-05-26 13:22:47 +02:00
|
|
|
let sign ?watermark sk_uri buf =
|
|
|
|
secret_key sk_uri >>=? fun sk ->
|
|
|
|
return (Signature.sign ?watermark sk buf)
|
2018-10-29 11:56:20 +01:00
|
|
|
|
|
|
|
let deterministic_nonce sk_uri buf =
|
|
|
|
secret_key sk_uri >>=? fun sk ->
|
|
|
|
return (Signature.deterministic_nonce sk buf)
|
|
|
|
|
|
|
|
let deterministic_nonce_hash sk_uri buf =
|
|
|
|
secret_key sk_uri >>=? fun sk ->
|
|
|
|
return (Signature.deterministic_nonce_hash sk buf)
|
2018-12-17 10:07:32 +01:00
|
|
|
|
|
|
|
let supports_deterministic_nonces _ = return_true
|