From 5bfa819075a489f6b9241519b154958ad08b1e18 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 10 Apr 2026 12:00:13 +0200 Subject: [PATCH] Replace hashes_fuzz with local fuzz gates --- Cargo.toml | 1 - ci/check-compiles.sh | 2 +- fuzz/.cargo/config.toml | 2 +- fuzz/Cargo.toml | 1 - fuzz/README.md | 2 +- fuzz/ci-fuzz.sh | 2 +- fuzz/src/bin/base32_target.rs | 3 - fuzz/src/bin/bech32_parse_target.rs | 3 - fuzz/src/bin/bolt11_deser_target.rs | 3 - fuzz/src/bin/chanmon_consistency_target.rs | 3 - fuzz/src/bin/chanmon_deser_target.rs | 3 - fuzz/src/bin/feature_flags_target.rs | 3 - fuzz/src/bin/fromstr_to_netaddress_target.rs | 3 - fuzz/src/bin/fs_store_target.rs | 3 - fuzz/src/bin/full_stack_target.rs | 3 - fuzz/src/bin/gossip_discovery_target.rs | 3 - fuzz/src/bin/indexedmap_target.rs | 3 - fuzz/src/bin/invoice_deser_target.rs | 3 - fuzz/src/bin/invoice_request_deser_target.rs | 3 - fuzz/src/bin/lsps_message_target.rs | 3 - fuzz/src/bin/msg_accept_channel_target.rs | 3 - fuzz/src/bin/msg_accept_channel_v2_target.rs | 3 - .../bin/msg_announcement_signatures_target.rs | 3 - .../bin/msg_blinded_message_path_target.rs | 3 - .../bin/msg_channel_announcement_target.rs | 3 - fuzz/src/bin/msg_channel_details_target.rs | 3 - fuzz/src/bin/msg_channel_ready_target.rs | 3 - .../src/bin/msg_channel_reestablish_target.rs | 3 - fuzz/src/bin/msg_channel_update_target.rs | 3 - fuzz/src/bin/msg_closing_complete_target.rs | 3 - fuzz/src/bin/msg_closing_sig_target.rs | 3 - fuzz/src/bin/msg_closing_signed_target.rs | 3 - fuzz/src/bin/msg_commitment_signed_target.rs | 3 - .../msg_decoded_onion_error_packet_target.rs | 3 - fuzz/src/bin/msg_error_message_target.rs | 3 - fuzz/src/bin/msg_funding_created_target.rs | 3 - fuzz/src/bin/msg_funding_signed_target.rs | 3 - .../bin/msg_gossip_timestamp_filter_target.rs | 3 - fuzz/src/bin/msg_init_target.rs | 3 - fuzz/src/bin/msg_node_announcement_target.rs | 3 - fuzz/src/bin/msg_open_channel_target.rs | 3 - fuzz/src/bin/msg_open_channel_v2_target.rs | 3 - fuzz/src/bin/msg_ping_target.rs | 3 - fuzz/src/bin/msg_pong_target.rs | 3 - .../src/bin/msg_query_channel_range_target.rs | 3 - .../bin/msg_query_short_channel_ids_target.rs | 3 - .../src/bin/msg_reply_channel_range_target.rs | 3 - .../msg_reply_short_channel_ids_end_target.rs | 3 - fuzz/src/bin/msg_revoke_and_ack_target.rs | 3 - fuzz/src/bin/msg_shutdown_target.rs | 3 - fuzz/src/bin/msg_splice_ack_target.rs | 3 - fuzz/src/bin/msg_splice_init_target.rs | 3 - fuzz/src/bin/msg_splice_locked_target.rs | 3 - fuzz/src/bin/msg_stfu_target.rs | 3 - fuzz/src/bin/msg_tx_abort_target.rs | 3 - fuzz/src/bin/msg_tx_ack_rbf_target.rs | 3 - fuzz/src/bin/msg_tx_add_input_target.rs | 3 - fuzz/src/bin/msg_tx_add_output_target.rs | 3 - fuzz/src/bin/msg_tx_complete_target.rs | 3 - fuzz/src/bin/msg_tx_init_rbf_target.rs | 3 - fuzz/src/bin/msg_tx_remove_input_target.rs | 3 - fuzz/src/bin/msg_tx_remove_output_target.rs | 3 - fuzz/src/bin/msg_tx_signatures_target.rs | 3 - fuzz/src/bin/msg_update_add_htlc_target.rs | 3 - fuzz/src/bin/msg_update_fail_htlc_target.rs | 3 - .../msg_update_fail_malformed_htlc_target.rs | 3 - fuzz/src/bin/msg_update_fee_target.rs | 3 - .../src/bin/msg_update_fulfill_htlc_target.rs | 3 - fuzz/src/bin/offer_deser_target.rs | 3 - fuzz/src/bin/onion_hop_data_target.rs | 3 - fuzz/src/bin/onion_message_target.rs | 3 - fuzz/src/bin/peer_crypt_target.rs | 3 - fuzz/src/bin/process_network_graph_target.rs | 3 - fuzz/src/bin/process_onion_failure_target.rs | 3 - fuzz/src/bin/refund_deser_target.rs | 3 - fuzz/src/bin/router_target.rs | 3 - fuzz/src/bin/static_invoice_deser_target.rs | 3 - fuzz/src/bin/target_template.txt | 3 - fuzz/src/bin/zbase32_target.rs | 3 - fuzz/src/chanmon_consistency.rs | 37 ++++++---- fuzz/src/full_stack.rs | 73 +++++++++++++------ fuzz/src/lib.rs | 3 - lightning-liquidity/Cargo.toml | 1 + lightning-liquidity/src/lsps2/utils.rs | 19 ++++- lightning/src/crypto/chacha20poly1305rfc.rs | 6 +- lightning/src/crypto/mod.rs | 9 --- lightning/src/crypto/streams.rs | 8 +- lightning/src/ln/inbound_payment.rs | 17 ++--- lightning/src/ln/onion_payment.rs | 4 +- lightning/src/ln/onion_utils.rs | 10 ++- lightning/src/util/fuzz_wrappers.rs | 38 ++++++++++ 91 files changed, 157 insertions(+), 297 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7978d9de6a0..e8ecaf932a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,6 @@ level = "forbid" check-cfg = [ "cfg(fuzzing)", "cfg(secp256k1_fuzz)", - "cfg(hashes_fuzz)", "cfg(test)", "cfg(debug_assertions)", "cfg(c_bindings)", diff --git a/ci/check-compiles.sh b/ci/check-compiles.sh index a067861fb56..c141ac919cf 100755 --- a/ci/check-compiles.sh +++ b/ci/check-compiles.sh @@ -5,6 +5,6 @@ echo "Testing $(git log -1 --oneline)" cargo check cargo doc cargo doc --document-private-items -cd fuzz && RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo check --features=stdin_fuzz +cd fuzz && RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz" cargo check --features=stdin_fuzz cd ../lightning && cargo check --no-default-features cd .. && RUSTC_BOOTSTRAP=1 RUSTFLAGS="--cfg=c_bindings" cargo check -Z avoid-dev-deps diff --git a/fuzz/.cargo/config.toml b/fuzz/.cargo/config.toml index 86513788566..4ca5cb3604c 100644 --- a/fuzz/.cargo/config.toml +++ b/fuzz/.cargo/config.toml @@ -1,2 +1,2 @@ [build] -rustflags = ["--cfg=fuzzing", "--cfg=secp256k1_fuzz", "--cfg=hashes_fuzz"] +rustflags = ["--cfg=fuzzing", "--cfg=secp256k1_fuzz"] diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 5a2e397a064..5528515752a 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -61,5 +61,4 @@ level = "forbid" check-cfg = [ "cfg(fuzzing)", "cfg(secp256k1_fuzz)", - "cfg(hashes_fuzz)", ] diff --git a/fuzz/README.md b/fuzz/README.md index 4af70390d7d..40f1a4b91e9 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -62,7 +62,7 @@ To run fuzzing using `cargo-fuzz / libFuzzer`, run ```shell rustup install nightly # Note: libFuzzer requires a nightly version of rust. -export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" +export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz" cargo +nightly fuzz run --features "libfuzzer_fuzz" msg_ping_target ``` Note: If you encounter a `SIGKILL` during run/build check for OOM in kernel logs and consider diff --git a/fuzz/ci-fuzz.sh b/fuzz/ci-fuzz.sh index 47bf41ba620..0bc561cdd8c 100755 --- a/fuzz/ci-fuzz.sh +++ b/fuzz/ci-fuzz.sh @@ -13,7 +13,7 @@ rm *_target.rs [ "$(git diff)" != "" ] && exit 1 popd -export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz" +export RUSTFLAGS="--cfg=secp256k1_fuzz" mkdir -p hfuzz_workspace/full_stack_target/input pushd write-seeds diff --git a/fuzz/src/bin/base32_target.rs b/fuzz/src/bin/base32_target.rs index e79e6db7380..dd232bf8213 100644 --- a/fuzz/src/bin/base32_target.rs +++ b/fuzz/src/bin/base32_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/bech32_parse_target.rs b/fuzz/src/bin/bech32_parse_target.rs index f9493bb1bc1..a459d74fa6d 100644 --- a/fuzz/src/bin/bech32_parse_target.rs +++ b/fuzz/src/bin/bech32_parse_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/bolt11_deser_target.rs b/fuzz/src/bin/bolt11_deser_target.rs index 28b1e2db679..ceb5dea9903 100644 --- a/fuzz/src/bin/bolt11_deser_target.rs +++ b/fuzz/src/bin/bolt11_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/chanmon_consistency_target.rs b/fuzz/src/bin/chanmon_consistency_target.rs index 7649900bae5..34abd49e97d 100644 --- a/fuzz/src/bin/chanmon_consistency_target.rs +++ b/fuzz/src/bin/chanmon_consistency_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/chanmon_deser_target.rs b/fuzz/src/bin/chanmon_deser_target.rs index d3cf30b86e3..d895c59af81 100644 --- a/fuzz/src/bin/chanmon_deser_target.rs +++ b/fuzz/src/bin/chanmon_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/feature_flags_target.rs b/fuzz/src/bin/feature_flags_target.rs index b1f35f8820f..e4476e041a9 100644 --- a/fuzz/src/bin/feature_flags_target.rs +++ b/fuzz/src/bin/feature_flags_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/fromstr_to_netaddress_target.rs b/fuzz/src/bin/fromstr_to_netaddress_target.rs index 8f3e5c3dc7f..d91992dfc0c 100644 --- a/fuzz/src/bin/fromstr_to_netaddress_target.rs +++ b/fuzz/src/bin/fromstr_to_netaddress_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/fs_store_target.rs b/fuzz/src/bin/fs_store_target.rs index 8d84aad7b6b..cf2ff56250a 100644 --- a/fuzz/src/bin/fs_store_target.rs +++ b/fuzz/src/bin/fs_store_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/full_stack_target.rs b/fuzz/src/bin/full_stack_target.rs index c1f20b10af4..2595345cd7d 100644 --- a/fuzz/src/bin/full_stack_target.rs +++ b/fuzz/src/bin/full_stack_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/gossip_discovery_target.rs b/fuzz/src/bin/gossip_discovery_target.rs index 960ba80ec8c..0658693a6ee 100644 --- a/fuzz/src/bin/gossip_discovery_target.rs +++ b/fuzz/src/bin/gossip_discovery_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/indexedmap_target.rs b/fuzz/src/bin/indexedmap_target.rs index 3bc4390fee4..2cb5110aa9f 100644 --- a/fuzz/src/bin/indexedmap_target.rs +++ b/fuzz/src/bin/indexedmap_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/invoice_deser_target.rs b/fuzz/src/bin/invoice_deser_target.rs index 44bf1851a40..da9d3e5b45e 100644 --- a/fuzz/src/bin/invoice_deser_target.rs +++ b/fuzz/src/bin/invoice_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/invoice_request_deser_target.rs b/fuzz/src/bin/invoice_request_deser_target.rs index 06d8f87fa55..5d192eb17ea 100644 --- a/fuzz/src/bin/invoice_request_deser_target.rs +++ b/fuzz/src/bin/invoice_request_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/lsps_message_target.rs b/fuzz/src/bin/lsps_message_target.rs index 37e6f103fb4..8bd25d056bb 100644 --- a/fuzz/src/bin/lsps_message_target.rs +++ b/fuzz/src/bin/lsps_message_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_accept_channel_target.rs b/fuzz/src/bin/msg_accept_channel_target.rs index ee08a5fc344..9fa42ff25c5 100644 --- a/fuzz/src/bin/msg_accept_channel_target.rs +++ b/fuzz/src/bin/msg_accept_channel_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_accept_channel_v2_target.rs b/fuzz/src/bin/msg_accept_channel_v2_target.rs index 2903e111f56..8d8094318d8 100644 --- a/fuzz/src/bin/msg_accept_channel_v2_target.rs +++ b/fuzz/src/bin/msg_accept_channel_v2_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_announcement_signatures_target.rs b/fuzz/src/bin/msg_announcement_signatures_target.rs index 064880abc18..a48e1e85a4a 100644 --- a/fuzz/src/bin/msg_announcement_signatures_target.rs +++ b/fuzz/src/bin/msg_announcement_signatures_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_blinded_message_path_target.rs b/fuzz/src/bin/msg_blinded_message_path_target.rs index 277e04c9656..d8986c24ce9 100644 --- a/fuzz/src/bin/msg_blinded_message_path_target.rs +++ b/fuzz/src/bin/msg_blinded_message_path_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_channel_announcement_target.rs b/fuzz/src/bin/msg_channel_announcement_target.rs index 42e72d54b72..b62fba2bd3f 100644 --- a/fuzz/src/bin/msg_channel_announcement_target.rs +++ b/fuzz/src/bin/msg_channel_announcement_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_channel_details_target.rs b/fuzz/src/bin/msg_channel_details_target.rs index a03a7a44920..28e850a9d8e 100644 --- a/fuzz/src/bin/msg_channel_details_target.rs +++ b/fuzz/src/bin/msg_channel_details_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_channel_ready_target.rs b/fuzz/src/bin/msg_channel_ready_target.rs index a0457815036..96b5da94a8c 100644 --- a/fuzz/src/bin/msg_channel_ready_target.rs +++ b/fuzz/src/bin/msg_channel_ready_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_channel_reestablish_target.rs b/fuzz/src/bin/msg_channel_reestablish_target.rs index b5449a90e37..094e7be21f3 100644 --- a/fuzz/src/bin/msg_channel_reestablish_target.rs +++ b/fuzz/src/bin/msg_channel_reestablish_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_channel_update_target.rs b/fuzz/src/bin/msg_channel_update_target.rs index 9feb6e6c6b4..323cd8d4a24 100644 --- a/fuzz/src/bin/msg_channel_update_target.rs +++ b/fuzz/src/bin/msg_channel_update_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_closing_complete_target.rs b/fuzz/src/bin/msg_closing_complete_target.rs index 22dd97c79c9..774b99ebebe 100644 --- a/fuzz/src/bin/msg_closing_complete_target.rs +++ b/fuzz/src/bin/msg_closing_complete_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_closing_sig_target.rs b/fuzz/src/bin/msg_closing_sig_target.rs index 26058a5277d..511ce541ebd 100644 --- a/fuzz/src/bin/msg_closing_sig_target.rs +++ b/fuzz/src/bin/msg_closing_sig_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_closing_signed_target.rs b/fuzz/src/bin/msg_closing_signed_target.rs index 94408bc2ba9..8466678a81e 100644 --- a/fuzz/src/bin/msg_closing_signed_target.rs +++ b/fuzz/src/bin/msg_closing_signed_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_commitment_signed_target.rs b/fuzz/src/bin/msg_commitment_signed_target.rs index e8987848417..732fda48106 100644 --- a/fuzz/src/bin/msg_commitment_signed_target.rs +++ b/fuzz/src/bin/msg_commitment_signed_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs b/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs index 47d8970b453..cc51305ca94 100644 --- a/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs +++ b/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_error_message_target.rs b/fuzz/src/bin/msg_error_message_target.rs index ee3904a724e..890823e7547 100644 --- a/fuzz/src/bin/msg_error_message_target.rs +++ b/fuzz/src/bin/msg_error_message_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_funding_created_target.rs b/fuzz/src/bin/msg_funding_created_target.rs index 028aa17ad8a..1ccfd228eee 100644 --- a/fuzz/src/bin/msg_funding_created_target.rs +++ b/fuzz/src/bin/msg_funding_created_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_funding_signed_target.rs b/fuzz/src/bin/msg_funding_signed_target.rs index 4894c66df0b..6ad65745144 100644 --- a/fuzz/src/bin/msg_funding_signed_target.rs +++ b/fuzz/src/bin/msg_funding_signed_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs b/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs index 6da383b2e6f..f6980bf05e4 100644 --- a/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs +++ b/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_init_target.rs b/fuzz/src/bin/msg_init_target.rs index f1d17c99289..af2cf6fe4db 100644 --- a/fuzz/src/bin/msg_init_target.rs +++ b/fuzz/src/bin/msg_init_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_node_announcement_target.rs b/fuzz/src/bin/msg_node_announcement_target.rs index b0615f3c5e5..7538416fc2d 100644 --- a/fuzz/src/bin/msg_node_announcement_target.rs +++ b/fuzz/src/bin/msg_node_announcement_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_open_channel_target.rs b/fuzz/src/bin/msg_open_channel_target.rs index b3dbf388c08..543625ef029 100644 --- a/fuzz/src/bin/msg_open_channel_target.rs +++ b/fuzz/src/bin/msg_open_channel_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_open_channel_v2_target.rs b/fuzz/src/bin/msg_open_channel_v2_target.rs index 0df11adf32e..d78c233cba0 100644 --- a/fuzz/src/bin/msg_open_channel_v2_target.rs +++ b/fuzz/src/bin/msg_open_channel_v2_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_ping_target.rs b/fuzz/src/bin/msg_ping_target.rs index 48f855985de..fedccc31c40 100644 --- a/fuzz/src/bin/msg_ping_target.rs +++ b/fuzz/src/bin/msg_ping_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_pong_target.rs b/fuzz/src/bin/msg_pong_target.rs index 434e9cfe310..7d801448f0e 100644 --- a/fuzz/src/bin/msg_pong_target.rs +++ b/fuzz/src/bin/msg_pong_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_query_channel_range_target.rs b/fuzz/src/bin/msg_query_channel_range_target.rs index cb87260e1ef..dcf581100c0 100644 --- a/fuzz/src/bin/msg_query_channel_range_target.rs +++ b/fuzz/src/bin/msg_query_channel_range_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_query_short_channel_ids_target.rs b/fuzz/src/bin/msg_query_short_channel_ids_target.rs index bc286a7e523..d259a7c0f27 100644 --- a/fuzz/src/bin/msg_query_short_channel_ids_target.rs +++ b/fuzz/src/bin/msg_query_short_channel_ids_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_reply_channel_range_target.rs b/fuzz/src/bin/msg_reply_channel_range_target.rs index c7df076c6c6..e133e3724f8 100644 --- a/fuzz/src/bin/msg_reply_channel_range_target.rs +++ b/fuzz/src/bin/msg_reply_channel_range_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs b/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs index 2c73d866bd9..d6bb2b7b52d 100644 --- a/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs +++ b/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_revoke_and_ack_target.rs b/fuzz/src/bin/msg_revoke_and_ack_target.rs index 6379d39591f..db3477c51f4 100644 --- a/fuzz/src/bin/msg_revoke_and_ack_target.rs +++ b/fuzz/src/bin/msg_revoke_and_ack_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_shutdown_target.rs b/fuzz/src/bin/msg_shutdown_target.rs index 6bf0409b7b5..12e076fc071 100644 --- a/fuzz/src/bin/msg_shutdown_target.rs +++ b/fuzz/src/bin/msg_shutdown_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_splice_ack_target.rs b/fuzz/src/bin/msg_splice_ack_target.rs index 96f373d5a1c..7af1b072d5a 100644 --- a/fuzz/src/bin/msg_splice_ack_target.rs +++ b/fuzz/src/bin/msg_splice_ack_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_splice_init_target.rs b/fuzz/src/bin/msg_splice_init_target.rs index 73d4319c44a..941afebbddf 100644 --- a/fuzz/src/bin/msg_splice_init_target.rs +++ b/fuzz/src/bin/msg_splice_init_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_splice_locked_target.rs b/fuzz/src/bin/msg_splice_locked_target.rs index 9210113a0c8..b52e6332939 100644 --- a/fuzz/src/bin/msg_splice_locked_target.rs +++ b/fuzz/src/bin/msg_splice_locked_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_stfu_target.rs b/fuzz/src/bin/msg_stfu_target.rs index d00536c7bcd..fbcff4b7879 100644 --- a/fuzz/src/bin/msg_stfu_target.rs +++ b/fuzz/src/bin/msg_stfu_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_abort_target.rs b/fuzz/src/bin/msg_tx_abort_target.rs index 8f216b46e63..d6f7a730264 100644 --- a/fuzz/src/bin/msg_tx_abort_target.rs +++ b/fuzz/src/bin/msg_tx_abort_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_ack_rbf_target.rs b/fuzz/src/bin/msg_tx_ack_rbf_target.rs index 90b34c7f93f..cf28bf66b42 100644 --- a/fuzz/src/bin/msg_tx_ack_rbf_target.rs +++ b/fuzz/src/bin/msg_tx_ack_rbf_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_add_input_target.rs b/fuzz/src/bin/msg_tx_add_input_target.rs index ce9700bd344..97f4e019210 100644 --- a/fuzz/src/bin/msg_tx_add_input_target.rs +++ b/fuzz/src/bin/msg_tx_add_input_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_add_output_target.rs b/fuzz/src/bin/msg_tx_add_output_target.rs index 02682194e13..8b9e7f3619d 100644 --- a/fuzz/src/bin/msg_tx_add_output_target.rs +++ b/fuzz/src/bin/msg_tx_add_output_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_complete_target.rs b/fuzz/src/bin/msg_tx_complete_target.rs index 48864f053c8..c5dfde5ff81 100644 --- a/fuzz/src/bin/msg_tx_complete_target.rs +++ b/fuzz/src/bin/msg_tx_complete_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_init_rbf_target.rs b/fuzz/src/bin/msg_tx_init_rbf_target.rs index a8b613cdfca..16dd3440742 100644 --- a/fuzz/src/bin/msg_tx_init_rbf_target.rs +++ b/fuzz/src/bin/msg_tx_init_rbf_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_remove_input_target.rs b/fuzz/src/bin/msg_tx_remove_input_target.rs index 1e46c547dbf..42d2ab8751c 100644 --- a/fuzz/src/bin/msg_tx_remove_input_target.rs +++ b/fuzz/src/bin/msg_tx_remove_input_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_remove_output_target.rs b/fuzz/src/bin/msg_tx_remove_output_target.rs index 3a9c178e75f..b825d47622a 100644 --- a/fuzz/src/bin/msg_tx_remove_output_target.rs +++ b/fuzz/src/bin/msg_tx_remove_output_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_tx_signatures_target.rs b/fuzz/src/bin/msg_tx_signatures_target.rs index 77f34cc1f6a..8099b08a121 100644 --- a/fuzz/src/bin/msg_tx_signatures_target.rs +++ b/fuzz/src/bin/msg_tx_signatures_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_update_add_htlc_target.rs b/fuzz/src/bin/msg_update_add_htlc_target.rs index 3ff5cf83dbe..50ed3827fdb 100644 --- a/fuzz/src/bin/msg_update_add_htlc_target.rs +++ b/fuzz/src/bin/msg_update_add_htlc_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_update_fail_htlc_target.rs b/fuzz/src/bin/msg_update_fail_htlc_target.rs index 5b8a7e55dcb..b476efb4393 100644 --- a/fuzz/src/bin/msg_update_fail_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fail_htlc_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs b/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs index e3e8918e492..0874ad20d04 100644 --- a/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_update_fee_target.rs b/fuzz/src/bin/msg_update_fee_target.rs index 98e51181c79..df95d783fa8 100644 --- a/fuzz/src/bin/msg_update_fee_target.rs +++ b/fuzz/src/bin/msg_update_fee_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/msg_update_fulfill_htlc_target.rs b/fuzz/src/bin/msg_update_fulfill_htlc_target.rs index cb156448e13..af9a062f336 100644 --- a/fuzz/src/bin/msg_update_fulfill_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fulfill_htlc_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/offer_deser_target.rs b/fuzz/src/bin/offer_deser_target.rs index c4a03f628b3..cb6bf8b0e8f 100644 --- a/fuzz/src/bin/offer_deser_target.rs +++ b/fuzz/src/bin/offer_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/onion_hop_data_target.rs b/fuzz/src/bin/onion_hop_data_target.rs index 3b9b55bbfa9..b9f1880fe0b 100644 --- a/fuzz/src/bin/onion_hop_data_target.rs +++ b/fuzz/src/bin/onion_hop_data_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/onion_message_target.rs b/fuzz/src/bin/onion_message_target.rs index bb343e9de83..14941be52ec 100644 --- a/fuzz/src/bin/onion_message_target.rs +++ b/fuzz/src/bin/onion_message_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/peer_crypt_target.rs b/fuzz/src/bin/peer_crypt_target.rs index c68111deb06..314d5339ff6 100644 --- a/fuzz/src/bin/peer_crypt_target.rs +++ b/fuzz/src/bin/peer_crypt_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/process_network_graph_target.rs b/fuzz/src/bin/process_network_graph_target.rs index 7da2aafe3c8..127c69064fc 100644 --- a/fuzz/src/bin/process_network_graph_target.rs +++ b/fuzz/src/bin/process_network_graph_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/process_onion_failure_target.rs b/fuzz/src/bin/process_onion_failure_target.rs index 9e1cc8aa6d0..bfbb0f171d2 100644 --- a/fuzz/src/bin/process_onion_failure_target.rs +++ b/fuzz/src/bin/process_onion_failure_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/refund_deser_target.rs b/fuzz/src/bin/refund_deser_target.rs index 13837d2be73..9f4dc9344f0 100644 --- a/fuzz/src/bin/refund_deser_target.rs +++ b/fuzz/src/bin/refund_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/router_target.rs b/fuzz/src/bin/router_target.rs index 52a8c3408ff..72fc807ffa6 100644 --- a/fuzz/src/bin/router_target.rs +++ b/fuzz/src/bin/router_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/static_invoice_deser_target.rs b/fuzz/src/bin/static_invoice_deser_target.rs index 477f7869e7f..ea641ca9136 100644 --- a/fuzz/src/bin/static_invoice_deser_target.rs +++ b/fuzz/src/bin/static_invoice_deser_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/target_template.txt b/fuzz/src/bin/target_template.txt index 9b0dff8eb8c..90e5435db22 100644 --- a/fuzz/src/bin/target_template.txt +++ b/fuzz/src/bin/target_template.txt @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/bin/zbase32_target.rs b/fuzz/src/bin/zbase32_target.rs index 68c8cf3e19c..d06d7f5daa5 100644 --- a/fuzz/src/bin/zbase32_target.rs +++ b/fuzz/src/bin/zbase32_target.rs @@ -16,9 +16,6 @@ #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index f20f93c789c..3fff7b08c2a 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -568,12 +568,18 @@ type ChanMan<'a> = ChannelManager< >; #[inline] -fn get_payment_secret_hash(dest: &ChanMan, payment_ctr: &mut u64) -> (PaymentSecret, PaymentHash) { +fn get_payment_secret_hash( + dest: &ChanMan, payment_ctr: &mut u64, + payment_preimages: &RefCell>, +) -> (PaymentSecret, PaymentHash) { *payment_ctr += 1; - let payment_hash = PaymentHash(Sha256::hash(&[*payment_ctr as u8]).to_byte_array()); + let mut payment_preimage = PaymentPreimage([0; 32]); + payment_preimage.0[0..8].copy_from_slice(&payment_ctr.to_be_bytes()); + let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0).to_byte_array()); let payment_secret = dest .create_inbound_payment_for_hash(payment_hash, None, 3600, None) .expect("create_inbound_payment_for_hash failed"); + assert!(payment_preimages.borrow_mut().insert(payment_hash, payment_preimage).is_none()); (payment_secret, payment_hash) } @@ -1342,10 +1348,8 @@ pub fn do_test(data: &[u8], out: Out) { // Create 3 channels between A-B and 3 channels between B-C (6 total). // - // Use version numbers 1-6 to avoid txid collisions under fuzz hashing. - // Fuzz mode uses XOR-based hashing (all bytes XOR to one byte), and - // versions 0-5 cause collisions between A-B and B-C channel pairs - // (e.g., A-B with Version(1) collides with B-C with Version(3)). + // Use distinct version numbers for each funding transaction so each test channel gets its own + // txid and funding outpoint. // A-B: channel 2 A and B have 0-reserve (trusted open + trusted accept), // channel 3 A has 0-reserve (trusted accept) make_channel!(nodes[0], nodes[1], monitor_a, monitor_b, keys_manager_b, 1, false, false); @@ -1422,6 +1426,8 @@ pub fn do_test(data: &[u8], out: Out) { let resolved_payments: RefCell<[HashMap>; 3]> = RefCell::new([new_hash_map(), new_hash_map(), new_hash_map()]); let claimed_payment_hashes: RefCell> = RefCell::new(HashSet::new()); + let payment_preimages: RefCell> = + RefCell::new(new_hash_map()); macro_rules! test_return { () => {{ @@ -1935,9 +1941,8 @@ pub fn do_test(data: &[u8], out: Out) { macro_rules! process_events { ($node: expr, $fail: expr) => {{ - // In case we get 256 payments we may have a hash collision, resulting in the - // second claim/fail call not finding the duplicate-hash HTLC, so we have to - // deduplicate the calls here. + // Multiple HTLCs can resolve for the same payment hash, so deduplicate + // claim/fail handling per event batch. let mut claim_set = new_hash_map(); let mut events = nodes[$node].get_and_clear_pending_events(); let had_events = !events.is_empty(); @@ -1950,7 +1955,11 @@ pub fn do_test(data: &[u8], out: Out) { if $fail { nodes[$node].fail_htlc_backwards(&payment_hash); } else { - nodes[$node].claim_funds(PaymentPreimage(payment_hash.0)); + let payment_preimage = *payment_preimages + .borrow() + .get(&payment_hash) + .expect("PaymentClaimable for unknown payment hash"); + nodes[$node].claim_funds(payment_preimage); claimed_payment_hashes.borrow_mut().insert(payment_hash); } } @@ -2090,7 +2099,7 @@ pub fn do_test(data: &[u8], out: Out) { |source_idx: usize, dest_idx: usize, dest_chan_id, amt, payment_ctr: &mut u64| { let source = &nodes[source_idx]; let dest = &nodes[dest_idx]; - let (secret, hash) = get_payment_secret_hash(dest, payment_ctr); + let (secret, hash) = get_payment_secret_hash(dest, payment_ctr, &payment_preimages); let mut id = PaymentId([0; 32]); id.0[0..8].copy_from_slice(&payment_ctr.to_ne_bytes()); let succeeded = send_payment(source, dest, dest_chan_id, amt, secret, hash, id); @@ -2113,7 +2122,7 @@ pub fn do_test(data: &[u8], out: Out) { let source = &nodes[source_idx]; let middle = &nodes[middle_idx]; let dest = &nodes[dest_idx]; - let (secret, hash) = get_payment_secret_hash(dest, payment_ctr); + let (secret, hash) = get_payment_secret_hash(dest, payment_ctr, &payment_preimages); let mut id = PaymentId([0; 32]); id.0[0..8].copy_from_slice(&payment_ctr.to_ne_bytes()); let succeeded = send_hop_payment( @@ -2140,7 +2149,7 @@ pub fn do_test(data: &[u8], out: Out) { payment_ctr: &mut u64| { let source = &nodes[source_idx]; let dest = &nodes[dest_idx]; - let (secret, hash) = get_payment_secret_hash(dest, payment_ctr); + let (secret, hash) = get_payment_secret_hash(dest, payment_ctr, &payment_preimages); let mut id = PaymentId([0; 32]); id.0[0..8].copy_from_slice(&payment_ctr.to_ne_bytes()); let succeeded = send_mpp_payment(source, dest, dest_chan_ids, amt, secret, hash, id); @@ -2160,7 +2169,7 @@ pub fn do_test(data: &[u8], out: Out) { let source = &nodes[source_idx]; let middle = &nodes[middle_idx]; let dest = &nodes[dest_idx]; - let (secret, hash) = get_payment_secret_hash(dest, payment_ctr); + let (secret, hash) = get_payment_secret_hash(dest, payment_ctr, &payment_preimages); let mut id = PaymentId([0; 32]); id.0[0..8].copy_from_slice(&payment_ctr.to_ne_bytes()); let succeeded = send_mpp_hop_payment( diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index c1d7982e5e4..09a77e1f97d 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -40,7 +40,7 @@ use lightning::chain::chaininterface::{ use lightning::chain::chainmonitor; use lightning::chain::transaction::OutPoint; use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen}; -use lightning::events::Event; +use lightning::events::{Event, PaymentPurpose}; use lightning::ln::channel_state::ChannelDetails; use lightning::ln::channelmanager::{ChainParameters, ChannelManager, InterceptId, PaymentId}; use lightning::ln::functional_test_utils::*; @@ -113,6 +113,13 @@ pub fn slice_to_be24(v: &[u8]) -> u32 { ((v[2] as u32) << 8*0) } +#[derive(Clone, Copy)] +struct ReceivedPayment { + payment_hash: PaymentHash, + payment_preimage: Option, + payment_secret: Option, +} + struct InputData { data: Vec, read_pos: AtomicUsize, @@ -651,7 +658,7 @@ pub fn do_test(mut data: &[u8], logger: &Arc let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), peer_manager); - let mut payments_received: Vec = Vec::new(); + let mut payments_received: Vec = Vec::new(); let mut intercepted_htlcs: Vec = Vec::new(); let mut payments_sent: u16 = 0; let mut pending_funding_generation: Vec<(ChannelId, PublicKey, u64, ScriptBuf)> = Vec::new(); @@ -736,14 +743,14 @@ pub fn do_test(mut data: &[u8], logger: &Arc payment_params, final_value_msat, ); - let mut payment_hash = PaymentHash([0; 32]); - payment_hash.0[0..2].copy_from_slice(&be16_to_array(payments_sent)); - payment_hash.0 = Sha256::hash(&payment_hash.0[..]).to_byte_array(); + let mut payment_preimage = PaymentPreimage([0; 32]); + payment_preimage.0[0..2].copy_from_slice(&be16_to_array(payments_sent)); + let payment_id = PaymentId(payment_preimage.0); payments_sent += 1; - let _ = channelmanager.send_payment( - payment_hash, + let _ = channelmanager.send_spontaneous_payment( + Some(payment_preimage), RecipientOnionFields::spontaneous_empty(final_value_msat), - PaymentId(payment_hash.0), + payment_id, params, Retry::Attempts(2), ); @@ -822,16 +829,24 @@ pub fn do_test(mut data: &[u8], logger: &Arc }, 8 => { for payment in payments_received.drain(..) { - // SHA256 is defined as XOR of all input bytes placed in the first byte, and 0s - // for the remaining bytes. Thus, if not all remaining bytes are 0s we cannot - // fulfill this HTLC, but if they are, we can just take the first byte and - // place that anywhere in our preimage. - if &payment.0[1..] != &[0; 31] { - channelmanager.fail_htlc_backwards(&payment); + if let Some(payment_preimage) = payment.payment_preimage { + let expected_hash = + PaymentHash(Sha256::hash(&payment_preimage.0[..]).to_byte_array()); + if expected_hash == payment.payment_hash { + channelmanager.claim_funds(payment_preimage); + } else { + channelmanager.fail_htlc_backwards(&payment.payment_hash); + } + } else if let Some(payment_secret) = payment.payment_secret { + match channelmanager.get_payment_preimage( + payment.payment_hash, + payment_secret, + ) { + Ok(payment_preimage) => channelmanager.claim_funds(payment_preimage), + Err(_) => channelmanager.fail_htlc_backwards(&payment.payment_hash), + } } else { - let mut payment_preimage = PaymentPreimage([0; 32]); - payment_preimage.0[0] = payment.0[0]; - channelmanager.claim_funds(payment_preimage); + channelmanager.fail_htlc_backwards(&payment.payment_hash); } } }, @@ -839,13 +854,11 @@ pub fn do_test(mut data: &[u8], logger: &Arc let payment_preimage = PaymentPreimage(keys_manager.get_secure_random_bytes()); let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).to_byte_array()); - // Note that this may fail - our hashes may collide and we'll end up trying to - // double-register the same payment_hash. let _ = channelmanager.create_inbound_payment_for_hash(payment_hash, None, 1, None); }, 9 => { for payment in payments_received.drain(..) { - channelmanager.fail_htlc_backwards(&payment); + channelmanager.fail_htlc_backwards(&payment.payment_hash); } }, 10 => { @@ -1118,9 +1131,25 @@ pub fn do_test(mut data: &[u8], logger: &Arc output_script, )); }, - Event::PaymentClaimable { payment_hash, .. } => { + Event::PaymentClaimable { payment_hash, purpose, .. } => { //TODO: enhance by fetching random amounts from fuzz input? - payments_received.push(payment_hash); + let payment_secret = match &purpose { + PaymentPurpose::Bolt11InvoicePayment { payment_secret, .. } => { + Some(*payment_secret) + }, + PaymentPurpose::Bolt12OfferPayment { payment_secret, .. } => { + Some(*payment_secret) + }, + PaymentPurpose::Bolt12RefundPayment { payment_secret, .. } => { + Some(*payment_secret) + }, + PaymentPurpose::SpontaneousPayment(_) => None, + }; + payments_received.push(ReceivedPayment { + payment_hash, + payment_preimage: purpose.preimage(), + payment_secret, + }); }, Event::HTLCIntercepted { intercept_id, .. } => { if !intercepted_htlcs.contains(&intercept_id) { diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index 5f429ea2c3b..25c2fffa23e 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -15,9 +15,6 @@ extern crate lightning_rapid_gossip_sync; #[cfg(not(fuzzing))] compile_error!("Fuzz targets need cfg=fuzzing"); -#[cfg(not(hashes_fuzz))] -compile_error!("Fuzz targets need cfg=hashes_fuzz"); - #[cfg(not(secp256k1_fuzz))] compile_error!("Fuzz targets need cfg=secp256k1_fuzz"); diff --git a/lightning-liquidity/Cargo.toml b/lightning-liquidity/Cargo.toml index cc7fb0c0f08..2ddc2a92ccc 100644 --- a/lightning-liquidity/Cargo.toml +++ b/lightning-liquidity/Cargo.toml @@ -46,6 +46,7 @@ parking_lot = { version = "0.12", default-features = false } level = "forbid" # When adding a new cfg attribute, ensure that it is added to this list. check-cfg = [ + "cfg(fuzzing)", "cfg(c_bindings)", "cfg(backtrace)", "cfg(ldk_bench)", diff --git a/lightning-liquidity/src/lsps2/utils.rs b/lightning-liquidity/src/lsps2/utils.rs index 998b1d2964d..430d4263eae 100644 --- a/lightning-liquidity/src/lsps2/utils.rs +++ b/lightning-liquidity/src/lsps2/utils.rs @@ -15,6 +15,23 @@ use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::{Hash, HashEngine}; use bitcoin::secp256k1::PublicKey; +#[inline] +fn promise_matches(expected_promise: &str, actual_promise: &str) -> bool { + if expected_promise.len() != actual_promise.len() { + return false; + } + + #[cfg(not(fuzzing))] + { + expected_promise == actual_promise + } + #[cfg(fuzzing)] + { + expected_promise.len() < 2 + || expected_promise.as_bytes()[..2] == actual_promise.as_bytes()[..2] + } +} + /// Determines if the given parameters are valid given the secret used to generate the promise. pub fn is_valid_opening_fee_params( fee_params: &LSPS2OpeningFeeParams, promise_secret: &[u8; 32], counterparty_node_id: &PublicKey, @@ -33,7 +50,7 @@ pub fn is_valid_opening_fee_params( hmac.input(&fee_params.max_payment_size_msat.to_be_bytes()); let promise_bytes = Hmac::from_engine(hmac).to_byte_array(); let promise = utils::hex_str(&promise_bytes[..]); - promise == fee_params.promise + promise_matches(&promise, &fee_params.promise) } /// Determines if the given parameters are expired, or still valid. diff --git a/lightning/src/crypto/chacha20poly1305rfc.rs b/lightning/src/crypto/chacha20poly1305rfc.rs index 839fad9ce6c..95ec647d81f 100644 --- a/lightning/src/crypto/chacha20poly1305rfc.rs +++ b/lightning/src/crypto/chacha20poly1305rfc.rs @@ -11,8 +11,8 @@ // https://github.com/floodyberry/poly1305-donna use super::chacha20::ChaCha20; -use super::fixed_time_eq; use super::poly1305::Poly1305; +use crate::util::fuzz_wrappers::digest_bytes_match; pub struct ChaCha20Poly1305RFC { cipher: ChaCha20, @@ -108,7 +108,7 @@ impl ChaCha20Poly1305RFC { self.mac.input(&(self.data_len as u64).to_le_bytes()); let calc_tag = self.mac.result(); - if fixed_time_eq(&calc_tag, tag) { + if digest_bytes_match(&calc_tag, tag) { self.cipher.process(input, output); Ok(()) } else { @@ -148,7 +148,7 @@ impl ChaCha20Poly1305RFC { self.mac.input(&(self.data_len as u64).to_le_bytes()); let calc_tag = self.mac.result(); - if fixed_time_eq(&calc_tag, tag) { + if digest_bytes_match(&calc_tag, tag) { true } else { false diff --git a/lightning/src/crypto/mod.rs b/lightning/src/crypto/mod.rs index 478918a49a8..a0e4fc7b31d 100644 --- a/lightning/src/crypto/mod.rs +++ b/lightning/src/crypto/mod.rs @@ -1,12 +1,3 @@ -#[cfg(not(fuzzing))] -pub(crate) use bitcoin::hashes::cmp::fixed_time_eq; - -#[cfg(fuzzing)] -fn fixed_time_eq(a: &[u8], b: &[u8]) -> bool { - assert_eq!(a.len(), b.len()); - a == b -} - pub(crate) mod chacha20; pub(crate) mod chacha20poly1305rfc; pub(crate) mod poly1305; diff --git a/lightning/src/crypto/streams.rs b/lightning/src/crypto/streams.rs index 23a23154307..8f3e1eed1bd 100644 --- a/lightning/src/crypto/streams.rs +++ b/lightning/src/crypto/streams.rs @@ -1,10 +1,10 @@ use crate::crypto::chacha20::ChaCha20; use crate::crypto::chacha20poly1305rfc::ChaCha20Poly1305RFC; -use crate::crypto::fixed_time_eq; use crate::crypto::poly1305::Poly1305; use crate::io::{self, Read, Write}; use crate::ln::msgs::DecodeError; +use crate::util::fuzz_wrappers::digest_bytes_match; use crate::util::ser::{ FixedLengthReader, LengthLimitedRead, LengthReadableArgs, Readable, Writeable, Writer, }; @@ -175,11 +175,11 @@ impl LengthReadableArgs<([u8; 32], [u8; 32], [u8; 32])> let mut tag = [0 as u8; 16]; r.read_exact(&mut tag)?; - if fixed_time_eq(&mac.result(), &tag) { + if digest_bytes_match(&mac.result(), &tag) { Ok(Self { readable, used_aad: TriPolyAADUsed::None }) - } else if fixed_time_eq(&mac_aad_a.result(), &tag) { + } else if digest_bytes_match(&mac_aad_a.result(), &tag) { Ok(Self { readable, used_aad: TriPolyAADUsed::First }) - } else if fixed_time_eq(&mac_aad_b.result(), &tag) { + } else if digest_bytes_match(&mac_aad_b.result(), &tag) { Ok(Self { readable, used_aad: TriPolyAADUsed::Second }) } else { return Err(DecodeError::InvalidValue); diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs index d70a20eaf44..f2fbacb2de3 100644 --- a/lightning/src/ln/inbound_payment.rs +++ b/lightning/src/ln/inbound_payment.rs @@ -9,7 +9,6 @@ //! Utilities to generate inbound payment information in service of invoice creation. -use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::{Hash, HashEngine}; @@ -22,6 +21,7 @@ use crate::offers::nonce::Nonce; use crate::sign::EntropySource; use crate::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret}; use crate::util::errors::APIError; +use crate::util::fuzz_wrappers::{digest_bytes_match, payment_hash_matches_digest}; use crate::util::logger::Logger; #[allow(unused_imports)] @@ -370,10 +370,8 @@ pub(super) fn verify( let mut hmac = HmacEngine::::new(&keys.user_pmt_hash_key); hmac.input(&metadata_bytes[..]); hmac.input(&payment_hash.0); - if !fixed_time_eq( - &iv_bytes, - &Hmac::from_engine(hmac).to_byte_array().split_at_mut(IV_LEN).0, - ) { + let expected_iv = Hmac::from_engine(hmac).to_byte_array(); + if !digest_bytes_match(&iv_bytes, &expected_iv[..IV_LEN]) { log_trace!( logger, "Failing HTLC with user-generated payment_hash {}: unexpected payment_secret", @@ -399,10 +397,8 @@ pub(super) fn verify( Ok(Method::SpontaneousPayment) => { let mut hmac = HmacEngine::::new(&keys.spontaneous_pmt_key); hmac.input(&metadata_bytes[..]); - if !fixed_time_eq( - &iv_bytes, - &Hmac::from_engine(hmac).to_byte_array().split_at_mut(IV_LEN).0, - ) { + let expected_iv = Hmac::from_engine(hmac).to_byte_array(); + if !digest_bytes_match(&iv_bytes, &expected_iv[..IV_LEN]) { log_trace!(logger, "Failing async payment HTLC with sender-generated payment_hash {}: unexpected payment_secret", &payment_hash); return Err(()); } @@ -505,7 +501,8 @@ fn derive_ldk_payment_preimage( hmac.input(iv_bytes); hmac.input(metadata_bytes); let decoded_payment_preimage = Hmac::from_engine(hmac).to_byte_array(); - if !fixed_time_eq(&payment_hash.0, &Sha256::hash(&decoded_payment_preimage).to_byte_array()) { + let expected_digest = Sha256::hash(&decoded_payment_preimage).to_byte_array(); + if !payment_hash_matches_digest(&payment_hash, &expected_digest) { return Err(decoded_payment_preimage); } return Ok(PaymentPreimage(decoded_payment_preimage)); diff --git a/lightning/src/ln/onion_payment.rs b/lightning/src/ln/onion_payment.rs index 5111f6982fe..bbc733a9cbb 100644 --- a/lightning/src/ln/onion_payment.rs +++ b/lightning/src/ln/onion_payment.rs @@ -21,6 +21,7 @@ use crate::ln::onion_utils::{HTLCFailReason, LocalHTLCFailureReason, ONION_DATA_ use crate::sign::{NodeSigner, Recipient}; use crate::types::features::BlindedHopFeatures; use crate::types::payment::PaymentHash; +use crate::util::fuzz_wrappers::payment_hash_matches_preimage; use crate::util::logger::Logger; #[allow(unused_imports)] @@ -426,8 +427,7 @@ pub(super) fn create_recv_pending_htlc_info( // could discover the final destination of X, by probing the adjacent nodes on the route // with a keysend payment of identical payment hash to X and observing the processing // time discrepancies due to a hash collision with X. - let hashed_preimage = PaymentHash(Sha256::hash(&payment_preimage.0).to_byte_array()); - if hashed_preimage != payment_hash { + if !payment_hash_matches_preimage(&payment_hash, &payment_preimage) { return Err(InboundHTLCErr { reason: LocalHTLCFailureReason::InvalidKeysendPreimage, err_data: invalid_payment_err_data(amt_msat, current_height), diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index 9b1b009e93a..c24c8f539b1 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -26,12 +26,12 @@ use crate::sign::{NodeSigner, Recipient}; use crate::types::features::{ChannelFeatures, NodeFeatures}; use crate::types::payment::{PaymentHash, PaymentPreimage}; use crate::util::errors::APIError; +use crate::util::fuzz_wrappers::digest_bytes_match; use crate::util::logger::Logger; use crate::util::ser::{ LengthCalculatingWriter, Readable, ReadableArgs, VecWriter, Writeable, Writer, }; -use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::{Hash, HashEngine}; @@ -1298,7 +1298,8 @@ fn process_onion_failure_inner( let mut hmac = HmacEngine::::new(&um); hmac.input(&encrypted_packet.data[32..]); - if &Hmac::from_engine(hmac).to_byte_array() != &encrypted_packet.data[..32] { + let expected_hmac = Hmac::from_engine(hmac).to_byte_array(); + if !digest_bytes_match(&expected_hmac, &encrypted_packet.data[..32]) { continue; } @@ -2727,7 +2728,8 @@ fn decode_next_hop, N: NextPacketBytes>( if let Some(tag) = payment_hash { hmac.input(&tag.0[..]); } - if !fixed_time_eq(&Hmac::from_engine(hmac).to_byte_array(), &hmac_bytes) { + let expected_hmac = Hmac::from_engine(hmac).to_byte_array(); + if !digest_bytes_match(&expected_hmac, &hmac_bytes) { return Err(OnionDecodeErr::Malformed { err_msg: "HMAC Check failed", reason: LocalHTLCFailureReason::InvalidOnionHMAC, @@ -2907,7 +2909,7 @@ impl AttributionData { // Compare with the actual HMAC. let hmac_idx = MAX_HOPS - position - 1; let actual_hmac = self.get_hmac(hmac_idx); - if !fixed_time_eq(expected_hmac, actual_hmac) { + if !digest_bytes_match(expected_hmac, actual_hmac) { return Err(()); } diff --git a/lightning/src/util/fuzz_wrappers.rs b/lightning/src/util/fuzz_wrappers.rs index 6475065b8be..5a3192709ec 100644 --- a/lightning/src/util/fuzz_wrappers.rs +++ b/lightning/src/util/fuzz_wrappers.rs @@ -7,6 +7,13 @@ // You may not use this file except in accordance with one or both of these // licenses. +use crate::types::payment::{PaymentHash, PaymentPreimage}; + +#[cfg(not(fuzzing))] +use bitcoin::hashes::cmp::fixed_time_eq; +use bitcoin::hashes::sha256::Hash as Sha256; +use bitcoin::hashes::Hash; + macro_rules! hash_to_message { ($slice: expr) => {{ #[cfg(not(fuzzing))] @@ -22,3 +29,34 @@ macro_rules! hash_to_message { } }}; } + +#[inline] +pub(crate) fn digest_bytes_match(expected_digest: &[u8], actual_digest: &[u8]) -> bool { + if expected_digest.len() != actual_digest.len() { + return false; + } + + #[cfg(not(fuzzing))] + { + fixed_time_eq(expected_digest, actual_digest) + } + #[cfg(fuzzing)] + { + expected_digest.is_empty() || expected_digest[0] == actual_digest[0] + } +} + +#[inline] +pub(crate) fn payment_hash_matches_digest( + payment_hash: &PaymentHash, expected_digest: &[u8; 32], +) -> bool { + digest_bytes_match(&payment_hash.0, expected_digest) +} + +#[inline] +pub(crate) fn payment_hash_matches_preimage( + payment_hash: &PaymentHash, payment_preimage: &PaymentPreimage, +) -> bool { + let expected_digest = Sha256::hash(&payment_preimage.0).to_byte_array(); + payment_hash_matches_digest(payment_hash, &expected_digest) +}