Skip to main content

Construct and invoke Pedersen hash functions (Rust-backed, arkworks)

Project description

pedersenpy

Rust-backed Pedersen hash functions for Python — one engine, the whole family of widely-known variants, validated byte-for-byte against their references.

arkworks, circomlib/iden3, and Zcash Sapling all define "a Pedersen hash," but their outputs disagree. pedersenpy implements the shared construction once (in Rust, on arkworks curves) and exposes each ecosystem's hash.

Install

pip install pedersenpy

Wheels are self-contained (abi3, Python ≥ 3.9) — no Rust toolchain needed to install.

Usage

import pedersenpy

# circom / iden3 — byte-identical to circomlibjs pedersenHash
c = pedersenpy.CircomPedersen()
c.hash(b"Hello").hex()
# '0e90d7d613ab8b5ea7f4f8bc537db6bb0fa2e5e97bbac1c1f609ef9e6a35fd8b'

# Zcash Sapling — 32-byte little-endian u-coordinate
z = pedersenpy.ZcashPedersen()                 # default personalization b"Zcash_PH"
int.from_bytes(z.hash(b"Hello"), "little")
# 8754254972755604884333948367738998890971419059392001151429652007230018821080

# arkworks-shaped instances (deterministic generators)
pedersenpy.BabyJubjubPedersen(64, 4).hash(b"data")
pedersenpy.JubjubBoweHopwood(16, 40).hash(b"data")

CircomPedersen and ZcashPedersen cache their generators — reuse one instance for many hashes.

Hashers

Class Returns Compatible with
CircomPedersen() 32-byte packed point byte-exact circomlibjs pedersenHash
ZcashPedersen(personalization=b"Zcash_PH") 32-byte LE u-coordinate byte-exact Zcash Sapling
BabyJubjubPedersen(segments, bits_per_window) compressed point arkworks pedersen::CRH
JubjubBoweHopwood(segments, chunks_per_segment) x-coordinate arkworks bowe_hopwood::CRH

The package ships type stubs (py.typed), so mypy/pyright and editors get full typing.

Links

License

MIT

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pedersenpy-0.1.1-cp39-abi3-win_amd64.whl (240.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

pedersenpy-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (383.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pedersenpy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (349.9 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pedersenpy-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl (346.9 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file pedersenpy-0.1.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pedersenpy-0.1.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 240.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pedersenpy-0.1.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6721304501e4bc20d35ffe60765ad6bb5c0b6216b07153bfc337d64dd30636af
MD5 b25b1c7ee849437f10722b12e5bde64a
BLAKE2b-256 d0e5c4c63fdb581acfdd4c17afe201527cbf5d374e25e629aed264b88d5840be

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedersenpy-0.1.1-cp39-abi3-win_amd64.whl:

Publisher: release.yml on luksgrin/pedersen-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pedersenpy-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pedersenpy-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e0ca3b867c5014e37e3ea4543dce3693570d6b6c2550788692033c6b65bb3dd
MD5 2f256a0c4ec5fb2bcd6421b10b864937
BLAKE2b-256 6cd691d6dfe847dece61a26338440fafeff6d5dcc72fe014654aeeee64ed0e95

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedersenpy-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on luksgrin/pedersen-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pedersenpy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pedersenpy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 62d0149bb110b1f5b7d5e4df30f14fcdbbff0108b023e59ac014cc1bc27d5bac
MD5 650149f6d301424628e51ff2ebaf9efb
BLAKE2b-256 60757988d3354c6997fa678d9b73c5686a00e80058aa9ae8deb137ae8e904554

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedersenpy-0.1.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on luksgrin/pedersen-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pedersenpy-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pedersenpy-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6a66806c76e6d6238a5cb82bd4324e60ad8b8a751512122e3c396a69e0faf897
MD5 d6a3a253a9358343076c30de1d1ae8e5
BLAKE2b-256 b0fbd2a9cac5a3381432cf03ceee8bab6e9bc7eec8bb98030299a4e5a3ca60d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pedersenpy-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on luksgrin/pedersen-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page