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

Function main

common/test/run-derive_basepoints.c:143–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143int main(int argc, char *argv[])
144{
145 const tal_t *ctx = tal(NULL, char);
146 struct info *baseline, *info;
147
148 common_setup(argv[0]);
149 baseline = new_info(ctx);
150 assert(derive_basepoints(&baseline->seed, &baseline->funding_pubkey,
151 &baseline->basepoints,
152 &baseline->secrets,
153 &baseline->shaseed));
154
155 /* Same seed, same result. */
156 info = new_info(ctx);
157 assert(derive_basepoints(&info->seed, &info->funding_pubkey,
158 &info->basepoints,
159 &info->secrets,
160 &info->shaseed));
161 assert(pubkey_eq(&baseline->funding_pubkey, &info->funding_pubkey));
162 assert(basepoints_eq(&baseline->basepoints, &info->basepoints));
163 assert(secrets_eq(&baseline->secrets, &info->secrets));
164 assert(sha256_eq(&baseline->shaseed, &info->shaseed));
165
166 /* Different seed, different result. */
167 for (size_t i = 0; i < sizeof(info->seed); i++) {
168 for (size_t b = 0; b < CHAR_BIT; b++) {
169 info = new_info(ctx);
170 info->seed.data[i] ^= (1 << b);
171
172 assert(derive_basepoints(&info->seed,
173 &info->funding_pubkey,
174 &info->basepoints,
175 &info->secrets,
176 &info->shaseed));
177 assert(!pubkey_eq(&baseline->funding_pubkey,
178 &info->funding_pubkey));
179 assert(!basepoints_eq(&baseline->basepoints,
180 &info->basepoints));
181 assert(!secrets_eq(&baseline->secrets, &info->secrets));
182 assert(!sha256_eq(&baseline->shaseed, &info->shaseed));
183 }
184 }
185
186 /* Any field can be NULL (except seed). */
187 info = new_info(ctx);
188 assert(derive_basepoints(&info->seed, NULL,
189 &info->basepoints,
190 &info->secrets,
191 &info->shaseed));
192 assert(basepoints_eq(&baseline->basepoints, &info->basepoints));
193 assert(secrets_eq(&baseline->secrets, &info->secrets));
194 assert(sha256_eq(&baseline->shaseed, &info->shaseed));
195
196 info = new_info(ctx);
197 assert(derive_basepoints(&info->seed, &info->funding_pubkey,
198 NULL,
199 &info->secrets,
200 &info->shaseed));

Callers

nothing calls this directly

Calls 11

common_setupFunction · 0.85
new_infoFunction · 0.85
derive_basepointsFunction · 0.85
derive_payment_basepointFunction · 0.85
secret_eq_consttimeFunction · 0.85
derive_shaseedFunction · 0.85
derive_htlc_basepointFunction · 0.85
tal_freeFunction · 0.85
common_shutdownFunction · 0.85
derive_funding_keyFunction · 0.50

Tested by

no test coverage detected