The zk Script Library is a collection of Python scripts that generate Bitcoin SV Scripts compatible with Bitcoin SV version 1.1.0.
The library supports the generation of Groth16 verification scripts and ancillary operations.
The following scripts are currently implemented:
- Finite field arithmetic
- Elliptic curve arithmetic
- Efficient operations on secp256k1
- Bilinear pairings
- Groth16
The library currently contains implementations of pairings and Groth16 for:
Please, refer to the notes for a walkthrough of the implementation of bilinear pairings and Groth16 in Bitcoin Script.
Additionally, the library contains the following scripts:
Make sure you are using Python 3.12 or later versions.
You can check your Python version with
python --versionAfter cloning the repository, you can install all the dependencies with
pip install -r requirements.txtThe folder test contains scripts generating Bitcoin Scripts for all the implemented operations.
Groth16 locking scripts are generated by test_groth16.py.
You can generate the script verifying Groth16 for BLS12-281 and MNT4-753 with pytest:
pytest .\tests\groth16\test_groth16.py --save-to-jsonWhen the --save-to-json option is set (as shown above), scripts are saved in the data/ folder.
A transaction spending an output locked by a Groth16 verifier can be found here.
The script sizes for Groth16 are:
| Curve | # public statements | Unlocking script size | Locking script size | Modulo threshold | Total |
|---|---|---|---|---|---|
BLS12-381 |
2 | ~ 59 KB | ~ 421 KB | 200B | ~ 480 KB |
MNT4-753 |
1 | ~ 402 KB | ~ 485 KB | 200B | ~ 887 KB |
Note: the unlocking script is dependent on the public statements.
The code and resources within this repository are intended for research and educational purposes only.
Please note:
- No guarantees are provided regarding the security or the performance of the code.
- Users are responsible for validating the code and understanding its implications before using it in any capacity.
- There may be edge cases causing bugs or unexpected behaviours. Please contact us if you find any bug.
The code is released under the attached LICENSE. If you would like to use it for commercial purposes, please contact [email protected].