Skip to content

Commit fadb07f

Browse files
committed
Added sign-message.
1 parent a377994 commit fadb07f

File tree

4 files changed

+6
-29
lines changed

4 files changed

+6
-29
lines changed

contrib/remote_hsmd/NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ Some popular tests:
6767

6868
# check-future-secret
6969
export THETEST=tests/test_connection.py::test_dataloss_protection
70+
71+
# sign-message
72+
export THETEST=tests/test_misc.py::test_signmessage
7073

7174
rust-lightning-signer
7275
----------------------------------------------------------------

contrib/remote_hsmd/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ COMPLETE proxy_stat proxy_handle_sign_penalty_to_us
2727
COMPLETE proxy_stat proxy_handle_sign_commitment_tx
2828
COMPLETE proxy_stat proxy_handle_sign_mutual_close_tx
2929
COMPLETE proxy_stat proxy_handle_check_future_secret
30+
COMPLETE proxy_stat proxy_handle_sign_message
3031
3132
PARTIAL (-P2SH) proxy_stat proxy_handle_sign_withdrawal_tx
3233
3334
MARSHALED proxy_stat proxy_init_hsm
34-
MARSHALED proxy_stat proxy_handle_sign_message
3535
MARSHALED proxy_stat proxy_handle_cannouncement_sig
3636
```
3737

contrib/remote_hsmd/hsmd.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,10 +1811,7 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
18111811
const u8 *msg_in)
18121812
{
18131813
u8 *msg;
1814-
struct sha256_ctx sctx = SHA256_INIT;
1815-
struct sha256_double shad;
18161814
secp256k1_ecdsa_recoverable_signature rsig;
1817-
struct privkey node_pkey;
18181815

18191816
if (!fromwire_hsm_sign_message(tmpctx, msg_in, &msg))
18201817
return bad_req(conn, c, msg_in);
@@ -1828,26 +1825,7 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
18281825
return bad_req_fmt(conn, c, msg_in,
18291826
"proxy_%s error: %s", __FUNCTION__,
18301827
proxy_last_message());
1831-
g_proxy_impl = PROXY_IMPL_MARSHALED;
1832-
1833-
/* FIXME - USE THE PROXIED VALUE WHEN SERVER SUPPORTS */
1834-
1835-
/* Prefixing by a known string means we'll never be convinced
1836-
* to sign some gossip message, etc. */
1837-
sha256_update(&sctx, "Lightning Signed Message:",
1838-
strlen("Lightning Signed Message:"));
1839-
sha256_update(&sctx, msg, tal_count(msg));
1840-
sha256_double_done(&sctx, &shad);
1841-
1842-
node_key(&node_pkey, NULL);
1843-
/*~ By no small coincidence, this libsecp routine uses the exact
1844-
* recovery signature format mandated by BOLT 11. */
1845-
if (!secp256k1_ecdsa_sign_recoverable(secp256k1_ctx, &rsig,
1846-
shad.sha.u.u8,
1847-
node_pkey.secret.data,
1848-
NULL, NULL)) {
1849-
return bad_req_fmt(conn, c, msg_in, "Failed to sign message");
1850-
}
1828+
g_proxy_impl = PROXY_IMPL_COMPLETE;
18511829

18521830
return req_reply(conn, c,
18531831
take(towire_hsm_sign_message_reply(NULL, &rsig)));

contrib/remote_hsmd/proxy.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,18 +642,14 @@ proxy_stat proxy_handle_sign_message(
642642

643643
last_message = "";
644644
SignMessageRequest req;
645+
marshal_node_id(&self_id, req.mutable_node_id());
645646
req.set_message(msg, tal_count(msg));
646647

647648
ClientContext context;
648649
RecoverableNodeSignatureReply rsp;
649650
Status status = stub->SignMessage(&context, req, &rsp);
650651
if (status.ok()) {
651-
// FIXME - UNCOMMENT WHEN SERVER IMPLEMENTS:
652-
#if 0
653652
unmarshal_ecdsa_recoverable_signature(rsp.signature(), o_sig);
654-
#else
655-
memset(o_sig, '\0', sizeof(*o_sig));
656-
#endif
657653
status_debug("%s:%d %s self_id=%s sig=%s",
658654
__FILE__, __LINE__, __FUNCTION__,
659655
dump_node_id(&self_id).c_str(),

0 commit comments

Comments
 (0)