Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
| 1317 | |
| 1318 | /* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */ |
| 1319 | bool 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 | |
| 1346 | REGISTER_PLUGIN_HOOK(htlc_accepted, |
| 1347 | htlc_accepted_hook_deserialize, |
no test coverage detected