Skip to content

Commit

Permalink
keccak fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed May 23, 2024
1 parent 251e35d commit 88a920f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ name = "allocator"
path = "fuzz_targets/allocator.rs"
test = false
doc = false

[[bin]]
name = "keccak"
path = "fuzz_targets/keccak.rs"
test = false
doc = false
16 changes: 16 additions & 0 deletions fuzz/fuzz_targets/keccak.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![no_main]
use clvmr::keccak256_ops::op_keccak256;
use clvmr::{reduction::Reduction, Allocator, NodePtr};
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let mut a = Allocator::new();
let blob = a.new_atom(data).expect("failed to create atom");
let args = a
.new_pair(blob, NodePtr::NIL)
.expect("failed to create pair");
let Reduction(cost, node) = op_keccak256(&mut a, args, 11000000000).expect("keccak256 failed");
assert!(cost >= 210);
assert!(node.is_atom());
assert_eq!(a.atom_len(node), 32);
});

0 comments on commit 88a920f

Please sign in to comment.