Skip to content

Commit 0cfb017

Browse files
committed
Add example
1 parent 17bc241 commit 0cfb017

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = ["-C", "target-cpu=native"]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cargo.lock
2+
target
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "highly_nonlinear_balanced_finder"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
rayon = "1.10.0"
8+
boolean_function = {path = "../..", features = ["unsafe_disable_safety_checks"]}
9+
num-bigint = "0.4.6"
36.9 MB
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::fs::File;
2+
use std::io::Read;
3+
use num_bigint::BigUint;
4+
use rayon::iter::ParallelBridge;
5+
use rayon::iter::ParallelIterator;
6+
use boolean_function::{BigBooleanFunction, BooleanFunctionImpl};
7+
8+
// Thanks https://langevin.univ-tln.fr/project/genbent/genbent.html
9+
const FILENAME: &'static str = "data/bent-1.zip";
10+
11+
fn main() {
12+
let mut bent_file = File::open(FILENAME).unwrap();
13+
let mut bent_function_buffer = [0u8; 32];
14+
15+
loop {
16+
if bent_file.read(&mut bent_function_buffer).unwrap() == 0 {
17+
println!("EOF");
18+
break;
19+
}
20+
let bent_function_tt = BigUint::from_bytes_le(&bent_function_buffer);
21+
let bent_function = BigBooleanFunction::from_truth_table(bent_function_tt.clone(), 8);
22+
23+
let close_balanced_iterator = bent_function.close_balanced_functions_iterator().unwrap();
24+
close_balanced_iterator.par_bridge()
25+
.filter(|balanced_function| balanced_function.nonlinearity() > 116)
26+
.for_each(|balanced_function| {
27+
println!("{}: {}", balanced_function.printable_hex_truth_table(), balanced_function.nonlinearity());
28+
});
29+
}
30+
}

0 commit comments

Comments
 (0)