2018-10-22 17:30:02 -07:00
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package signrpc;
|
|
|
|
|
2018-12-11 11:42:43 +01:00
|
|
|
option go_package = "github.com/lightningnetwork/lnd/lnrpc/signrpc";
|
|
|
|
|
2020-05-06 16:41:47 +02:00
|
|
|
// Signer is a service that gives access to the signing functionality of the
|
|
|
|
// daemon's wallet.
|
|
|
|
service Signer {
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-05-06 16:41:47 +02:00
|
|
|
SignOutputRaw is a method that can be used to generated a signature for a
|
|
|
|
set of inputs/outputs to a transaction. Each request specifies details
|
|
|
|
concerning how the outputs should be signed, which keys they should be
|
|
|
|
signed with, and also any optional tweaks. The return value is a fixed
|
|
|
|
64-byte signature (the same format as we use on the wire in Lightning).
|
|
|
|
|
|
|
|
If we are unable to sign using the specified keys, then an error will be
|
|
|
|
returned.
|
|
|
|
*/
|
|
|
|
rpc SignOutputRaw (SignReq) returns (SignResp);
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-05-06 16:41:47 +02:00
|
|
|
ComputeInputScript generates a complete InputIndex for the passed
|
|
|
|
transaction with the signature as defined within the passed SignDescriptor.
|
|
|
|
This method should be capable of generating the proper input script for
|
|
|
|
both regular p2wkh output and p2wkh outputs nested within a regular p2sh
|
|
|
|
output.
|
|
|
|
|
|
|
|
Note that when using this method to sign inputs belonging to the wallet,
|
|
|
|
the only items of the SignDescriptor that need to be populated are pkScript
|
|
|
|
in the TxOut field, the value in that same field, and finally the input
|
|
|
|
index.
|
|
|
|
*/
|
|
|
|
rpc ComputeInputScript (SignReq) returns (InputScriptResp);
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-05-06 16:41:47 +02:00
|
|
|
SignMessage signs a message with the key specified in the key locator. The
|
|
|
|
returned signature is fixed-size LN wire format encoded.
|
|
|
|
|
|
|
|
The main difference to SignMessage in the main RPC is that a specific key is
|
|
|
|
used to sign the message instead of the node identity private key.
|
|
|
|
*/
|
|
|
|
rpc SignMessage (SignMessageReq) returns (SignMessageResp);
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-05-06 16:41:47 +02:00
|
|
|
VerifyMessage verifies a signature over a message using the public key
|
|
|
|
provided. The signature must be fixed-size LN wire format encoded.
|
|
|
|
|
|
|
|
The main difference to VerifyMessage in the main RPC is that the public key
|
|
|
|
used to sign the message does not have to be a node known to the network.
|
|
|
|
*/
|
|
|
|
rpc VerifyMessage (VerifyMessageReq) returns (VerifyMessageResp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key
|
|
|
|
derivation between the ephemeral public key in the request and the node's
|
2020-07-28 05:39:12 +08:00
|
|
|
key specified in the key_desc parameter. Either a key locator or a raw
|
|
|
|
public key is expected in the key_desc, if neither is supplied, defaults to
|
|
|
|
the node's identity private key:
|
2020-05-06 16:41:47 +02:00
|
|
|
P_shared = privKeyNode * ephemeralPubkey
|
|
|
|
The resulting shared public key is serialized in the compressed format and
|
|
|
|
hashed with sha256, resulting in the final key length of 256bit.
|
|
|
|
*/
|
|
|
|
rpc DeriveSharedKey (SharedKeyRequest) returns (SharedKeyResponse);
|
|
|
|
}
|
|
|
|
|
2018-10-22 17:30:02 -07:00
|
|
|
message KeyLocator {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The family of key being identified.
|
2018-10-22 17:30:02 -07:00
|
|
|
int32 key_family = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
// The precise index of the key being identified.
|
2018-10-22 17:30:02 -07:00
|
|
|
int32 key_index = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message KeyDescriptor {
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2021-11-01 08:37:42 -05:00
|
|
|
The raw bytes of the public key in the key pair being identified. Either
|
|
|
|
this or the KeyLocator must be specified.
|
2019-12-10 09:48:49 +01:00
|
|
|
*/
|
|
|
|
bytes raw_key_bytes = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2021-11-01 08:37:42 -05:00
|
|
|
The key locator that identifies which private key to use for signing.
|
|
|
|
Either this or the raw bytes of the target public key must be specified.
|
2019-12-10 09:48:49 +01:00
|
|
|
*/
|
|
|
|
KeyLocator key_loc = 2;
|
2018-10-22 17:30:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
message TxOut {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The value of the output being spent.
|
2018-10-22 17:30:02 -07:00
|
|
|
int64 value = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
// The script of the output being spent.
|
2018-10-22 17:30:02 -07:00
|
|
|
bytes pk_script = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message SignDescriptor {
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
A descriptor that precisely describes *which* key to use for signing. This
|
|
|
|
may provide the raw public key directly, or require the Signer to re-derive
|
|
|
|
the key according to the populated derivation path.
|
2020-06-04 17:44:25 -07:00
|
|
|
|
|
|
|
Note that if the key descriptor was obtained through walletrpc.DeriveKey,
|
|
|
|
then the key locator MUST always be provided, since the derived keys are not
|
|
|
|
persisted unlike with DeriveNextKey.
|
2018-10-22 17:30:02 -07:00
|
|
|
*/
|
|
|
|
KeyDescriptor key_desc = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
A scalar value that will be added to the private key corresponding to the
|
|
|
|
above public key to obtain the private key to be used to sign this input.
|
|
|
|
This value is typically derived via the following computation:
|
|
|
|
|
|
|
|
* derivedKey = privkey + sha256(perCommitmentPoint || pubKey) mod N
|
|
|
|
*/
|
|
|
|
bytes single_tweak = 2;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
A private key that will be used in combination with its corresponding
|
|
|
|
private key to derive the private key that is to be used to sign the target
|
|
|
|
input. Within the Lightning protocol, this value is typically the
|
|
|
|
commitment secret from a previously revoked commitment transaction. This
|
|
|
|
value is in combination with two hash values, and the original private key
|
|
|
|
to derive the private key to be used when signing.
|
2020-03-02 15:35:25 +01:00
|
|
|
|
2018-10-22 17:30:02 -07:00
|
|
|
* k = (privKey*sha256(pubKey || tweakPub) +
|
|
|
|
tweakPriv*sha256(tweakPub || pubKey)) mod N
|
|
|
|
*/
|
|
|
|
bytes double_tweak = 3;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2022-03-18 18:37:51 +01:00
|
|
|
The full script required to properly redeem the output. This field will
|
|
|
|
only be populated if a p2tr, p2wsh or a p2sh output is being signed. In case
|
|
|
|
taproot_key_spend is set to true then this value must correspond to the
|
|
|
|
taproot root hash (in case of a tapscript output) or the tap hashed internal
|
|
|
|
public key (in case of a BIP-0086 output).
|
2018-10-22 17:30:02 -07:00
|
|
|
*/
|
|
|
|
bytes witness_script = 4;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-03-02 15:35:25 +01:00
|
|
|
A description of the output being spent. The value and script MUST be
|
|
|
|
provided.
|
2018-10-22 17:30:02 -07:00
|
|
|
*/
|
|
|
|
TxOut output = 5;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
The target sighash type that should be used when generating the final
|
|
|
|
sighash, and signature.
|
|
|
|
*/
|
|
|
|
uint32 sighash = 7;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
The target input within the transaction that should be signed.
|
|
|
|
*/
|
|
|
|
int32 input_index = 8;
|
2022-03-18 18:37:51 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Indicates that this should produce a signature that can be used for the key
|
|
|
|
spend path of a taproot input. This requires the witness_script field to be
|
|
|
|
set to the taproot root hash (in case of a tapscript output) or the tap
|
|
|
|
hashed internal public key (in case of a BIP-0086 output).
|
|
|
|
*/
|
|
|
|
bool taproot_key_spend = 9;
|
2018-10-22 17:30:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
message SignReq {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The raw bytes of the transaction to be signed.
|
2018-10-22 17:30:02 -07:00
|
|
|
bytes raw_tx_bytes = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
// A set of sign descriptors, for each input to be signed.
|
2018-10-22 17:30:02 -07:00
|
|
|
repeated SignDescriptor sign_descs = 2;
|
2022-03-18 18:37:50 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
The full list of UTXO information for each of the inputs being spent. This
|
|
|
|
is required when spending one or more taproot (SegWit v1) outputs.
|
|
|
|
*/
|
|
|
|
repeated TxOut prev_outputs = 3;
|
2018-10-22 17:30:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
message SignResp {
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2018-10-22 17:30:02 -07:00
|
|
|
A set of signatures realized in a fixed 64-byte format ordered in ascending
|
|
|
|
input order.
|
|
|
|
*/
|
|
|
|
repeated bytes raw_sigs = 1;
|
|
|
|
}
|
|
|
|
|
2018-11-28 20:08:00 -08:00
|
|
|
message InputScript {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The serializes witness stack for the specified input.
|
2018-11-28 20:08:00 -08:00
|
|
|
repeated bytes witness = 1;
|
|
|
|
|
2020-05-13 09:19:27 +02:00
|
|
|
/*
|
2018-11-28 20:08:00 -08:00
|
|
|
The optional sig script for the specified witness that will only be set if
|
|
|
|
the input specified is a nested p2sh witness program.
|
|
|
|
*/
|
|
|
|
bytes sig_script = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message InputScriptResp {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The set of fully valid input scripts requested.
|
2018-11-28 20:08:00 -08:00
|
|
|
repeated InputScript input_scripts = 1;
|
|
|
|
}
|
|
|
|
|
2019-12-10 09:48:49 +01:00
|
|
|
message SignMessageReq {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The message to be signed.
|
2019-12-10 09:48:49 +01:00
|
|
|
bytes msg = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
// The key locator that identifies which key to use for signing.
|
2019-12-10 09:48:49 +01:00
|
|
|
KeyLocator key_loc = 2;
|
2021-09-23 16:54:26 +02:00
|
|
|
|
|
|
|
// Double-SHA256 hash instead of just the default single round.
|
|
|
|
bool double_hash = 3;
|
2021-10-14 15:42:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Use the compact (pubkey recoverable) format instead of the raw lnwire
|
|
|
|
format.
|
|
|
|
*/
|
|
|
|
bool compact_sig = 4;
|
2019-12-10 09:48:49 +01:00
|
|
|
}
|
|
|
|
message SignMessageResp {
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2019-12-10 09:48:49 +01:00
|
|
|
The signature for the given message in the fixed-size LN wire format.
|
|
|
|
*/
|
|
|
|
bytes signature = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message VerifyMessageReq {
|
2020-05-06 16:51:14 +02:00
|
|
|
// The message over which the signature is to be verified.
|
2019-12-10 09:48:49 +01:00
|
|
|
bytes msg = 1;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2019-12-10 09:48:49 +01:00
|
|
|
The fixed-size LN wire encoded signature to be verified over the given
|
|
|
|
message.
|
|
|
|
*/
|
|
|
|
bytes signature = 2;
|
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
// The public key the signature has to be valid for.
|
2019-12-10 09:48:49 +01:00
|
|
|
bytes pubkey = 3;
|
|
|
|
}
|
|
|
|
message VerifyMessageResp {
|
2020-05-06 16:51:14 +02:00
|
|
|
// Whether the signature was valid over the given message.
|
2019-12-10 09:48:49 +01:00
|
|
|
bool valid = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-28 10:58:51 +01:00
|
|
|
message SharedKeyRequest {
|
|
|
|
// The ephemeral public key to use for the DH key derivation.
|
|
|
|
bytes ephemeral_pubkey = 1;
|
2020-02-11 13:59:22 +01:00
|
|
|
|
2020-05-06 16:51:14 +02:00
|
|
|
/*
|
2020-07-28 05:39:12 +08:00
|
|
|
Deprecated. The optional key locator of the local key that should be used.
|
|
|
|
If this parameter is not set then the node's identity private key will be
|
|
|
|
used.
|
2020-01-06 14:53:24 +01:00
|
|
|
*/
|
2020-07-28 05:39:12 +08:00
|
|
|
KeyLocator key_loc = 2 [deprecated = true];
|
|
|
|
|
|
|
|
/*
|
|
|
|
A key descriptor describes the key used for performing ECDH. Either a key
|
|
|
|
locator or a raw public key is expected, if neither is supplied, defaults to
|
|
|
|
the node's identity private key.
|
|
|
|
*/
|
|
|
|
KeyDescriptor key_desc = 3;
|
2019-11-28 10:58:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
message SharedKeyResponse {
|
|
|
|
// The shared public key, hashed with sha256.
|
|
|
|
bytes shared_key = 1;
|
|
|
|
}
|