algebraic_immunity 0.3.2

A package to compute the algebrac immunity and the restricted algebraic immunity of Boolean functions.
Documentation
# algebraic_immunity_rs
A Rust library to compute the algebraic immunity and restricted algebraic immunity of Boolean functions.

<b>Reference:</b></br>
*"Computing the Restricted Algebraic Immunity, and Application to WPB Functions"*  
Luca Bonamino and Pierrick Méaux. [IACR ePrint 2025/1779](https://eprint.iacr.org/2025/1779).

## Installation
Add the dependency to your `Cargo.toml`:

```toml
[dependencies]
algebraic_immunity = "0.3.2"
```

## Usage
From `BooleanFunction` struct.
``` Rust
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.
```Rust
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);
```
```Rust
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,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1,1,0,1,1,1,1,0,1,1,0,0,0,0,1,1,1,1,1,1,0,0,1,0,1,
        1,1,1,1,0,0,1,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,0,0,0,1,1,1,1,0,1,0,1,
        1,0,0,1,1,1,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,1,0,1,1,0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,1,1,0,0,1,1,
        0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,1,1,1,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,1,0,
        0,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,1,0,1,1,0,1,1,0,1,0,1,0,1,1,1,1,0,1,0,0,1,1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,0,0,1,
        0,1,1,1,0,1,0,0,1,1,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,0,1,1,0,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,1,1,0,1,0,0,0,0,1,1,1,1,0,0,1,0,0,1,1,1,
        1,0,1,1,0,1,1,1,1,1,1,0,1,0,0,1,1,1,1,0,1,1,0,1,1,0,0,1,1,1
    ];
let restricted_immunity = RestrictedAlgebraicImmunity::algebraic_immunity(ve, vec![1, 2, 6, 100, 200],10);
assert_eq!(restricted_immunity, 1);

```

## License
MIT

## Roadmap

This project is under active development.

Current and planned directions include:
- Reduce unnecessary copying: remove cloning where possible
- Add generics for the domain bit size (currently all $F_2^n$ elements use `usize`)
- Increase unit test coverage
- Increase integration test coverage