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

Function test_sign

tests/fuzz/fuzz-bolt11.c:47–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47static bool test_sign(const u5 *u5bytes,
48 const u8 *hrpu8,
49 secp256k1_ecdsa_recoverable_signature *rsig,
50 void *unused UNUSED)
51{
52 struct hash_u5 hu5;
53 char *hrp;
54 struct sha256 sha;
55 struct privkey privkey;
56
57 memset(&privkey, 'a', sizeof(privkey));
58
59 hrp = tal_dup_arr(NULL, char, (char *)hrpu8, tal_count(hrpu8), 1);
60 hrp[tal_count(hrpu8)] = '\0';
61
62 hash_u5_init(&hu5, hrp);
63 hash_u5(&hu5, u5bytes, tal_count(u5bytes));
64 hash_u5_done(&hu5, &sha);
65 tal_free(hrp);
66
67 if (!secp256k1_ecdsa_sign_recoverable(secp256k1_ctx, rsig,
68 (const u8 *)&sha,
69 privkey.secret.data,
70 NULL, NULL))
71 abort();
72
73 return true;
74}
75
76// We use a custom mutator to produce an input corpus that consists entirely of
77// correctly encoded bech32 strings. This enables us to efficiently fuzz the

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