petrelic is a Python wrapper around RELIC. It provides a simple python interface to the BLS-381 pairing and RELIC’s big number class. Our goals is to make it easy to prototype new cryptographic applications in Python using RELIC as the backend. In the future we aim to support a few other pairing curves as well.
petrelic provides native, multiplicative and additive interfaces to RELIC. You can use the one that you find most comfortable. petrelic overloads Python’s binary operators to make computation with pairings easy. For example, here is how you would compute and verify a BLS signature using the multiplicative interface:
>>> frompetrelic.multiplicative.pairingimportG1,G2,GT>>> sk=G1.order().random()>>> pk=G2.generator()**sk>>> # Create the signature>>> m=b"Some message">>> signature=G1.hash_to_point(m)**sk>>> # Verify the signature>>> signature.pair(G2.generator())==G1.hash_to_point(m).pair(pk)True