mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
fuzz: add Silent Payments targets #37006
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!37006
Loading…
Reference in a new issue
No description provided.
Delete branch "fuzz-bip352"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds fuzz testing for Silent Payments in
src/test/fuzz/bip352.cpp, covering address decoding, destination creation, public key extraction from inputs, and end-to-end sending and receiving. There are currently no fuzz targets forsrc/common/bip352.cpp.The new fuzz targets are:
bip352_decode_address: testsDecodeSilentPaymentsAddressagainst an independent validity model, covering Bech32m checksums, the network HRP, versions, payload sizes, and compressed public keys. Accepted addresses are also checked against the encoded version, keys, and extension.bip352_destination_from: exercisesSilentPaymentsDestination::From, including invalid public keys.bip352_pubkey_from_input: testsGetPubKeyFromInputacross P2TR, P2WPKH, P2SH-P2WPKH, and P2PKH inputs. Taproot cases include annex handling, NUMS_H, and control blocks at the maximum supported size and beyond.bip352_send_receive: exercises the complete sending and receiving flow, fromGetSilentPaymentsPrevoutsSummarythroughGenerateSilentPaymentsTaprootDestinationstoSilentPaymentsReceiver::Scan. It also covers missing coins, unsupported SegWit versions, labels, outpoint ordering, and keys that cancel each other out.The fuzz targets use independent models to check expected behavior rather than simply reproducing the implementation. For consensus-invalid inputs where more than one result would be acceptable, the expected result is left undetermined. Two cases follow the current implementation instead of an independent model: P2SH scriptSig evaluation, and Taproot script-path spends with a malformed control block, which are expected to yield no public key.
The final corpus was built from inputs minimized with libFuzzer's
-merge=1, together with additional manually added seeds for cases that were not retained by corpus minimization. Some of the mutation results below depend on these added seeds, which do not add coverage and would not survive a new minimization. I will open a separatebitcoin-core/qa-assetsPR with these inputs underfuzz_corpora/.Mutation testing was performed against 55 mutations of
src/common/bip352.cpp, replaying the final corpus without additional fuzzing. Eight mutations survive: three are equivalent to the original implementation, two only change which validation layer rejects an address without changing acceptance, and three concern copy-assignment ofSilentPaymentsLabel, which is covered by the unit test proposed in #36995.Additional mutations were also tested, covering address decoding, P2WPKH and P2SH-P2WPKH public key extraction, invalid padding, empty address data, transactions without eligible inputs, and sender input validation. The corpus detects all of them except three: one that only affects consensus-invalid spends, one where an invalid private key is passed to the sender, and one where the sender is called without any recipients.
Testing performed on Linux with libFuzzer, ASan, UBSan, and integer sanitizers:
src/.clang-tidywithout findings.Testing performed on macOS (Apple M3):
src/common/bip352.cppwere detected.No production code is modified.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
🟠 Minor · The fuzz oracle rejects a valid point-at-infinity failure
A crafted spend key can make
bip352_send_receiveabort on the sender's documented point-at-infinity rejection even though the prevouts summary is valid.Location:
src/test/fuzz/bip352.cpp:542(head).Review coverage was incomplete.
Reviewed:
12b299133cf0· Review report · Previous reportspermalink
Opened bitcoin-core/qa-assets#303 with a
-set_cover_merge=1 -use_value_profile=0reduction of the corpus, as suggested in its README. It keeps coverage but not every input the mutation results rely on: with the reduced inputs alone, 8 of the 47 detected mutations are no longer detected. These 8 are detected by the unit tests: 2 by those in master, and the other 6 by the tests proposed in #36995. The mutation results in the description were measured with the full corpus, which I can share on request.