arkworks BLS12-381 bindings
The main usage of this library at this moment is to generate test vectors for EIP4844 in the consensus-specs. The library itself is generic, so feel free to use it for other purposes.
Usage examples
Scalar field arithmetic
from ark_algebra_py.ark_algebra_py import Scalar
# Initialisation - The default initialiser for a scalar is an u128 integer
scalar = Scalar(12345)
# Equality -- We override eq and neq operators
assert(scalar == scalar)
assert(Scalar(1234) != Scalar(4567))
# Scalar Addition/subtraction/Negation -- We override the add/sub/neg operators
a = Scalar(3)
b = Scalar(4)
c = Scalar(5)
assert(a.square() + b.square() == c.square())
assert(a * a + b * b == c * c)
neg_a = -a
assert(a + neg_a == Scalar(0))
assert(a + neg_a).is_zero()
# Serialisation
compressed_bytes = scalar.to_le_bytes()
deserialised_scalar = Scalar.from_le_bytes(compressed_bytes)
assert(scalar == deserialised_scalar)
Group arithmetic
from ark_algebra_py.ark_algebra_py import G1, G2, Scalar
# G1 and G2 have the same methods implemented on them
# For brevity, we will only see one method using G1 and G2;
# the rest of the code will just use G1
# Point initialization -- This will be initialized to the generator of G1.
g1_generator = G1()
g2_generator = G2()
# Identity element
identity = G1.identity()
# Equality -- We override eq and neq operators
assert(g1_generator == g1_generator)
assert(g1_generator != identity)
# Printing an element -- We override __str__ so when we print
# an element it prints in hex
print("identity: ",identity)
print("g1 generator: ", g1_generator)
print("g2 generator: ", g2_generator)
# Point Addition/subtraction/Negation -- We override the add/sub/neg operators
gen = G1()
double_gen = gen + gen
double_gen2 = gen.double()
assert(double_gen == double_gen2)
assert((double_gen2 - gen) == gen)
neg_gen = -gen
assert(neg_gen + gen == identity)
# Scalar multiplication
scalar = Scalar(4)
four_gen = gen * scalar
four_gen_2 = scalar * gen
assert(four_gen == gen + gen + gen + gen)
assert(four_gen == four_gen_2)
# Serialisation
#
# serialising to/from a g1 point
# We don't expose the uncompressed form
# because it seems like its not needed
compressed_bytes = gen.to_compressed_bytes()
deserialised_point = G1.from_compressed_bytes(compressed_bytes)
# If the bytes being received are trusted, we can avoid
# doing subgroup checks
deserialised_point_unchecked = G1.from_compressed_bytes_unchecked(compressed_bytes)
assert(deserialised_point == deserialised_point_unchecked)
assert(deserialised_point == gen)
Pairings
from ark_algebra_py.ark_algebra_py import G1, G2, PairingOutput, Scalar, Pairing
# Initilisation -- This is the generator point
gt_gen = PairingOutput()
# Zero/One
zero = PairingOutput.one()
# Computing a pairing using pairing and multi_pairing
# multi_pairing does multiple pairings and adds them together with only one final_exp
assert gt_gen == Pairing.pairing(G1(), G2())
g1s = [G1()]
g2s = [G2()]
assert gt_gen == Pairing.multi_pairing(g1s, g2s)
# Bilinearity
a = Scalar(1234)
b = Scalar(4566)
c = a * b
g = G1() * a
h = G2() * b
p = Pairing.pairing(g, h)
c_g1 = G1() *c
c_g2 = G2() *c
assert p == Pairing.pairing(c_g1, G2())
assert p == Pairing.pairing(G1(), c_g2)
Metadata
Release files for ark-algebra-py 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ark_algebra_py-0.2.1.tar.gz | 17.9 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| ark_algebra_py-0.2.1-cp37-abi3-win_amd64.whl | CPython 3.7 | abi3 | Windows x86-64 | Details |
| ark_algebra_py-0.2.1-cp37-abi3-win32.whl | CPython 3.7 | abi3 | Windows x86-32 | Details |
| ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.7 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl | CPython 3.7 | abi3 | Linux glibc 2.17+ ARMv7l | Details |
| ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.7 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| ark_algebra_py-0.2.1-cp37-abi3-macosx_11_0_arm64.whl | CPython 3.7 | abi3 | macOS 11.0+ ARM64 | Details |
| ark_algebra_py-0.2.1-cp37-abi3-macosx_10_12_x86_64.whl | CPython 3.7 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 7.3 MB
Release files / ark_algebra_py-0.2.1.tar.gz
| Download URL | ark_algebra_py-0.2.1.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba92042dc65c0bea3bec83109de20a1ee78feda5cc7b00444610f8c2996165d0
|
|
BLAKE2b-256 checksum How to use checksums |
65ce39c4f9bc2176c8b6691381f3eccc2c8102b384a81aa6291fc7142f70cd56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-win_amd64.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-win_amd64.whl |
|---|---|
| Size | 603.9 kB |
| Tags | CPython 3.7 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
409ab28c08c8c55e2626adc0db6b4a3e155d4141cae5b8625ff63d420398391a
|
|
BLAKE2b-256 checksum How to use checksums |
6037b826b0dd816dd2215e129fe842c322101553df77c7397c166314116ccd26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-win32.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-win32.whl |
|---|---|
| Size | 584.9 kB |
| Tags | CPython 3.7 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
83e6cd811d7c855c793e8d186c02b75488793a4972f5c5453cbe6ec2ca20e853
|
|
BLAKE2b-256 checksum How to use checksums |
3602a6916d9b250505002e1f4173cbeb934f93d3535c196441aea8aff6e6599f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bc472484619e93060e648a94bc3a6bc82edaa24dd943a3148581cce5b60d5fac
|
|
BLAKE2b-256 checksum How to use checksums |
16521834b0392a5f8607e1e9a497c94bcb37c0f6ad5ae1b978965007ffa57f8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
853e1644753906f9c64498ad979a201effc17b1a8814119f203dbace9ccd4b2c
|
|
BLAKE2b-256 checksum How to use checksums |
587eae56857740bb65552c6167e25afed4de08547e5bb140f6b20970bfd26e0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
e07859ce95dccda6f1b50061a5b14eb434d7d8c311e53a53d661e9378470b661
|
|
BLAKE2b-256 checksum How to use checksums |
9619c5e9f3a765436374afe9022a741093bb603b498de3c8fd0065b3be296473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-macosx_11_0_arm64.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 660.5 kB |
| Tags | CPython 3.7 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5d7915e15db09040e8695596a85ca82e3bb2958633e1a9387b8c976b95a20f69
|
|
BLAKE2b-256 checksum How to use checksums |
4a22b0730b0a251d99deaf926747206775238375e833c8b67be3e77b5f73f637
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Release files / ark_algebra_py-0.2.1-cp37-abi3-macosx_10_12_x86_64.whl
| Download URL | ark_algebra_py-0.2.1-cp37-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 730.7 kB |
| Tags | CPython 3.7 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
88b8a9f899e782d1aacf2d5bdece57e486cd81519be6e9cb33d89f83f4b0e12a
|
|
BLAKE2b-256 checksum How to use checksums |
1b80f3ed86c689e71f999cca0ee2fc764fce1f1ec91e7cbd8ee8fe0513c252c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.5.1
|
Security for ark-algebra-py 0.2.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.