Skip to content

Commit 154fcce

Browse files
committed
[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.
1 parent 9e1306f commit 154fcce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/fuzz/key.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ FUZZ_TARGET(ellswift_roundtrip, .init = initialize_key)
322322
auto encoded_ellswift = key.EllSwiftCreate(ent32);
323323
auto decoded_pubkey = encoded_ellswift.Decode();
324324

325-
assert(key.VerifyPubKey(decoded_pubkey));
325+
uint256 hash{ConsumeUInt256(fdp)};
326+
std::vector<unsigned char> sig;
327+
key.Sign(hash, sig);
328+
assert(decoded_pubkey.Verify(hash, sig));
326329
}
327330

328331
FUZZ_TARGET(bip324_ecdh, .init = initialize_key)

0 commit comments

Comments
 (0)