| Crates.io | algebraic_immunity |
| lib.rs | algebraic_immunity |
| version | 0.3.0 |
| created_at | 2025-07-01 14:29:59.590289+00 |
| updated_at | 2026-01-02 10:25:20.126246+00 |
| description | A package to compute the algebrac immunity of Boolean functions. |
| homepage | https://github.com/LucaBonamino/algebraic_immunity_rs |
| repository | https://github.com/LucaBonamino/algebraic_immunity_rs |
| max_upload_size | |
| id | 1733264 |
| size | 46,450 |
A Rust library to compute the algebraic immunity and restructes 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.
Add the dependency to your Cargo.toml:
[dependencies]
algebraic_immunity = "0.3.0"
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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