This is a Schnorr Signatures utility for educational purposes only, developed by BitPolito in Python3.
The classic signature and verification functions are based on the BIP340 reference implementation, while we tried to keep as close as possible to it the MuSig functions, even if they are not specified (yet).
Alessandro Guggino, Luca Giorgino, Andrea Gangemi, Fadi Barbara.
There are four main scripts:
create_keypair.py
creates one or more key pairs which are stored in a JSON file and can be used to sign and verify a message.
Syntax: create_keypair.py -n <number of keys>
schnorr_sign.py
returns the signature from one or more private keys and a message.
Syntax: schnorr_sign.py [--musig1 || --musig2] (optional) -m <message>
schnorr_verify.py
returns True
or False
from a signature, a single public key or an aggregated one, and a message.
Syntax: schnorr_verify.py -s <signature> -p <public_key> -m <message>
schnorr_test.py
is the BIP340 reference implementation minimally changed to perform a test from the test vectors.
Note: All the functions used in those scripts are collected in the library schnorr_lib.py
.
We used Python3 to write these scripts.
# clone the repo
$ git clone https://github.com/BITPoliTO/schnorr-sig.git
# change the working directory to schnorr-sig
$ cd schnorr-sig
$ python create_keypair.py -n <number_of_keys>
$ python schnorr_sign.py [--musig1 || --musig2] (optional) -m <message>
$ python schnorr_verify.py -s <signature> -p <public_key> -m <message>
The code can also be launched from a Jupyter Notebook, thanks to the script collected in the library "schnorr.ipynb".
# Download Jupyter Notebook
$ pip install notebook
# Launch
$ python -m notebook
Select schnorr.ipynb
from your folders and enjoy! You can:
- generate your own keypairs;
- generate a Schnorr, MuSig1 or MuSig2 signature;
- check that the obtained signature is valid.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.