Commit Graph

172 Commits

Author SHA1 Message Date
Chandra Pratap
d6a7c29af0 fuzz-tests: Add a test for codex32 operations
Changelog-None: Add a test for `codex32_encode()` and
`codex32_secret_decode()` defined in `common/codex32.{c, h}`.
2025-09-22 11:03:54 +09:30
Chandra Pratap
6e16f94443 fuzz-tests: Add coverage-increasing inputs to seed corpora
Change in the fuzzing scheme of fuzz-bech32 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-22 10:23:24 +09:30
Chandra Pratap
b6a1c97c41 fuzz-tests: test 8-to-5 bit conversion
Currently, the test only verifies the 5-to-8 bit conversion. Replace
it with a roundtrip check that verifies 8-to-5 bit conversion as well.
2025-09-22 10:23:24 +09:30
Chandra Pratap
f4fdb1962a fuzz-tests: Test over all possible witness version values
According to `common/bech32.h`, the valid values of witness
program version are between 0 and 16 (inclusive). Update the
test to iterate over all of these values.
2025-09-22 10:23:24 +09:30
Chandra Pratap
83894faa21 fuzz-tests: Replace manual allocations with tal_arr()
Changelog-None: Use the common library utilities for temporary
allocations instead of manually calling `malloc` and `free`.

This makes the code conformant with rest of the codebase and
reduces the chances of leaks.
2025-09-22 10:23:24 +09:30
Chandra Pratap
5cc8d0ad78 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-22 10:21:27 +09:30
Chandra Pratap
48ced70f9a fuzz-tests: Add a test for calculate_our_funding()
Changelog-None: `calculate_our_funding()` in `plugins/funder_policy.c`
is responsible for calculating our funding policy. Add a test for it.
2025-09-22 10:21:27 +09:30
Chandra Pratap
6f4cfedeea fuzz-tests: Add coverage-increasing inputs to seed corpora
Change in the fuzzing scheme of `fuzz-close_tx` 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:43:40 +09:30
Chandra Pratap
20e252b548 fuzz-tests: fix overflow of u32 in fuzz-close-tx
Changelog-None: The value WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX
is equal to 2.1e15, which is much higher than the maximum capacity
of a u32, which is 4.29e9.

Hence, use a u64 to store this value instead.
2025-09-15 13:43:40 +09:30
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