Apply tweak to ephemeral key if blinding is non-NULL, then do ECDH */
| 1136 | |
| 1137 | /* Apply tweak to ephemeral key if blinding is non-NULL, then do ECDH */ |
| 1138 | static 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 | |
| 1166 | REGISTER_PLUGIN_HOOK(htlc_accepted, |
| 1167 | htlc_accepted_hook_deserialize, |
no test coverage detected