Commit Graph

163 Commits

Author SHA1 Message Date
Chandra Pratap
17cf63aec3 fuzz-tests: Add coverage increasing inputs to seed corpora
Improvements in the fuzz-testing scheme of `fuzz-channel_id led
to the discovery of test inputs that result in greater in code
coverage. Add these inputs to the test's seed corpus.
2025-09-15 13:42:38 +09:30
Chandra Pratap
9e341453d5 fuzz-tests: Get rid of magic numbers
Replace instances of 36 with sizeof(outpoint) and 32 with
sizeof(chan_id) since that's what they represent. This makes
the test more future-proof.
2025-09-15 13:42:38 +09:30
Chandra Pratap
bc57dc9b90 fuzz-tests: Make the channel_id wire test roundtrip
Changelog-None: `memcmp()` the output of `towire_channel_id()`
and the input to `fromwire_channel_id()` to ensure that wire
encoding-decoding is correctly performed.
2025-09-15 13:42:38 +09:30
Chandra Pratap
271356f695 fuzz-tests: Add coverage-increasing inputs to seed corpora
Change in the fuzzing scheme of `fuzz-bolt11` led to the
discovery of test inputs that result in greater in code
coverage. Add these inputs to the test's seed corpus.
2025-09-15 13:39:18 +09:30
Chandra Pratap
2a877633a4 fuzz-tests: Remove unnecessary #includes in the BOLT #11 test
The fuzz target for BOLT #11 has some unnecessary #includes.
Get rid of them.
2025-09-15 13:39:18 +09:30
Chandra Pratap
974af91cc6 fuzz-tests: add a check for bolt11_encode()
Changelog-None: Since `bolt11_decode()` defined in `common/bolt11.c`
is untested by the current BOLT #11 fuzz test, add a test for it.
2025-09-15 13:39:18 +09:30
Chandra Pratap
fc549b3bc8 fuzz-tests: Add a seed corpus for the new test
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
2025-09-15 11:31:00 +09:30
Chandra Pratap
69a604fca5 fuzz-tests: add a test for handle_peer_error_or_warning()
Changelog-None: `handle_peer_error_or_warning()` in
`common/read_peer_message.{c, h}` is responsible for parsing any
incoming `error` or `warning` messages as defined in BOLT #1.

Add a test for it.
2025-09-15 11:31:00 +09:30
Chandra Pratap
7b4e182fbe fuzz-tests: order FUZZ_COMMON_OBJS lexicographic
The FUZZ_COMMON_OBJS list roughly follows lexicographic
order. Make it adhere strictly to the order. This makes adding
and reviewing changes to the file easier.
2025-09-15 11:31:00 +09:30
Chandra Pratap
3e96f07635 fuzz-tests: Add coverage-increasing inputs to seed corpora
Improvements in the fuzz-testing scheme of fuzz-bigsize led
to the discovery of test inputs that result in greater in
code-coverage. Add these inputs to the test's seed corpus.
2025-09-15 11:30:08 +09:30
Chandra Pratap
66e0d9c285 fuzz-tests: Add a roundtrip check for bigsize_put()
Add a roundtrip check for `bigsize_put()` using `bigsize_get()`.
This enforces a stricter check for the former and adds a test
for the latter, which is currently untested.
2025-09-15 11:30:08 +09:30
Chandra Pratap
8ab0a01e82 fuzz-tests: Replace hardcoded chunk size with iteration over sizes
Changelog-None: The exisiting fuzz test only extracts chunks of
a fixed size (8) from the fuzzer's input. Replace this with an
iteration over a set of chunk sizes (1 to BIGSIZE_MAX_LEN) for
better coverage.

While at it, get rid of the check `if (bs != 0)` because 0 is a
valid value for bigsize_t as well.
2025-09-15 11:30:08 +09:30
Chandra Pratap
a23dcf67f2 fuzz-tests: Add coverage-increasing inputs to seed corpora
Change in the fuzz-testing scheme of fuzz-addr led to the
discovery of test inputs that result in greater in code
coverage. Add these inputs to the test's seed corpus.
2025-09-15 11:28:20 +09:30
Chandra Pratap
763be38e6d fuzz-tests: verify round‑trip scriptpubkey <-> addr conversion
Changelog-None: Currently, fuzz-addr only tests encoding via
encode_scriptpubkey_to_addr(), without checking decoding. Add a
round‑trip assertion: if encoding produces an address, decode
it back with decode_scriptpubkey_from_addr() and confirm the
result matches the original scriptpubkey.
2025-09-15 11:28:20 +09:30
Chandra Pratap
c7052b7d27 fuzz-tests: Add a seed corpus for the new test
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
2025-09-15 11:28:07 +09:30
Chandra Pratap
871ae75b5e fuzz-tests: Add fuzz target for closing_sig
Changelog-None: 'closing_signed' and 'closing_sig' are
channel closing negotiation messages defined in BOLT #2.

While 'closing_signed' has a wire fuzz test, 'closing_sig'
does not. Add a test to perform a round-trip encoding check
(towire -> fromwire) similar to the other wire fuzzers.
2025-09-15 11:28:07 +09:30
Chandra Pratap
59ccced19d fuzz-tests: Add a seed corpus for the new test
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
2025-09-15 11:21:25 +09:30
Chandra Pratap
0b401a92f2 fuzz-tests: Add fuzz target for closing_complete
Changelog-None: 'closing_signed' and 'closing_complete'
are channel closing negotiation messages defined in BOLT #2.

While 'closing_signed' has a wire fuzz test, 'closing_complete'
does not. Add a test to perform a round-trip encoding check
(towire -> fromwire) similar to the other wire fuzzers.
2025-09-15 11:21:25 +09:30
Chandra Pratap
a1c554fd76 fuzz-tests: Add coverage increasing inputs to seed corpora
Improvements in the fuzz-testing scheme of
`fuzz-bolt12-invrequest-decode` led to the discovery of test inputs
that result in greater in code coverage.

Add these inputs to the test's seed corpus.
2025-08-06 13:53:49 +09:30
Chandra Pratap
d9685a6c63 fuzz-tests: Make fuzz-bolt12-invrequest-decode roundrip
Changelog-None: Currently, the `BOLT #12` invrequest parsing test
only tests the invrequest decode function. Add a test for the
encoding function as well by making the test roundtrip.
2025-08-06 13:53:49 +09:30
Chandra Pratap
de5e4fe9ca fuzz-tests: Add a seed corpus for the new test
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
2025-07-08 14:47:36 +09:30
Chandra Pratap
61bf4ffc35 fuzz-tests: Add differential test for HMAC-SHA256
Changelog-None: Add a differential fuzz test for
HMAC-SHA256, similar to those for SHA256 and RIPEMD160,
to verify CCAN’s implementation against OpenSSL’s.
2025-07-08 14:47:36 +09:30
Chandra Pratap
0651b37ae4 fuzz-tests: Add coverage-increasing inputs to seed corpora
Change in the fuzz-testing scheme of fuzz-base32-64 led to
the discovery of test inputs that result in greater in
code-coverage. Add these inputs to the test's seed corpus.
2025-07-08 12:54:56 +09:30
Chandra Pratap
e721b0a89a fuzz-tests: Enhance b64_encode() validation with roundtrip decoding
Changelog-None: Currently, fuzz testing for b64_encode() merely
encodes input and frees the result, providing no real verification
of its behavior.

Introduce a new b64_decode() function (modeled after b32_decode())
and update the fuzz test to perform a roundtrip—encoding followed
by decoding—to ensure that b64_encode() correctly preserves the
original data.
2025-07-08 12:54:56 +09:30
Dusty Daemon
e928817fa7 splice: Update to Eclair style of reestablish
Update to use Eclair’s spec’d version of reestablish.

Changelog-None
2025-05-13 14:52:15 +09:30
Richard Myers
940b6a3af2 splice: Add splice_txid to splice_locked message 2025-05-13 14:52:15 +09:30
Matt Morehouse
2811614c37 fuzz: don't fail when fuzzer generates valid Act 1 or 2 packets
The handshake targets were based on a false premise: that it is
impossible for any fuzzer to generate valid Act 1 or 2 packets. Niklas
Gogge proved this premise incorrect using AFL++ with the CMPLOG feature,
which enabled AFL++ to generate such valid packets.

We modify the targets to allow the scenario where the fuzzer finds these
valid packets and add the inputs AFL++ found to the corpus.
2025-04-15 19:53:47 +09:30
Matt Morehouse
2b5140fbcd fuzz: don't fail when fuzzer generates valid MAC
The cryptofuzz target was based on a false premise: that it is
impossible for any fuzzer to generate a valid ciphertext+MAC for the
decrypt function. Niklas Gogge proved this premise incorrect using AFL++
with the CMPLOG feature, which enabled AFL++ to generate such valid
messages.

We remove the assertions requiring decryption to fail and add the inputs
AFL++ found to the corpus.
2025-04-15 19:53:47 +09:30
Rusty Russell
67c91a7e5c BOLTs: Update to version with peer storage merged.
Unfortunately a spec typo means the data fields are missing (PR pending),
so we still patch those in.

The message "your_peer_storage" got renamed to "peer_storage_retrieval",
and the option "want_peer_backup_storage" was removed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `experimental-peer-storage` now only advertizes feature 43, not 41.
2025-03-18 14:30:58 +10:30
Dusty Daemon
2b3cb8b8a8 splice: Update splice signature msg type
Update to use spec signature type.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
d077fd59c9 splice: Remove blockhash from peer msg
This is no longer used.

Changelog-None
2024-11-21 14:15:36 +10:30
Dusty Daemon
2e92fdc507 interactivetx: Add support for shared prevtx
It is possible for prevtx to be larger than max packet size, so for shared outputs (currently only the funding tx) we add support for sending the `txid` only across the wire and filling in the prevtx locally.

Changelog-None
2024-11-21 14:15:36 +10:30
ShahanaFarooqui
e352a72e5e shellcheck: shellcheck fixes 2024-11-19 09:05:55 +10:30
Rusty Russell
3ad7167cfa fuzz: fix up compilation with hsmtool change.
```
tests/fuzz/fuzz-hsm_encryption.c:28:80: error: passing 'char **' to parameter of type 'const char **' discards qualifiers in nested pointer types [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
                assert(!hsm_secret_encryption_key_with_exitcode(passphrase, &encryption_key, &emsg));
                                                                                             ^~~~~
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-11-13 13:24:06 +10:30
Rusty Russell
45533584e2 global: rename blinding to path_key everywhere.
Get with the modern nomenclature: the pubkey inside a blinded path is called
the `path_key` now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-16 07:14:32 +10:30
Rusty Russell
dc18f3cd7b BOLTs: update which renames blinding terminology.
No code changes, just catching up with the BOLT changes which rework our
blinded path terminology (for the better!).

Another patch will sweep the rest of our internal names, this tries only to
make things compile and fix up the BOLT quotes.

1. Inside payload: current_blinding_point -> current_path_key
2. Inside update_add_htlc TLV: blinding_point -> blinded_path
3. Inside blinded_path: blinding -> first_path_key
4. Inside onion_message: blinding -> path_key.
5. Inside encrypted_data_tlv: next_blinding_override -> next_path_key_override

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-16 07:14:32 +10:30
Niklas Gögge
259015720e fuzz: Add input for from_bech32_charset off-by-one bug 2024-06-20 10:53:50 +09:30
Rusty Russell
7d3d763b96 channeld: BOLT update, no longer allow creation of old (experimental-only!) non-zero-fee anchor channels.
These were removed from the spec.

We still support existing ones, though we were the only implementation
which ever did, and only in experimental mode, so we should be able to
upgrade them and avoid a forced close, with a bit of engineering...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-19 15:54:24 +09:30
Rusty Russell
b6d7ee1f11 common: No longer support new channels without option_static_remotekey.
We still support *existing* channels.  Just not new ones (before they could,
in theory, explicitly ask for one).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-19 15:54:24 +09:30
Rusty Russell
cb2c4963f2 bolt12: allow first_node_id in blinded path to be a scid.
We don't actually support it yet, but this threads through the type change,
puts it in "decode" etc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
9450d46db1 bitcoin/short_channel_id: pass by copy everywhere.
It's a u64, we should pass by copy.  This is a big sweeping change,
but mainly mechanical (change one, compile, fix breakage, repeat).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
e0e879c003 common: remove type_to_string files altogther.
This means including <common/utils.h> where it was indirectly included.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
df44431f8c common: add tal_arr_eq helper.
We do `memeq(a, tal_bytelen(a), b, tal_bytelen(b))` remarkably often...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
niftynei
bc98cafe9e dual-fund: add require_confirmed_inputs to RBF flows
We now require peers to reaffirm their preference for
`require_confirmed_inputs` when executing an RBF.

Requested-By: @t-bast
2024-02-11 10:46:40 +01:00
Matt Morehouse
25b40d2ce8 fuzz: use explicit fetching for digest algorithms
For better performance it is recommended to use the modern OpenSSL
EVP_MD_fetch API to load digest algorithms (i.e. explicit fetching),
instead of the older implicit fetching API.

As a side effect, using this API seems to avoid memory leaks with some
versions of OpenSSL.
2024-02-04 17:16:01 +01:00
Matt Morehouse
3260d7dd5e fuzz: initial fuzz-bolt12-invoice-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
1c18269cd1 fuzz: initial fuzz-bolt12-invrequest-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
2073d9771d fuzz: initial fuzz-bolt12-offer-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
3af61e087c fuzz: initial fuzz-bolt12-bech32-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
7d05f07a2b fuzz: test bolt12 decoding
Add fuzz targets for decoding of offers, invoice requests, and invoices.
Mutators are shared in bolt12.h.
2024-01-23 20:21:48 +10:30