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

Function main

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

Source from the content-addressed store, hash-verified

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