Cryptography in SageMath.

Clone this repo:
  1. fc3a4c1 Update weil-pairing-example.sage by Antonio Sanso · 4 years ago master
  2. c4c7794 Tate example by Zhi Guan · 6 years ago
  3. c8f1bce update by Zhi Guan · 6 years ago
  4. 8975646 Add Weil Pairing Example by Zhi Guan · 6 years ago
  5. b982c7e Lamport's One Time Signature by Zhi Guan · 6 years ago


CryptoSage provides cryptography algorithms in SageMath (

This project is for students and engineers interested in cryptography. You can try and test these cryptography algorithms with real parameters and full key lengths. We write cryptography algorithms in SageMath.


At first you need to install SageMath. And then the sage command can load and run the CryptoSage scripts.


We hope to implement all popular public key schemes:

  • Integer-Factoring-Based Cryptosystems including RSA/Rabin/Paillier, etc.
  • Descrete-Log-Based Cryptosystems including DH/ElGamal/DSA, etc.
  • ECC (Elliptic curve cryptography)
  • Pairing-Based Cryptography
  • Lattice-Based Cryptography
  • Coding-Based Cryptography

Elliptic Curve Cryptography

  • EC domain parameters: prime192v1.sage
  • EC key generation: eckeygen.sage
  • ECDSA signature generation and verification ecdsa.sage

You can view and try the ectest.sage

$ sage ectest.sage