| 231 | } |
| 232 | |
| 233 | int main(int argc, char *argv[]) |
| 234 | { |
| 235 | const char *alias[] = {"Alice", "Bob", "Carol", "Dave"}; |
| 236 | struct privkey privkey[ARRAY_SIZE(alias)], path_key, override_path_key; |
| 237 | struct pubkey id[ARRAY_SIZE(alias)], path_key_pub; |
| 238 | struct secret session_key; |
| 239 | u8 *erd[ARRAY_SIZE(alias)]; /* encrypted_recipient_data */ |
| 240 | u8 *onion_message_packet, *onion_message; |
| 241 | struct pubkey blinded[ARRAY_SIZE(alias)]; |
| 242 | struct sphinx_path *sphinx_path; |
| 243 | struct onionpacket *op; |
| 244 | struct secret *path_secrets; |
| 245 | |
| 246 | common_setup(argv[0]); |
| 247 | |
| 248 | /* Alice is AAA... Bob is BBB... */ |
| 249 | for (size_t i = 0; i < ARRAY_SIZE(alias); i++) { |
| 250 | memset(&privkey[i], alias[i][0], sizeof(privkey[i])); |
| 251 | assert(pubkey_from_privkey(&privkey[i], &id[i])); |
| 252 | } |
| 253 | |
| 254 | memset(&session_key, 3, sizeof(session_key)); |
| 255 | |
| 256 | json_start(NULL, '{'); |
| 257 | json_strfield("comment", "Test vector creating an onionmessage, including joining an existing one"); |
| 258 | json_start("generate", '{'); |
| 259 | json_strfield("comment", "This sections contains test data for Dave's blinded path Bob->Dave; sender has to prepend a hop to Alice to reach Bob"); |
| 260 | json_hexfield("session_key", session_key.data, sizeof(session_key)); |
| 261 | json_start("hops", '['); |
| 262 | |
| 263 | memset(&path_key, 99, sizeof(path_key)); |
| 264 | memset(&override_path_key, 1, sizeof(override_path_key)); |
| 265 | erd[0] = add_hop("Alice", "Alice->Bob: note next_path_key_override to match that give by Dave for Bob", |
| 266 | &id[0], &id[1], |
| 267 | &override_path_key, NULL, NULL, |
| 268 | &path_key, &blinded[0]); |
| 269 | erd[1] = add_hop("Bob", "Bob->Carol", |
| 270 | &id[1], &id[2], |
| 271 | NULL, "fd023103123456", NULL, |
| 272 | &path_key, &blinded[1]); |
| 273 | erd[2] = add_hop("Carol", "Carol->Dave", |
| 274 | &id[2], &id[3], |
| 275 | NULL, NULL, NULL, |
| 276 | &path_key, &blinded[2]); |
| 277 | erd[3] = add_hop("Dave", "Dave is final node, hence path_id", |
| 278 | &id[3], NULL, |
| 279 | NULL, "fdffff0206c1", |
| 280 | "deadbeefbadc0ffeedeadbeefbadc0ffeedeadbeefbadc0ffeedeadbeefbadc0", |
| 281 | &path_key, &blinded[3]); |
| 282 | |
| 283 | json_end(']'); |
| 284 | json_end('}'); |
| 285 | maybe_comma(); |
| 286 | |
| 287 | memset(&path_key, 99, sizeof(path_key)); |
| 288 | assert(pubkey_from_privkey(&path_key, &path_key_pub)); |
| 289 | json_start("route", '{'); |
| 290 | json_strfield("comment", "The resulting blinded route Alice to Dave."); |
nothing calls this directly
no test coverage detected