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

Function test_sign

common/test/run-bolt11.c:155–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153static struct privkey privkey;
154
155static bool test_sign(const u5 *u5bytes,
156 const u8 *hrpu8,
157 secp256k1_ecdsa_recoverable_signature *rsig,
158 void *unused UNUSED)
159{
160 struct hash_u5 hu5;
161 char *hrp;
162 struct sha256 sha;
163
164 hrp = tal_dup_arr(NULL, char, (char *)hrpu8, tal_count(hrpu8), 1);
165 hrp[tal_count(hrpu8)] = '\0';
166
167 hash_u5_init(&hu5, hrp);
168 hash_u5(&hu5, u5bytes, tal_count(u5bytes));
169 hash_u5_done(&hu5, &sha);
170 tal_free(hrp);
171
172 if (!secp256k1_ecdsa_sign_recoverable(secp256k1_ctx, rsig,
173 (const u8 *)&sha,
174 privkey.secret.data,
175 NULL, NULL))
176 abort();
177
178 return true;
179}
180
181static void test_b11(const char *b11str,
182 const struct bolt11 *expect_b11,

Callers

nothing calls this directly

Calls 5

hash_u5_initFunction · 0.85
hash_u5_doneFunction · 0.85
tal_freeFunction · 0.85
abortFunction · 0.85
hash_u5Class · 0.70

Tested by

no test coverage detected