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

Function ecdh_maybe_blinding

lightningd/peer_htlcs.c:1138–1164  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1136
1137/* Apply tweak to ephemeral key if blinding is non-NULL, then do ECDH */
1138static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,
1139 const struct pubkey *blinding,
1140 const struct secret *blinding_ss,
1141 struct secret *ss)
1142{
1143 struct pubkey point = *ephemeral_key;
1144
1145#if EXPERIMENTAL_FEATURES
1146 if (blinding) {
1147 struct secret hmac;
1148
1149 /* b(i) = HMAC256("blinded_node_id", ss(i)) * k(i) */
1150 subkey_from_hmac("blinded_node_id", blinding_ss, &hmac);
1151
1152 /* We instead tweak the *ephemeral* key from the onion and use
1153 * our normal privkey: since hsmd knows only how to ECDH with
1154 * our real key */
1155 if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx,
1156 &point.pubkey,
1157 hmac.data) != 1) {
1158 return false;
1159 }
1160 }
1161#endif /* EXPERIMENTAL_FEATURES */
1162 ecdh(&point, ss);
1163 return true;
1164}
1165
1166REGISTER_PLUGIN_HOOK(htlc_accepted,
1167 htlc_accepted_hook_deserialize,

Callers 1

channel_added_their_htlcFunction · 0.85

Calls 2

subkey_from_hmacFunction · 0.50
ecdhFunction · 0.50

Tested by

no test coverage detected