You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-50Lines changed: 88 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,112 +1,147 @@
1
1
# py_arkworks_bls12381
2
2
3
+
Python bindings for BLS12-381 curve operations using [arkworks](https://github.com/arkworks-rs/algebra). Built with [PyO3](https://pyo3.rs/) and [maturin](https://www.maturin.rs/).
4
+
3
5
The main usage of this library at this moment is to generate test vectors for EIP4844 in the [consensus-specs](https://github.com/ethereum/consensus-specs/tree/master). The library itself is generic, so feel free to use it for other purposes.
4
6
5
-
## G1/G2Points
7
+
Requires Python >= 3.11.
8
+
9
+
## G1/G2 Points
6
10
7
11
```python
8
12
from py_arkworks_bls12381 import G1Point, G2Point, Scalar
9
13
10
-
# G1Point and G2Point have the same methods implemented on them
11
-
# For brevity, I will only show one method using G1Point and G2Point
12
-
# The rest of the code will just use G1Point
14
+
# G1Point and G2Point have the same methods implemented on them.
15
+
# For brevity, most examples below use G1Point only.
13
16
14
-
# Point initialization -- This will be initialized to the g1 generator
17
+
# Point initialization -- defaults to the generator
15
18
g1_generator = G1Point()
16
19
g2_generator = G2Point()
17
20
18
-
# Identity element
21
+
# Identity element
19
22
identity = G1Point.identity()
20
23
21
-
# Equality -- We override eq and neq operators
24
+
# Equality
22
25
assert g1_generator == g1_generator
23
26
assert g1_generator != identity
24
27
25
-
26
-
# Printing an element -- We override __str__ so when we print
27
-
# an element it prints in hex
28
-
print("identity: ",identity)
28
+
# Printing -- __str__ returns hex
29
+
print("identity: ", identity)
29
30
print("g1 generator: ", g1_generator)
30
31
print("g2 generator: ", g2_generator)
31
32
32
-
#Point Addition/subtraction/Negation -- We override the add/sub/neg operators
0 commit comments