Skip to content

Commit f311150

Browse files
committed
Refactor README.md
1 parent df0d739 commit f311150

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,33 @@ use num_traits::Num;
3333
fn main() {
3434
// Create a Boolean function from its string truth table
3535
const TRUTH_TABLE_STR: &'static str = "0113077C165E76A8";
36-
let f: BooleanFunction = BooleanFunction::from_hex_string_truth_table(TRUTH_TABLE_STR).unwrap();
36+
let f: BooleanFunction = BooleanFunction::from_hex_string_truth_table(TRUTH_TABLE_STR)
37+
.unwrap();
3738

3839
// How many variables does the function have?
3940
assert_eq!(f.variables_count(), 6);
4041

4142
// Check if the function is bent
4243
assert!(f.is_bent());
4344

44-
// If you already know that the function has a small number of variables, you can use SmallBooleanFunction
45+
// If you already know that the function has a small number of variables,
46+
// you can use SmallBooleanFunction
4547
// It will be faster runtime and use less memory
46-
let f_small: SmallBooleanFunction = SmallBooleanFunction::from_truth_table(0xac90, 4).unwrap();
48+
let f_small: SmallBooleanFunction = SmallBooleanFunction::from_truth_table(0xac90, 4)
49+
.unwrap();
4750
assert!(f_small.is_bent());
4851
assert!(!f_small.is_balanced()); // A bent function is not balanced
4952
// ANF of the function, `*` is AND and `+` is XOR
50-
assert_eq!(f_small.algebraic_normal_form().to_string(), "x0*x2 + x1*x2 + x1*x3 + x2*x3 + x2");
53+
assert_eq!(
54+
f_small.algebraic_normal_form().to_string(),
55+
"x0*x2 + x1*x2 + x1*x3 + x2*x3 + x2");
5156

5257
// If your function has more than 6 variables, you can use BigBooleanFunction
5358
// So that you will avoid runtime calls to the V-table
5459
const AES_COMP_TT: &'static str = "4f1ead396f247a0410bdb210c006eab568ab4bfa8acb7a13b14ede67096c6eed";
55-
let f_big: BigBooleanFunction = BigBooleanFunction::from_truth_table(BigUint::from_str_radix(AES_COMP_TT, 16).unwrap(), 8);
60+
let f_big: BigBooleanFunction = BigBooleanFunction::from_truth_table(
61+
BigUint::from_str_radix(AES_COMP_TT, 16).unwrap(),
62+
8);
5663
assert_eq!(f_big.nonlinearity(), 112); // AES S-Box has a nonlinearity of 112
5764
}
5865
```
@@ -89,7 +96,8 @@ fn main() {
8996
// Parallel exhaustive search on all 4-variable Boolean functions
9097
let count = (0..(1 << 16)).into_par_iter()
9198
.filter(|truth_table| {
92-
let f: BooleanFunction = BooleanFunction::from_u64_truth_table(*truth_table, 4).unwrap();
99+
let f: BooleanFunction = BooleanFunction::from_u64_truth_table(*truth_table, 4)
100+
.unwrap();
93101
f.is_balanced()
94102
}).count();
95103
assert_eq!(count, 12870);

0 commit comments

Comments
 (0)