Python bindings for the ashmaize cryptographic hash function.
ashmaize-py provides Python bindings to the ashmaize library, a memory-hard hash function that uses large ROMs (Read-Only Memory tables) for secure password hashing and key derivation.
- Fast Rust implementation with Python bindings via PyO3
- Batch hashing for processing multiple preimages efficiently
- Configurable parameters (loops, instructions, ROM size)
- Two ROM generation methods:
TwoStep: Faster generation, suitable for most use casesFullRandom: More thorough but slower generation
- macOS: See BUILD_MACOS.md
- Linux: See below
- Windows: Requires Rust toolchain and MSVC build tools
- Rust 1.70+ (install from rustup.rs)
- Python 3.12 (IMPORTANT: Must use 3.12)
- pip and setuptools
- Clone the repository with submodules:
git clone https://github.com/djeanql/ashmaize-py cd ashmaize-py - Install the ce-ashmaize submodule:
git submodule update --init --recursive-
Create a virtual environment:
python3.12 -m venv venv && source venv/bin/activate
-
Install setup tools:
python3.12 -m pip install setuptools setuptools_rust wheel
-
Build and install:
python3.12 -m pip install -e . --no-build-isolation
If you are using Midnight Miner, you need to:
- Exit the venv with
deactivate - Copy
target/release/libashmaize_py.soto MidnightMiner's directory - Rename to
ashmaize_py.so
Build a ROM using FullRandom generation.
key(str): Secret key for ROM generationsize(int): ROM size in bytes (default: 1GB)
Build a ROM using TwoStep generation (faster).
key(str): Secret key for ROM generationsize(int): ROM size in bytes (default: 1GB)pre_size(int): Pre-ROM size (default: 16MB)mixing_numbers(int): Mixing iterations (default: 4)
Hash a single preimage with default parameters (8 loops, 256 instructions).
Hash with custom parameters.
Hash multiple preimages efficiently (recommended for bulk operations).
Batch hash with custom parameters.
- Use release builds for production:
pip install -e . --config-settings=build-args="--release" - Use batch hashing when processing multiple preimages
- Start with TwoStep ROM generation for faster initialization
- Larger ROMs provide more security but require more memory
See the LICENSE files in the ce-ashmaize directory.
Built with PyO3 - Rust bindings for Python.