Skip to main content

Circom libs in Python

Project description

circomlibpy

Circom libs in Python

Obtaining a Poseidon hash from two elements:

from circomlibpy.poseidon import PoseidonHash

poseidon = PoseidonHash()
hash = poseidon.hash(2, [12345, 67890])

Constructing a Merkle tree based on Poseidon hashes:

from circomlibpy.merkle_tree import MerkleTree

leafs: list[int] = [
    [1, 2, 3],
    [11, 22, 33],
]
mtree = MerkleTree(leafs)
path, order = mtree.gen_proof(index=0)

print(f'Root: {mtree.root}')
print(f'Path: {path}')
print(f'Order: {order}')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circomlibpy-1.0.0.tar.gz (905.2 kB view hashes)

Uploaded Source

Built Distribution

circomlibpy-1.0.0-py3-none-any.whl (906.1 kB view hashes)

Uploaded Python 3

Supported by

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