mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-05 19:26:17 +00:00
Merge bitcoin/bitcoin#34725: fuzz: assert we accept any PSBT serialization we create
d76ec4de148724e6b384efb0a4180722ed30db10 fuzz: make sure PSBT serialization roundtrips (Antoine Poinsot)
Pull request description:
~~Invalid public keys were accepted in Musig2 partial signatures. Because we serialize invalid keys as the empty byte string, this would lead us to creating an invalid PSBT serializations.~~
~~This can be checked by reverting the first commit with the fix and simply running the target against the existing qa-assets corpus for the `psbt` harness.~~
This patch found the issue fixed in #34219 with a single run against the existing qa-assets corpus. It is useful to make sure there are no similar bugs, and we don't introduce roundtrip regressions outside of the specifc instance of accepting invalid public keys in Musig2 fields.
*(Edited on March 4 to only contain the fuzz harness patch)*
ACKs for top commit:
davidgumberg:
crACK d76ec4de14
achow101:
ACK d76ec4de148724e6b384efb0a4180722ed30db10
dergoegge:
utACK d76ec4de148724e6b384efb0a4180722ed30db10
brunoerg:
code review ACK d76ec4de148724e6b384efb0a4180722ed30db10
Tree-SHA512: ab5f8d4e6a1781ecdef825e1a0e2793a6b553f36c923a4a35cb1af4070eead9d9780f6cc9a76235aa03462e52a129d15e61f631490b43651dc4395f3f1c005f3
This commit is contained in:
commit
083242aac8
@ -33,6 +33,17 @@ FUZZ_TARGET(psbt)
|
||||
}
|
||||
const PartiallySignedTransaction psbt = psbt_mut;
|
||||
|
||||
// A PSBT must roundtrip.
|
||||
PartiallySignedTransaction psbt_roundtrip;
|
||||
std::vector<uint8_t> psbt_ser;
|
||||
VectorWriter{psbt_ser, 0, psbt};
|
||||
SpanReader{psbt_ser} >> psbt_roundtrip;
|
||||
|
||||
// And be stable across roundtrips.
|
||||
std::vector<uint8_t> roundtrip_ser;
|
||||
VectorWriter{roundtrip_ser, 0, psbt_roundtrip};
|
||||
Assert(psbt_ser == roundtrip_ser);
|
||||
|
||||
const PSBTAnalysis analysis = AnalyzePSBT(psbt);
|
||||
(void)PSBTRoleName(analysis.next);
|
||||
for (const PSBTInputAnalysis& input_analysis : analysis.inputs) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user