LU
LucaBonamino/algebraic_immunity_rs
Rust library to compute the algebraic immunity of Boolean function
algebraic_immunity_rs
A Rust library to compute the algebraic immunity and restricted algebraic immunity of Boolean functions.
Reference:
"Computing the Restricted Algebraic Immunity, and Application to WPB Functions"
Luca Bonamino and Pierrick Méaux. IACR ePrint 2025/1779.
Installation
Add the dependency to your Cargo.toml:
[dependencies]
algebraic_immunity = "0.3.0"Usage
From BooleanFunction struct.
use alebraic_immunity::boolean_functions::BooleanFunction;
let ve = vec![0,1,0,0];
let bf = BooleanFuntion::from_truth_table(ve.clone());
let immunity = bf.algebraic_immunity();
assert_eq!(immunity, 1);
let restricted_immunity = bf.restricted_algebraic_immunity(vec![0,1,2]);
assert_eq!(restricted_immunity, 1);
Directly from AlgebraicImmunity and RestrictedAlgebraicImmunity structs.
use algebraic_immunity::ai::{AlgebraicImmunity, RestrictedAlgebraicImmunity};
let ve = vec![0,1,0,0];
let immunity = AlgebraicImmunity::algebraic_immunity(ve, 2);
assert_eq!(immunity, 1);
let restricted_immunity = RestrictedAlgebraicImmunity::algebraic_immunity(ve, vec![0,1,2], 2);
assert_eq!(restricted_immunity, 1);use algebraic_immunity::ai::{AlgebraicImmunity, RestrictedAlgebraicImmunity};
let ve = vec![
1,0,1,0,0,0,1,1,1,1,0,1,0,0,1,0,1,1,0,1,1,1,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,1,0,0,0,0,1,1,1,1,0,1,1,0,0,1,0,0,1,0,0,1,1,1,1,0,
1,0,0,1,1,0,0,1,0,0,1,1,0,1,1,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,0,1,0,0,1,1,1,0,0,1,0,0,1,1,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,1,0,1,0,0,0,1,1,1,
1,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,1,1,1,0,1,1,0,0,0,1,0,1,0,0,0,1,1,0,1,0,0,0,0,0,1,0,0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