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

Function ecdh_maybe_blinding

lightningd/peer_htlcs.c:1319–1344  ·  view source on GitHub ↗

Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */

Source from the content-addressed store, hash-verified

1317
1318/* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
1319bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,
1320 const struct pubkey *path_key,
1321 struct secret *ss)
1322{
1323 struct pubkey point = *ephemeral_key;
1324
1325 if (path_key) {
1326 struct secret hmac;
1327 struct secret blinding_ss;
1328
1329 ecdh(path_key, &blinding_ss);
1330 /* b(i) = HMAC256("blinded_node_id", ss(i)) * k(i) */
1331 subkey_from_hmac("blinded_node_id", &blinding_ss, &hmac);
1332
1333 /* We instead tweak the *ephemeral* key from the onion and use
1334 * our normal privkey: since hsmd knows only how to ECDH with
1335 * our real key */
1336 if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx,
1337 &point.pubkey,
1338 hmac.data) != 1) {
1339 return false;
1340 }
1341 }
1342 ecdh(&point, ss);
1343 return true;
1344}
1345
1346REGISTER_PLUGIN_HOOK(htlc_accepted,
1347 htlc_accepted_hook_deserialize,

Callers 2

json_injectpaymentonionFunction · 0.70
channel_added_their_htlcFunction · 0.70

Calls 2

ecdhFunction · 0.50
subkey_from_hmacFunction · 0.50

Tested by

no test coverage detected