light-poseidon Python Bindings
Python bindings for light-poseidon, originally by Mike Rostecki. This package is a fork providing Python access to the Poseidon hash implementation for the BN254 curve.
Compatibility
This package is made to be compatible with Kusama Shield's PoseidonPolkaVM.
Installation
pip install light-poseidon
Usage
from light_poseidon_python import poseidon_hash, poseidon_hash_bytes, Hasher
# One-shot function with uint64 inputs
result = poseidon_hash([1, 2])
print(result) # 0x115cc0f5e7d690413df64c6b9662e9cf2a3617f2743245519e19607a4417189a
# Byte inputs (32 bytes each, big-endian)
a = b"\x01" * 32
b = b"\x02" * 32
result = poseidon_hash_bytes([a, b])
# Reusable Hasher class
hasher = Hasher(2) # 2 inputs
result = hasher.hash([1, 2])
# Byte variants
hasher.hash_bytes_be([a, b]) # big-endian
hasher.hash_bytes_le([a, b]) # little-endian
Supported arities
1-12 inputs are supported.
Development
# Using Makefile
make install # Create venv and build
make test # Run basic tests
make build # Build wheel
make publish # Publish to PyPI
# Or manually
cd light-poseidon-python
python3 -m venv .venv
source .venv/bin/activate
pip install maturin
maturin develop
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
light_poseidon-0.1.1.tar.gz
(358.2 kB
view details)
Built Distribution
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 light_poseidon-0.1.1.tar.gz.
File metadata
- Download URL: light_poseidon-0.1.1.tar.gz
- Upload date:
- Size: 358.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca2386f6591d6a54408a2f46d5e6288bfb8a802be31a713b6a8acae254a6a805
|
|
| MD5 |
4e99130c85c6f14410c3781037c8535e
|
|
| BLAKE2b-256 |
cc95576e0502057e717194930af570c89a69250a3744c2b82c178b6ccb7d3cee
|
File details
Details for the file light_poseidon-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: light_poseidon-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 702.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83cad4e9ed1c557a7fa3149be6c74af85b1b8d9e3495db72bbb145e86635147b
|
|
| MD5 |
ee020766228513ea1fb00a3e6ace088e
|
|
| BLAKE2b-256 |
8a29d0d7574dd777f57e52765d2ef9cddeaf4c36ee30bc4f6b5dd5bb2c957f51
|