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

Function main

common/test/run-blindedpath_onion.c:146–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146int main(int argc, char *argv[])
147{
148 struct privkey nodekey[4], blinding[4], override_blinding;
149 struct pubkey id[4], blinding_pub[4], override_blinding_pub, alias[4];
150 struct secret self_id;
151 u8 *enctlv[4];
152 u8 *onionmsg_payload[4];
153 u8 *omsg;
154 struct sphinx_path *sphinx_path;
155 struct secret *path_secrets;
156 struct onionpacket *op;
157 const char *names[] = {"Alice", "Bob", "Carol", "Dave"};
158
159 common_setup(argv[0]);
160
161 for (size_t i = 0; i < 4; i++) {
162 memset(&nodekey[i], names[i][0], sizeof(nodekey[i]));
163 pubkey_from_privkey(&nodekey[i], &id[i]);
164 }
165
166 /* Make enctlvs as per enctlv test vectors */
167 memset(&blinding[ALICE], 5, sizeof(blinding[ALICE]));
168 pubkey_from_privkey(&blinding[ALICE], &blinding_pub[ALICE]);
169
170 enctlv[ALICE] = create_enctlv(tmpctx, &blinding[ALICE],
171 &id[ALICE], &id[BOB],
172 0, NULL, &blinding[BOB], &alias[ALICE]);
173
174 pubkey_from_privkey(&blinding[BOB], &blinding_pub[BOB]);
175
176 /* We override blinding for Carol. */
177 memset(&override_blinding, 7, sizeof(override_blinding));
178 pubkey_from_privkey(&override_blinding, &override_blinding_pub);
179 enctlv[BOB] = create_enctlv(tmpctx, &blinding[BOB],
180 &id[BOB], &id[CAROL],
181 0, &override_blinding_pub,
182 &blinding[CAROL], &alias[BOB]);
183
184 /* That replaced the blinding */
185 blinding[CAROL] = override_blinding;
186 blinding_pub[CAROL] = override_blinding_pub;
187
188 enctlv[CAROL] = create_enctlv(tmpctx, &blinding[CAROL],
189 &id[CAROL], &id[DAVE],
190 35, NULL, &blinding[DAVE], &alias[CAROL]);
191
192 for (size_t i = 0; i < sizeof(self_id); i++)
193 self_id.data[i] = i+1;
194
195 enctlv[DAVE] = create_final_enctlv(tmpctx, &blinding[DAVE], &id[DAVE],
196 0, &self_id, &alias[DAVE]);
197 pubkey_from_privkey(&blinding[DAVE], &blinding_pub[DAVE]);
198
199 /* Create an onion which encodes this. */
200 sphinx_path = sphinx_path_new(tmpctx, NULL);
201 for (size_t i = 0; i < 4; i++) {
202 struct tlv_onionmsg_payload *payload
203 = tlv_onionmsg_payload_new(tmpctx);

Callers

nothing calls this directly

Calls 13

common_setupFunction · 0.85
pubkey_from_privkeyFunction · 0.85
create_enctlvFunction · 0.85
create_final_enctlvFunction · 0.85
sphinx_path_newFunction · 0.85
sphinx_add_hopFunction · 0.85
create_onionpacketFunction · 0.85
tal_hexFunction · 0.85
next_onionFunction · 0.85
common_shutdownFunction · 0.85
json_strfieldFunction · 0.70
serialize_onionpacketFunction · 0.50

Tested by

no test coverage detected