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

Function derive_basepoints

common/derive_basepoints.c:49–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool derive_basepoints(const struct secret *seed,
50 struct pubkey *funding_pubkey,
51 struct basepoints *basepoints,
52 struct secrets *secrets,
53 struct sha256 *shaseed)
54{
55 struct keys keys;
56
57 derive_keys(seed, &keys);
58
59 if (secrets) {
60 secrets->funding_privkey = keys.f;
61 secrets->revocation_basepoint_secret = keys.r.secret;
62 secrets->payment_basepoint_secret = keys.p.secret;
63 secrets->htlc_basepoint_secret = keys.h.secret;
64 secrets->delayed_payment_basepoint_secret = keys.d.secret;
65 }
66
67 if (funding_pubkey) {
68 if (!pubkey_from_privkey(&keys.f, funding_pubkey))
69 return false;
70 }
71
72 if (basepoints) {
73 if (!pubkey_from_privkey(&keys.r, &basepoints->revocation)
74 || !pubkey_from_privkey(&keys.p, &basepoints->payment)
75 || !pubkey_from_privkey(&keys.h, &basepoints->htlc)
76 || !pubkey_from_privkey(&keys.d, &basepoints->delayed_payment))
77 return false;
78 }
79
80 /* BOLT #3:
81 *
82 * A node:
83 * - MUST select an unguessable 256-bit seed for each connection,
84 * - MUST NOT reveal the seed.
85 */
86 if (shaseed)
87 *shaseed = keys.shaseed;
88
89 return true;
90}
91
92bool per_commit_secret(const struct sha256 *shaseed,
93 struct secret *commit_secret,

Callers 9

handle_sign_splice_txFunction · 0.85
handle_sign_anchorspendFunction · 0.85
mainFunction · 0.85

Calls 2

pubkey_from_privkeyFunction · 0.85
derive_keysFunction · 0.70

Tested by 1

mainFunction · 0.68