Python library that serves as an API for the BN254/256 pairing-friendly curve implemented in MCl in C.
Package Installation and Usage
The package is available on PyPI:
pip install mclbn256
The library can be imported in the usual ways:
import mclbn256 # Abstracted 'dumb' API over the scalar and point groups from mclbn256 import mclbn256 # Extended attributes, internals, classes, test methods
Examples
This library supports concise construction of elliptic curve points (groups G1 and G2) and scalars (group Fr):
from mclbn256 import G1, G2, Fr
>>> p = G1().hash("some row")
>>> q = G2().hash("another row")
>>> p.valid()
True
>>> q.valid()
True
>>> s = Fr(6)
>>> t = Fr(857462736753)
>>> ((p * s) @ (q * t)) == (p @ (q * s * t))
True
>>> ((p * s * ~t) @ (q * t)) == (p @ (q * s))
True
>>> ((p * s) @ q) == ((p * ~t) @ (q * s * t))
True
Data structures for the relevant curve subgroups and finite fields are included as well:
>>> len(Fr().randomize().serialize()) 32 >>> len(G1().randomize().serialize()) 32 >>> len(G2().randomize().serialize()) 64 >>> len((G1().randomize() @ G2().randomize()).serialize()) <= 384 True
The representation of BN254 points and scalars in this library is compatible with the pure-Python bn254 implementation thanks to ECp_to_G1 and the other similarly-named helpers. We may also convert points in that library’s representation to the minimal-size MCl serial format using ECp_serialize.
>>> Q = G1.random(); G1().deserialize(ECp_serialize(G1_to_ECp(Q))) == Q and Q.serialize() == ECp_serialize(G1_to_ECp(Q)) True
Please see the package oblivious (which extends this package) for more examples of how to use the BN254 curve.
Contributions
In order to contribute to the source code, open an issue or submit a pull request on the GitHub page for this library.
Versioning
Beginning with version 0.1.0, the version number format for this library and the changes to the library associated with version number increments conform with Semantic Versioning 2.0.0.
Naming Notes
BN-256 was an old name for the BarretoNaehrig(2,254) Weierstrass curve,
when it was though to have close to 256 bits of security. It has since
been estimated to have at least 90 bits of security (compared to
symmetric ciphers) and is now more commonly refered to by BN254, after
the number of bits in its prime modulus. Specifically, mclbn256 is the
name of the subset of the MCl library containing the support for this
curve.
Metadata
Release files for mclbn256 1.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| mclbn256-1.3.5-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| mclbn256-1.3.5-py3-none-win32.whl | Python 3 | none | Windows x86-32 | Details |
| mclbn256-1.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| mclbn256-1.3.5-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details |
| mclbn256-1.3.5-py3-none-macosx_11_0_universal2.whl | Python 3 | none | macOS 11.0+ universal2 (ARM64, x86-64) | Details |
| mclbn256-1.3.5-py3-none-macosx_10_15_x86_64.whl | Python 3 | none | macOS 10.15+ x86-64 | Details |
Total release size: 31.6 MB
Release files / mclbn256-1.3.5-py3-none-win_amd64.whl
| Download URL | mclbn256-1.3.5-py3-none-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6ce6c8764ca87984aa05801b4c737608f51a1399b6165718661ce490b16d27c4
|
|
BLAKE2b-256 checksum How to use checksums |
fe0040621b7bdf7c5da113e4a215e3a6b7bd58a10e650b64a90fe6c00cc5cb1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / mclbn256-1.3.5-py3-none-win32.whl
| Download URL | mclbn256-1.3.5-py3-none-win32.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
3eb524fdaaef2c8f245e70b527b122391042a9c7444199a19effd4bc05cb9808
|
|
BLAKE2b-256 checksum How to use checksums |
4be8b0ffbf07988303f9d1e9530decd4c84b8fe16036356b54f55fc961efc9b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / mclbn256-1.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mclbn256-1.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 21.6 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
ac84fa8fc21a42f220c6c4b46e3941fce7e016931956fce709f2e596cb67bc37
|
|
BLAKE2b-256 checksum How to use checksums |
ef8d36dc5093d3bfd288f5d010c6818b3d6d4649df512571bcead4feab53e046
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / mclbn256-1.3.5-py3-none-macosx_12_0_arm64.whl
| Download URL | mclbn256-1.3.5-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ae7d8b89246ea4761673e24f887c4e808b917a9a5b0979baaabefe9c6a8edd5c
|
|
BLAKE2b-256 checksum How to use checksums |
e0f0a15a021aa3008300dccb0901fc5ff93a236033867d4a7a4d16d13e81b0f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / mclbn256-1.3.5-py3-none-macosx_11_0_universal2.whl
| Download URL | mclbn256-1.3.5-py3-none-macosx_11_0_universal2.whl |
|---|---|
| Size | 2.7 MB |
| Tags | Python 3 macOS 11.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
927678cdf191e6dc858f64949b02dee19f752f958a8c8e4a30e1276f5d266cd9
|
|
BLAKE2b-256 checksum How to use checksums |
7a345390c8078cc572c6a2e53cede1a8393a67690b784005dc81dd85bb3ea049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / mclbn256-1.3.5-py3-none-macosx_10_15_x86_64.whl
| Download URL | mclbn256-1.3.5-py3-none-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | Python 3 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba8ebdc982fbd031ca53e49fa6feae386566e13848792e8fa85447fa4e047903
|
|
BLAKE2b-256 checksum How to use checksums |
9090d2e1e240c08f97808f4662a1b1e3dea5dcaa911fa0de6ae1781e2c087c4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|