From 154fcce55c84c251fad8d280eafb3c0a5284fcd4 Mon Sep 17 00:00:00 2001 From: dergoegge Date: Wed, 10 Jan 2024 16:16:36 +0000 Subject: [PATCH] [fuzz] Improve fuzzing stability for ellswift_roundtrip harness `CPubKey::VerifyPubKey` uses rng internally which leads to instability in the fuzz test. We fix this by avoiding `VerifyPubKey` in the test and verifying the decoded public key with a fuzzer chosen message instead. --- src/test/fuzz/key.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp index be45443172..9e1e318e02 100644 --- a/src/test/fuzz/key.cpp +++ b/src/test/fuzz/key.cpp @@ -322,7 +322,10 @@ FUZZ_TARGET(ellswift_roundtrip, .init = initialize_key) auto encoded_ellswift = key.EllSwiftCreate(ent32); auto decoded_pubkey = encoded_ellswift.Decode(); - assert(key.VerifyPubKey(decoded_pubkey)); + uint256 hash{ConsumeUInt256(fdp)}; + std::vector sig; + key.Sign(hash, sig); + assert(decoded_pubkey.Verify(hash, sig)); } FUZZ_TARGET(bip324_ecdh, .init = initialize_key)