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

Function main

common/test/run-blindedpath_enctlv.c:131–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131int main(int argc, char *argv[])
132{
133 struct privkey alice, bob, carol, dave, blinding, override_blinding;
134 struct pubkey alice_id, bob_id, carol_id, dave_id, blinding_pub, override_blinding_pub, alias;
135 struct secret self_id;
136 u8 *enctlv;
137
138 common_setup(argv[0]);
139
140 memset(&alice, 'A', sizeof(alice));
141 memset(&bob, 'B', sizeof(bob));
142 memset(&carol, 'C', sizeof(carol));
143 memset(&dave, 'D', sizeof(dave));
144 pubkey_from_privkey(&alice, &alice_id);
145 pubkey_from_privkey(&bob, &bob_id);
146 pubkey_from_privkey(&carol, &carol_id);
147 pubkey_from_privkey(&dave, &dave_id);
148
149 memset(&blinding, 5, sizeof(blinding));
150 pubkey_from_privkey(&blinding, &blinding_pub);
151
152 /* We output the JSON test vectors. */
153 printf("[{");
154 json_strfield("test name", "Simple encrypted_recipient_data for Alice, next is Bob");
155 json_strfield("node_privkey",
156 type_to_string(tmpctx, struct privkey, &alice));
157 json_strfield("node_id",
158 type_to_string(tmpctx, struct pubkey, &alice_id));
159 json_strfield("blinding_secret",
160 type_to_string(tmpctx, struct privkey, &blinding));
161 json_strfield("blinding",
162 type_to_string(tmpctx, struct pubkey, &blinding_pub));
163 printf("\t\"encrypted_data_tlv\": {\n"
164 "\t\t\"next_node_id\": \"%s\"\n"
165 "\t},\n",
166 type_to_string(tmpctx, struct pubkey, &bob_id));
167
168 enctlv = create_enctlv(tmpctx, &blinding, &alice_id, &bob_id,
169 0, NULL, &blinding, &alias);
170 printf("\t\"encrypted_recipient_data_hex\": \"%s\"\n"
171 "},\n",
172 tal_hex(tmpctx, enctlv));
173
174 test_decrypt(&blinding_pub, enctlv, &alice, &bob_id, &blinding);
175
176 pubkey_from_privkey(&blinding, &blinding_pub);
177 memset(&override_blinding, 7, sizeof(override_blinding));
178 pubkey_from_privkey(&override_blinding, &override_blinding_pub);
179
180 printf("{");
181 json_strfield("test name",
182 "Blinding-key-override encrypted_recipient_data for Bob, next is Carol");
183 json_strfield("node_privkey",
184 type_to_string(tmpctx, struct privkey, &bob));
185 json_strfield("node_id",
186 type_to_string(tmpctx, struct pubkey, &bob_id));
187 json_strfield("blinding_secret",
188 type_to_string(tmpctx, struct privkey, &blinding));

Callers

nothing calls this directly

Calls 10

common_setupFunction · 0.85
pubkey_from_privkeyFunction · 0.85
create_enctlvFunction · 0.85
tal_hexFunction · 0.85
test_decryptFunction · 0.85
create_final_enctlvFunction · 0.85
test_final_decryptFunction · 0.85
common_shutdownFunction · 0.85
json_strfieldFunction · 0.70
type_to_stringClass · 0.50

Tested by

no test coverage detected