MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sigcheck_channel_update

Function sigcheck_channel_update

gossipd/sigcheck.c:9–43  ·  view source on GitHub ↗

Verify the signature of a channel_update message */

Source from the content-addressed store, hash-verified

7
8/* Verify the signature of a channel_update message */
9const char *sigcheck_channel_update(const tal_t *ctx,
10 const struct node_id *node_id,
11 const secp256k1_ecdsa_signature *node_sig,
12 const u8 *update)
13{
14 /* BOLT #7:
15 * 1. type: 258 (`channel_update`)
16 * 2. data:
17 * * [`signature`:`signature`]
18 * * [`chain_hash`:`chain_hash`]
19 * * [`short_channel_id`:`short_channel_id`]
20 * * [`u32`:`timestamp`]
21 * * [`byte`:`message_flags`]
22 * * [`byte`:`channel_flags`]
23 * * [`u16`:`cltv_expiry_delta`]
24 * * [`u64`:`htlc_minimum_msat`]
25 * * [`u32`:`fee_base_msat`]
26 * * [`u32`:`fee_proportional_millionths`]
27 * * [`u64`:`htlc_maximum_msat`]
28 */
29 /* 2 byte msg type + 64 byte signatures */
30 int offset = 66;
31 struct sha256_double hash;
32
33 sha256_double(&hash, update + offset, tal_count(update) - offset);
34
35 if (!check_signed_hash_nodeid(&hash, node_sig, node_id))
36 return tal_fmt(ctx,
37 "Bad signature for %s hash %s"
38 " on channel_update %s",
39 fmt_secp256k1_ecdsa_signature(tmpctx, node_sig),
40 fmt_sha256_double(tmpctx, &hash),
41 tal_hex(tmpctx, update));
42 return NULL;
43}
44
45const char *sigcheck_channel_announcement(const tal_t *ctx,
46 const struct node_id *node1_id,

Callers 2

process_channel_updateFunction · 0.85

Calls 5

check_signed_hash_nodeidFunction · 0.85
fmt_sha256_doubleFunction · 0.85
tal_hexFunction · 0.85
sha256_doubleClass · 0.70

Tested by

no test coverage detected