| 200 | } |
| 201 | |
| 202 | bool decrypt_enctlv(const struct pubkey *blinding, |
| 203 | const struct secret *ss, |
| 204 | const u8 *enctlv, |
| 205 | struct pubkey *next_node, |
| 206 | struct pubkey *next_blinding) |
| 207 | { |
| 208 | struct tlv_encrypted_data_tlv *encmsg; |
| 209 | |
| 210 | encmsg = decrypt_encmsg(tmpctx, blinding, ss, enctlv); |
| 211 | if (!encmsg) |
| 212 | return false; |
| 213 | |
| 214 | /* BOLT-onion-message #4: |
| 215 | * |
| 216 | * The reader: |
| 217 | * - if it is not the final node according to the onion encryption: |
| 218 | *... |
| 219 | * - if the `enctlv` ... does not contain |
| 220 | * `next_node_id`: |
| 221 | * - MUST drop the message. |
| 222 | */ |
| 223 | if (!encmsg->next_node_id) |
| 224 | return false; |
| 225 | |
| 226 | /* BOLT-onion-message #4: |
| 227 | * The reader: |
| 228 | * - if it is not the final node according to the onion encryption: |
| 229 | *... |
| 230 | * - if the `enctlv` contains `path_id`: |
| 231 | * - MUST drop the message. |
| 232 | */ |
| 233 | if (encmsg->path_id) |
| 234 | return false; |
| 235 | |
| 236 | /* BOLT-onion-message #4: |
| 237 | * The reader: |
| 238 | * - if it is not the final node according to the onion encryption: |
| 239 | *... |
| 240 | * - if `blinding` is specified in the `enctlv`: |
| 241 | * - MUST pass that as `blinding` in the `onion_message` |
| 242 | * - otherwise: |
| 243 | * - MUST pass `blinding` derived as in |
| 244 | * [Route Blinding][route-blinding] (i.e. |
| 245 | * `E(i+1) = H(E(i) || ss(i)) * E(i)`). |
| 246 | */ |
| 247 | *next_node = *encmsg->next_node_id; |
| 248 | if (encmsg->next_blinding_override) |
| 249 | *next_blinding = *encmsg->next_blinding_override; |
| 250 | else { |
| 251 | /* E(i-1) = H(E(i) || ss(i)) * E(i) */ |
| 252 | struct sha256 h; |
| 253 | blinding_hash_e_and_ss(blinding, ss, &h); |
| 254 | blinding_next_pubkey(blinding, &h, next_blinding); |
| 255 | } |
| 256 | return true; |
| 257 | } |
| 258 | |
| 259 | bool decrypt_final_enctlv(const tal_t *ctx, |