A Python 3 wrapper for the mcl library (BLS12-381) using Pybind11.
Project description
pymcl
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 pymcl-1.0.2.tar.gz.
File metadata
- Download URL: pymcl-1.0.2.tar.gz
- Upload date:
- Size: 771.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef532851ba7785db68aa55ce21153bff94afd56f537c1bfe11c07afb7d83b438
|
|
| MD5 |
2728ad3c08baa4858b4cb0c241297b63
|
|
| BLAKE2b-256 |
48caca8a76c62e6e16f2ef7e714d45329705e844e5f5e851c5f3034511091377
|
Provenance
The following attestation bundles were made for pymcl-1.0.2.tar.gz:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2.tar.gz -
Subject digest:
ef532851ba7785db68aa55ce21153bff94afd56f537c1bfe11c07afb7d83b438 - Sigstore transparency entry: 830595659
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 355.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2f2c24401933af979bdc6826cdef24a658063f0192a84a80bc649a9b361a716
|
|
| MD5 |
868a12f118c419abb118ebea38e08897
|
|
| BLAKE2b-256 |
1eb1dc10b126f1d6cbcda8701722cec78ba330f8fdab7576ac3f3efa3cc73ca6
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp312-cp312-win_amd64.whl -
Subject digest:
a2f2c24401933af979bdc6826cdef24a658063f0192a84a80bc649a9b361a716 - Sigstore transparency entry: 830595673
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40de8ab713c0c29088a92dc509f5281da6c8f3c2a6afae7d8bcdd16720683af5
|
|
| MD5 |
54f6f5a4b9502c91f2ebf450cba88dd5
|
|
| BLAKE2b-256 |
15434cd0d2a3f7b81cb4d37c0d64435bc24c25221e420925d63eef9d00fe9e7d
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
40de8ab713c0c29088a92dc509f5281da6c8f3c2a6afae7d8bcdd16720683af5 - Sigstore transparency entry: 830595667
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 338.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f23cd5377c3d8b8616b1fe6f604e76901fa15eeae8d3b3ec50c464016f479ec6
|
|
| MD5 |
29c14c905750ca4bda5fe0cdd8b1d5a9
|
|
| BLAKE2b-256 |
a62a6bcc0b2a393c4dfe4692dea02c628294feccde0bf03c517bf925e7409185
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
f23cd5377c3d8b8616b1fe6f604e76901fa15eeae8d3b3ec50c464016f479ec6 - Sigstore transparency entry: 830595666
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 354.8 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78209c3b9f12d1b6a3dc4440d6a27df99f1c7ec04b3cbb95c0f251f9fbad6398
|
|
| MD5 |
a9185721104dd63ff0eed0fcebbe038f
|
|
| BLAKE2b-256 |
443d698e444ab1a8911a21f9eb56161bd92150802e2a84e4fa000f17ecdbd63a
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp311-cp311-win_amd64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp311-cp311-win_amd64.whl -
Subject digest:
78209c3b9f12d1b6a3dc4440d6a27df99f1c7ec04b3cbb95c0f251f9fbad6398 - Sigstore transparency entry: 830595674
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd0ed8b29e692f198bb00a1bfd199a5c6a09806199deea4b4109d537c3f94a2f
|
|
| MD5 |
a178ed199816b39772827f8ba24716d5
|
|
| BLAKE2b-256 |
01942c5f3b366ebe13faf8578e0f5868a1bd388b820e8ef1aa19cf023379714f
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
dd0ed8b29e692f198bb00a1bfd199a5c6a09806199deea4b4109d537c3f94a2f - Sigstore transparency entry: 830595663
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 338.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eafc29f0739083b5af953330666fa4ab9fb30a70ffcaf039832471ac6290347
|
|
| MD5 |
08873d786e92e379aba03ca48b636bf6
|
|
| BLAKE2b-256 |
f8ef453b0be123025b19682e45007a2ef0948261bbc210e75805e6409f5b091f
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
6eafc29f0739083b5af953330666fa4ab9fb30a70ffcaf039832471ac6290347 - Sigstore transparency entry: 830595676
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 354.1 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd3c6c36bacd8de999a86ddc9b63150fa701a081877c4e12ff0a92d22c0dd667
|
|
| MD5 |
32b12bd7b8c57c54a3f90cbdced8d160
|
|
| BLAKE2b-256 |
8efa55eb2c30e298e414256b25c09127a9c7a4824b9565e37b08011f65da16ec
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp310-cp310-win_amd64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp310-cp310-win_amd64.whl -
Subject digest:
dd3c6c36bacd8de999a86ddc9b63150fa701a081877c4e12ff0a92d22c0dd667 - Sigstore transparency entry: 830595677
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effe0405efa2891b0e2ac0541e9a3c6b0e960e5d741a55db5a44dcf3eac1bb13
|
|
| MD5 |
42db158856a8d9eeb10d023c1a7be9f3
|
|
| BLAKE2b-256 |
dfecae2bf6d0d174e0bf932c4c4615c170c46962d246fc9865a17a113ae3be1e
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
effe0405efa2891b0e2ac0541e9a3c6b0e960e5d741a55db5a44dcf3eac1bb13 - Sigstore transparency entry: 830595662
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 337.2 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
518c7aafbb044d25ce28f941468ae268287477fa260985b06bb1a9e56a748d6a
|
|
| MD5 |
f66b3df8f1e82cd177699f083b3d3489
|
|
| BLAKE2b-256 |
ac4ca9b6044aad54d56c1557767404be539ecd9673b282a1f4e966b74952ae33
|
Provenance
The following attestation bundles were made for pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
release.yml on Jemtaly/pymcl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymcl-1.0.2-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
518c7aafbb044d25ce28f941468ae268287477fa260985b06bb1a9e56a748d6a - Sigstore transparency entry: 830595669
- Sigstore integration time:
-
Permalink:
Jemtaly/pymcl@64131691b35f425527c7a94edc61f92e76c37bc6 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Jemtaly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64131691b35f425527c7a94edc61f92e76c37bc6 -
Trigger Event:
push
-
Statement type: