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

Function get_channel_seed

devtools/checkchannels.c:31–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31static void get_channel_seed(const struct secret *hsm_secret,
32 const struct node_id *peer_id, u64 dbid,
33 struct secret *channel_seed)
34{
35 struct secret channel_base;
36 u8 input[sizeof(peer_id->k) + sizeof(dbid)];
37 /*~ Again, "per-peer" should be "per-channel", but Hysterical Raisins */
38 const char *info = "per-peer seed";
39
40 /*~ We use the DER encoding of the pubkey, because it's platform
41 * independent. Since the dbid is unique, however, it's completely
42 * unnecessary, but again, existing users can't be broken. */
43 /* FIXME: lnd has a nicer BIP32 method for deriving secrets which we
44 * should migrate to. */
45 hsm_channel_secret_base(&channel_base, hsm_secret);
46 memcpy(input, peer_id->k, sizeof(peer_id->k));
47 BUILD_ASSERT(sizeof(peer_id->k) == PUBKEY_CMPR_LEN);
48 /*~ For all that talk about platform-independence, note that this
49 * field is endian-dependent! But let's face it, little-endian won.
50 * In related news, we don't support EBCDIC or middle-endian. */
51 memcpy(input + PUBKEY_CMPR_LEN, &dbid, sizeof(dbid));
52
53 hkdf_sha256(channel_seed, sizeof(*channel_seed),
54 input, sizeof(input),
55 &channel_base, sizeof(channel_base),
56 info, strlen(info));
57}
58
59struct keys {
60 struct privkey f, r, h, p, d;

Callers 1

derive_funding_keyFunction · 0.70

Calls 2

hsm_channel_secret_baseFunction · 0.70
hkdf_sha256Function · 0.50

Tested by

no test coverage detected