Skip to content

djeanql/ashmaize-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ashmaize-py

Python bindings for the ashmaize cryptographic hash function.

Overview

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.

Features

  • 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 cases
    • FullRandom: More thorough but slower generation

Platform-Specific Build Instructions

  • macOS: See BUILD_MACOS.md
  • Linux: See below
  • Windows: Requires Rust toolchain and MSVC build tools

Building on Linux

Prerequisites

  • Rust 1.70+ (install from rustup.rs)
  • Python 3.12 (IMPORTANT: Must use 3.12)
  • pip and setuptools

Build Steps

  1. Clone the repository with submodules:
    git clone https://github.com/djeanql/ashmaize-py
    cd ashmaize-py
  2. Install the ce-ashmaize submodule:
git submodule update --init --recursive
  1. Create a virtual environment:

    python3.12 -m venv venv && source venv/bin/activate
  2. Install setup tools:

    python3.12 -m pip install setuptools setuptools_rust wheel
  3. Build and install:

    python3.12 -m pip install -e . --no-build-isolation

Midnight Miner

If you are using Midnight Miner, you need to:

  • Exit the venv with deactivate
  • Copy target/release/libashmaize_py.so to MidnightMiner's directory
  • Rename to ashmaize_py.so

API Reference

build_rom(key, size=1073741824)

Build a ROM using FullRandom generation.

  • key (str): Secret key for ROM generation
  • size (int): ROM size in bytes (default: 1GB)

build_rom_twostep(key, size=1073741824, pre_size=16777216, mixing_numbers=4)

Build a ROM using TwoStep generation (faster).

  • key (str): Secret key for ROM generation
  • size (int): ROM size in bytes (default: 1GB)
  • pre_size (int): Pre-ROM size (default: 16MB)
  • mixing_numbers (int): Mixing iterations (default: 4)

PyRom Class

hash(preimage)

Hash a single preimage with default parameters (8 loops, 256 instructions).

hash_with_params(preimage, nb_loops, nb_instrs)

Hash with custom parameters.

hash_batch(preimages)

Hash multiple preimages efficiently (recommended for bulk operations).

hash_batch_with_params(preimages, nb_loops, nb_instrs)

Batch hash with custom parameters.

Performance Tips

  • 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

License

See the LICENSE files in the ce-ashmaize directory.

Credits

Built with PyO3 - Rust bindings for Python.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published