A lightweight cryptographic Boolean function analysis and quantum circuit synthesis tool and library. It helps you analyze cryptographic Substitution Boxes (S-Boxes) by computing their Algebraic Normal Form (ANF) polynomials, truth tables, and Möbius transform coefficients, as well as synthesizing quantum circuits representing those equations.
- ANF Equation Generation: Generate Algebraic Normal Form (ANF) equations for each S-Box bit.
- Truth Tables: Extract individual truth tables for output bits.
- Möbius Coefficients: Compute Fast Möbius Transform (FMT) coefficients.
- Quantum Circuit Synthesis: Synthesize out-of-place quantum circuits (reversible logic) directly from the generated ANF polynomials.
- Flexible Input: Load S-Boxes from raw strings, local files, or standard input (stdin).
The tool supports multiple output formats for ANF equations:
- Text (
text): Standard text representation of equations. - LaTeX (
latex): Outputs mathematical equations formatted with standard LaTeX symbols. - JSON (
json): Structured data format containing equations and metadata, useful for integration with other tools. - Unicode (
unicode): Visually formatted text utilizing subscript numbers and mathematical symbols (e.g.,⊕,→). - Image (
image): Renders and saves equations to a PNG image file usingmatplotlib.
Clone the repository and install the package with editable mode. You can choose the extras configuration depending on your use case:
git clone https://github.com/enes/boolbox.git
cd boolbox
# Core package with basic image export
pip install -e .[image]
# Basic quantum circuit synthesis (Qiskit support)
pip install -e .[quantum]
# Quantum circuit synthesis with visualization capabilities (Matplotlib & pylatexenc)
pip install -e .[quantum-vis]
# Complete installation with all features and development dependencies (pytest)
pip install -e .[all,dev]Verify your installation with:
boolbox --helpboolbox will soon be available on PyPI. Once published, you will be able to install it directly using pip:
pip install boolboxOnce installed, the boolbox command is available globally.
Convert S-Box outputs to algebraic equations.
# Standard text format (default)
boolbox anf "[0xC, 0x5, 0x6, 0xB, 0x9, 0x0, 0xA, 0xD, 0x3, 0xE, 0xF, 0x8, 0x4, 0x7, 0x1, 0x2]"
# Unicode format
boolbox anf "[0xC, 0x5, 0x6, 0xB]" --format unicode
# LaTeX format
boolbox anf "[0xC, 0x5, 0x6, 0xB]" --format latex
# Save equations as a PNG image (requires 'matplotlib')
boolbox anf "[0xC, 0x5, 0x6, 0xB]" --format image --output equations.pngExtract truth tables for each S-Box output bit.
boolbox tts "[0xC, 0x5, 0x6, 0xB]" --format jsonCompute Fast Möbius Transform coefficients.
boolbox coeffs "[0xC, 0x5, 0x6, 0xB]" --format textSynthesize a Qiskit-compatible quantum circuit from an S-Box ANF.
# Display circuit structure as ASCII/Text directly on stdout (default)
boolbox qcircuit "[0xC, 0x5, 0x6, 0xB]"
# Export ASCII circuit rendering to a text file
boolbox qcircuit "[0xC, 0x5, 0x6, 0xB]" --format text --output circuit.txt
# Render and save the circuit as an MPL-based PNG image (requires 'quantum-vis' extras)
boolbox qcircuit "[0xC, 0x5, 0x6, 0xB]" --format image --output quantum_circuit.pngNote: As
boolboxis primarily designed for educational and learning purposes, the synthesized circuits are intended for demonstration and baseline functionality, rather than representing optimal or physically simplified quantum layouts.
Inputs can be supplied through different channels:
# Read from a file
boolbox anf path/to/sbox.txt
# Pipe from standard input (stdin)
cat sbox.txt | boolbox anf -Planned improvements and features for future releases:
- Expand LaTeX Formatting Support: Extend LaTeX output support to the remaining subcommands (
ttsandcoeffs), where it is currently pending implementation. - Universal Output Routing: Extend the
-o/--outputflag functionality to support all formatters (Text, JSON, LaTeX, etc.), allowing users to write any generated output directly to a file instead ofstdout. - Formatter Architecture Refactoring: Introduce dedicated formatter families for Truth Tables (
TruthTableFormatter) and Möbius Coefficients (CoeffsFormatter). This architectural upgrade will eliminate inlineif/elifconditional logic, enforcing a cleaner and fully polymorphic design across all subcommands.
This project was developed with assistance from Artificial Intelligence. AI tools were utilized for the following tasks:
- Optimizing the Fast Möbius Transform algorithm to reduce its complexity.
- Drafting and formatting this
README.mdfile. - Minor refactoring and routine code adjustments.
The core design, structural logic, program architecture, and implementation are designed and owned by the author.
This project is licensed under the MIT License. See the LICENSE file for more details.