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

Function unblind_onion

common/blindedpath.c:129–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129bool unblind_onion(const struct pubkey *path_key,
130 void (*ecdh)(const struct pubkey *point, struct secret *ss),
131 struct pubkey *onion_key,
132 struct secret *ss)
133{
134 struct secret hmac;
135
136 /* BOLT #4:
137 * A reader:
138 *...
139 * - if `path_key` is specified:
140 * - Calculate the `blinding_ss` as ECDH(`path_key`, `node_privkey`).
141 * - Either:
142 * - Tweak `public_key` by multiplying by $`HMAC256(\text{"blinded\_node\_id"}, blinding\_ss)`$.
143 * - or (equivalently):
144 * - Tweak its own `node_privkey` below by multiplying by $`HMAC256(\text{"blinded\_node\_id"}, blinding\_ss)`$.
145 * - Derive the shared secret `ss` as ECDH(`public_key`, `node_privkey`)
146 * (see [Shared Secret](#shared-secret)).
147 */
148 ecdh(path_key, ss);
149 subkey_from_hmac("blinded_node_id", ss, &hmac);
150
151 /* We tweak the *ephemeral* key from the onion and use
152 * our normal privkey: since hsmd knows only how to ECDH with
153 * our real key. */
154 return secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx,
155 &onion_key->pubkey,
156 hmac.data) == 1;
157}
158
159u8 *decrypt_encmsg_raw(const tal_t *ctx,
160 const struct secret *ss,

Callers 5

onion_message_parseFunction · 0.85
next_onionFunction · 0.85
test_decryptFunction · 0.85
test_final_decryptFunction · 0.85
mainFunction · 0.85

Calls 2

ecdhFunction · 0.70
subkey_from_hmacFunction · 0.70

Tested by 4

next_onionFunction · 0.68
test_decryptFunction · 0.68
test_final_decryptFunction · 0.68
mainFunction · 0.68