A package for computing the algebraic immunity and restricted algebraic immunity of Boolean functions.
Project description
algebraic_immunity
Rust implementation of the algebraic immunity abd restricted algebraic immunity computation of Boolean functions, based on the papers
"Efficient Computation of Algebraic Immunity for Algebraic and Fast Algebraic Attacks"
(Armknecht et al., 2006, DOI: https://doi.org/10.1007/11761679_8) and "Computing the Restricted Algebraic Immunity, and Application to WPB Functions"
Luca Bonamino and Pierrick Méaux. IACR ePrint 2025/1779 .
This Rust implementation is wrapped as a Python package using PyO3 (https://pyo3.rs) and maturin (https://github.com/PyO3/maturin).
Why This Implementation?
This library was developed to provide a robust and reliable implementation of algebraic immunity computation. It addresses a correctness issue in SageMath’s BooleanFunction.algebraic_immunity() method, which can raise internal errors or produce incorrect results for certain Boolean functions — particularly those with two variables, such as [1, 0, 0, 1].
This Rust implementation has been tested extensively and is suitable for both small and large truth tables, with a focus on correctness and Python accessibility.
Installation
You can install the package via PyPI or use the pre-built wheels provided in the GitHub releases.
✅ Installation via PyPI
To install the package directly from PyPI:
pip install algebraic_immunity
Installation via Pre-built Wheels
If PyPI installation doesn't work for your platform, you can use the pre-built wheels:
- Run the following script to determine the correct wheel for your platform:
python construct_wheel_url.py
- Then install the wheel using:
pip install <output of the previous command>
Usage Example (Python)
from algebraic_immunity import AlgebraicImmunity, BooleanFunction
# Algebraic immunity
truth_table = [0, 1, 1, 1, 1, 0, 0, 1]
n = 3
ai = AlgebraicImmunity.ai(truth_table, n)
print(f"Algebraic immunity: {ai}")
# Restricted Algebraic immunity
bf = BooleanFunction(truth_table)
ai = bf.algebraic_immunity()
print(f"Algebraic immunity: {ai}")
Future Work
- Parts of this repository are more broadly relevant to operations over GF(2) matrices. These components could be extracted into a standalone Rust crate in the future.
- The current implementation sometimes uses the
clonemethod unnecessarily to bypass Rust’s borrowing rules. These instances will be reviewed and optimized in future updates.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 189.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e948da76824c4e9ca49c82f9b3f26768c00cdf9bb24030c81a31b4b92ff21626
|
|
| MD5 |
b9759db22a421dddeb2289ca402a9472
|
|
| BLAKE2b-256 |
77c7843f91d1de81972d3c4ded3827192ab1f4a05651487deb066795c58ebb3b
|
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-win32.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-win32.whl
- Upload date:
- Size: 177.1 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6abd5c2219df0d7875ba948d54529e66ffd58309b685efca57950efbbac9062e
|
|
| MD5 |
326ce0b049f329cd7567eda4b03cf418
|
|
| BLAKE2b-256 |
44fadca6374601bfb9e504ec3e99a69b8bac04bb6b6a2e6d7c9c7d4d8503eeda
|
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 351.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
231198bbb41b74105d5a4aa44140cec4ca989661a11f8bf66d11d08539abfc35
|
|
| MD5 |
e3bdc43feafd4ae7d7b015883eabc6c9
|
|
| BLAKE2b-256 |
7068e775d296b36843e50f051d6f4dfc8b79091368f1bd441432475f217c90ad
|
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 348.8 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7a27bcc49b8fb2dadb604a92e9c7da8fcc8fded057a6e5a965373c39159fe5d
|
|
| MD5 |
897c57260f4df5f47a38c870422a0253
|
|
| BLAKE2b-256 |
834bf7f2a4766c6abcbbd91b56635f488d22d37e8efbdb98341bf5e10a9713d3
|
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 304.6 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1350f13902ec203bbca75f94a6a5227d008c5be74764666bac6bbd647b944346
|
|
| MD5 |
7f8497f60722d3d48a97f962b7be5968
|
|
| BLAKE2b-256 |
28b331ac1d6815e6ed3cfa810f283b713aed6ff230f1b572b8f8d532fe13cbb3
|
File details
Details for the file algebraic_immunity-1.1.0-cp310-cp310-macosx_10_12_x86_64.whl.
File metadata
- Download URL: algebraic_immunity-1.1.0-cp310-cp310-macosx_10_12_x86_64.whl
- Upload date:
- Size: 307.0 kB
- Tags: CPython 3.10, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ec94e8a890238fe9df1adba98ddd0e392d0b078312194bab98fb11031cb93b
|
|
| MD5 |
e7bad441a28dac44eff67c8853fd171e
|
|
| BLAKE2b-256 |
819101f8184ee382699305ac37fc8e7627b1d149115245501e0f49223e9c4af4
|