Learn cryptography via Python3

There is a steep learning curve for learning cryptography, specifically zero knowledge proof. Qi zhou shared a great learning method: learning it via programming.

Every time you learn a cryptographic primitive, get a corresponding code, and see the principle.

  • Observe programming examples
  • Modify the program and see different results
  • Early performance benchmark
  • practice the usage of functions, and writing Examples Start your project - KZG, Plonk, etc.

Python is a scripting language with native big integer support, which is easy to implement crypto ideas.

Many famous cryptography researchers, including Vitalik, are using python3, and Ethereum 2.0 spec is also written in Python3

Good libraries:

  1. ethereum/research

    a lot of treasuries, Fq, polynomial over Fq, FFT

  2. ethereum/py_pairing: Elliptic curve operations, including pairings

  3. ethereum/py_ecc: Python implementation of ECC pairing and bn_128 and bls12_381 curve operations

  4. bls-signatures/python-impl at main · Chia-Network/bls-signatures · GitHub

    Chia’s BLS library with ECC

Common used libraries

1
2
3
from basic_crypto.poly_utils import PrimeField # operation at or between polynomials
from basic_crypto.fft import fft
from poly_commit.bls.fields import Fq

For polynomial over Prime field

The prime root for the root of unity of BLS12-381 can be 5 or 7.

TODO

References

Learning Crypto via Python3 qi zhou