| 238 | } |
| 239 | |
| 240 | void blindedpath_next_path_key(const struct tlv_encrypted_data_tlv *enc, |
| 241 | const struct pubkey *path_key, |
| 242 | const struct secret *ss, |
| 243 | struct pubkey *next_path_key) |
| 244 | { |
| 245 | /* BOLT #4: |
| 246 | * - $`E_{i+1} = SHA256(E_i || ss_i) * E_i`$ |
| 247 | * ... |
| 248 | * - If the `encrypted_data_tlv` contains a `next_path_key_override`: |
| 249 | * - MUST use it as the next `path_key`. |
| 250 | * - Otherwise: |
| 251 | * - MUST use $`E_{i+1} = SHA256(E_i || ss_i) * E_i`$ as the next `path_key` |
| 252 | */ |
| 253 | if (enc->next_path_key_override) |
| 254 | *next_path_key = *enc->next_path_key_override; |
| 255 | else { |
| 256 | struct sha256 h; |
| 257 | blinding_hash_e_and_ss(path_key, ss, &h); |
| 258 | blinding_next_path_key(path_key, &h, next_path_key); |
| 259 | } |
| 260 | } |