Skip to main content

pymcl

PyPI version CI License: MIT

A Python 3 wrapper for the mcl library. Currently support operations on BLS12-381 curve.

Requirements

  • Python 3.10 or higher

If you want to build from source, please check readme of mcl.

Installation

Install from PyPI (recommended):

pip install pymcl

Or install from source:

git clone https://github.com/Jemtaly/pymcl
cd pymcl
pip install .

Supported Platforms

  • Linux: x86_64, aarch64 (ARM64)
  • macOS: x86_64 (Intel), arm64 (Apple Silicon), universal2
  • Windows: AMD64 (x64)

Basic Usage

Here is an example of how to use pymcl:

import pymcl

g1 = pymcl.g1 # generator of G1
g2 = pymcl.g2 # generator of G2
x1 = pymcl.Fr.random() # random element in Fr
x2 = pymcl.Fr.random() # random element in Fr

# check the correctness of the pairing
assert pymcl.pairing(g1 * x1, g2 * x2) == pymcl.pairing(g1, g2) ** (x1 * x2)

Other Operations

There are 4 types of elements in pymcl: Fr, G1, G2, and GT. You can perform operations on these elements as follows:

Fr Class

Fr(s: str) -> Fr

Create an element in Fr from a string, which is the decimal representation of the element. The library does not supply a constructor for Fr from an integer, you can convert an integer to a string and then use this constructor, the integer should be in the range of $[0, r)$, where $r$ is the order of the Fr group.

Fr.__str__(self: Fr) -> str

Convert the element to a string.

Fr.random() -> Fr

Return a random element in Fr.

Fr.__add__(self: Fr, other: Fr) -> Fr
Fr.__sub__(self: Fr, other: Fr) -> Fr
Fr.__neg__(self: Fr) -> Fr
Fr.__mul__(self: Fr, other: Fr) -> Fr
Fr.__truediv__(self: Fr, other: Fr) -> Fr
Fr.__invert__(self: Fr) -> Fr

Perform addition, subtraction, negation, multiplication, division, and inversion on the element.

Fr.__eq__(self: Fr, other: Fr) -> bool
Fr.__ne__(self: Fr, other: Fr) -> bool
Fr.isZero(self: Fr) -> bool
Fr.isOne(self: Fr) -> bool

Check the equality and inequality of the element, and check if the element is the additive identity or the multiplicative identity.

Fr.__hash__(self: Fr) -> int

Return the hash value of the element.

Fr.serialize(self: Fr) -> bytes
Fr.deserialize(b: bytes) -> Fr

Serialize and deserialize the element.

G1 Class

G1(s: str) -> G1

Create an element in G1 from its string representation.

G1.__str__(self: G1) -> str

Convert the element to a string. (check the API of mcl for the format of the string representation)

G1.hash(b: bytes) -> G1

Hash a byte array to an element in G1. (check here)

G1.__add__(self: G1, other: G1) -> G1
G1.__sub__(self: G1, other: G1) -> G1
G1.__neg__(self: G1) -> G1
G1.__mul__(self: G1, other: Fr) -> G1

Perform addition, subtraction, negation, and multiplication on the element. Note that for the multiplication of G1 and Fr, the Fr element should be on the right-hand side.

G1.__eq__(self: G1, other: G1) -> bool
G1.__ne__(self: G1, other: G1) -> bool
G1.isZero(self: G1) -> bool

Check the equality and inequality of the element, and check if the element is the additive identity.

G1.__hash__(self: G1) -> int

Return the hash value of the element.

G1.serialize(self: G1) -> bytes
G1.deserialize(b: bytes) -> G1

Serialize and deserialize the element (in compressed form).

G2 Class

The G2 class has the same methods as the G1 class.

GT Class

GT(s: str) -> GT

Create an element in GT from its string representation.

GT.__str__(self: GT) -> str

Convert the element to a string.

GT.__mul__(self: GT, other: GT) -> GT
GT.__truediv__(self: GT, other: GT) -> GT
GT.__invert__(self: GT) -> GT
GT.__pow__(self: GT, other: Fr) -> GT

Perform multiplication, division, inversion, and exponentiation on the element.

GT.__eq__(self: GT, other: GT) -> bool
GT.__ne__(self: GT, other: GT) -> bool
GT.isZero(self: GT) -> bool
GT.isOne(self: GT) -> bool

Check the equality and inequality of the element, and check if the element is the additive identity or the multiplicative identity.

GT.__hash__(self: GT) -> int

Return the hash value of the element.

GT.serialize(self: GT) -> bytes
GT.deserialize(b: bytes) -> GT

Serialize and deserialize the element.

Other Function and Constants

pairing(a: G1, b: G2) -> GT

Compute the pairing of two elements in G1 and G2, note that the first argument should be in G1 and the second argument should be in G2.

g1: G1
g2: G2

The generator of G1 and G2.

r: int

The order of the G1, G2, Fr, and GT groups.

Metadata

Release files for pymcl 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymcl 1.0.2
File Size Uploaded Provenance Actions
pymcl-1.0.2.tar.gz 771.4 kB With provenance Details for pymcl-1.0.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pymcl 1.0.2
File Actions
pymcl-1.0.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pymcl-1.0.2-cp312-cp312-win_amd64.whl
pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
pymcl-1.0.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for pymcl-1.0.2-cp311-cp311-win_amd64.whl
pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
pymcl-1.0.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for pymcl-1.0.2-cp310-cp310-win_amd64.whl
pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 11.7 MB

Release files / pymcl-1.0.2.tar.gz

Download URL pymcl-1.0.2.tar.gz
Size 771.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef532851ba7785db68aa55ce21153bff94afd56f537c1bfe11c07afb7d83b438
BLAKE2b-256 checksum
How to use checksums
48caca8a76c62e6e16f2ef7e714d45329705e844e5f5e851c5f3034511091377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp312-cp312-win_amd64.whl

Download URL pymcl-1.0.2-cp312-cp312-win_amd64.whl
Size 355.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a2f2c24401933af979bdc6826cdef24a658063f0192a84a80bc649a9b361a716
BLAKE2b-256 checksum
How to use checksums
1eb1dc10b126f1d6cbcda8701722cec78ba330f8fdab7576ac3f3efa3cc73ca6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
40de8ab713c0c29088a92dc509f5281da6c8f3c2a6afae7d8bcdd16720683af5
BLAKE2b-256 checksum
How to use checksums
15434cd0d2a3f7b81cb4d37c0d64435bc24c25221e420925d63eef9d00fe9e7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Size 338.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f23cd5377c3d8b8616b1fe6f604e76901fa15eeae8d3b3ec50c464016f479ec6
BLAKE2b-256 checksum
How to use checksums
a62a6bcc0b2a393c4dfe4692dea02c628294feccde0bf03c517bf925e7409185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp311-cp311-win_amd64.whl

Download URL pymcl-1.0.2-cp311-cp311-win_amd64.whl
Size 354.8 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
78209c3b9f12d1b6a3dc4440d6a27df99f1c7ec04b3cbb95c0f251f9fbad6398
BLAKE2b-256 checksum
How to use checksums
443d698e444ab1a8911a21f9eb56161bd92150802e2a84e4fa000f17ecdbd63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
dd0ed8b29e692f198bb00a1bfd199a5c6a09806199deea4b4109d537c3f94a2f
BLAKE2b-256 checksum
How to use checksums
01942c5f3b366ebe13faf8578e0f5868a1bd388b820e8ef1aa19cf023379714f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Size 338.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6eafc29f0739083b5af953330666fa4ab9fb30a70ffcaf039832471ac6290347
BLAKE2b-256 checksum
How to use checksums
f8ef453b0be123025b19682e45007a2ef0948261bbc210e75805e6409f5b091f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp310-cp310-win_amd64.whl

Download URL pymcl-1.0.2-cp310-cp310-win_amd64.whl
Size 354.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
dd3c6c36bacd8de999a86ddc9b63150fa701a081877c4e12ff0a92d22c0dd667
BLAKE2b-256 checksum
How to use checksums
8efa55eb2c30e298e414256b25c09127a9c7a4824b9565e37b08011f65da16ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
effe0405efa2891b0e2ac0541e9a3c6b0e960e5d741a55db5a44dcf3eac1bb13
BLAKE2b-256 checksum
How to use checksums
dfecae2bf6d0d174e0bf932c4c4615c170c46962d246fc9865a17a113ae3be1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Release files / pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl
Size 337.2 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
518c7aafbb044d25ce28f941468ae268287477fa260985b06bb1a9e56a748d6a
BLAKE2b-256 checksum
How to use checksums
ac4ca9b6044aad54d56c1557767404be539ecd9673b282a1f4e966b74952ae33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

Security for pymcl 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 10 files in this release have been uploaded with provenance metadata.

Select from 10 files

Attestation for pymcl-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

10 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page