Skip to content

Commit 84af845

Browse files
authored
Merge pull request #3 from pvdhove/collision-fix
Fix panics arising due to hash collisions
2 parents b11dc3c + 3afa286 commit 84af845

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/algos/meta/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ where
106106
let nb_traces = target.len();
107107
// Check whether the fom
108108
if let Some(f) = initial_cache.get_from_cv(target, target) {
109-
debug!("Formula found in cache");
110-
return Some(f);
109+
// Due to hash collisions, the formula may not be right; we check that
110+
// the formula has the right characteristic vector.
111+
if f.eval(traces).accepted_vec() == target {
112+
debug!("Formula found in cache");
113+
return Some(f);
114+
} else {
115+
debug!("Hash collision found a wrong formula {f} for target {target:?}; continuing");
116+
}
111117
}
112118
if nb_traces > 128 {
113119
split_and_solve_non_overlapping(traces, operators, initial_cache, target, params)

0 commit comments

Comments
 (0)