🔐 Python Cryptography
A blazing-fast cryptography library for Python, built on Rust.
Supports an extensive set of post-quantum digital signature algorithms (DSA) and key encapsulation mechanisms (KEM).
🚀 Classic cryptography algorithms are also supported!
⚡ Features
- ✅ Dozens of NIST PQC candidates
- 🦀 Rust core for speed and safety
- 📦 Easy installation via
pip
🧬 Supported Algorithms
💻 Classic
Encoding
Hashing
Password Hashing
🛰️ Quantum
🛡️ KEM
-
Bike
-
ClassicMcEliece
-
Hqc
-
Kyber
-
MLKEM
-
NtruPrime
-
FrodoKem
✍️ DSA
-
Cross
-
Dilithium
-
Falcon
-
Mayo
-
MLDSA
-
Sphincs
-
Uov
❔ Examples
DSA Example
from pisalt.quantum.dsa import Algorithm, KeyPair
alicesk, alicepk = KeyPair(Algorithm.MLDSA.MLDSA87)
secretkey = KeyPair(Algorithm.MLDSA.MLDSA87, secretkey=alicesk.secretkey)
publickey = KeyPair(Algorithm.MLDSA.MLDSA87, publickey=alicepk.publickey)
secretkey, publickey = KeyPair(
Algorithm.MLDSA.MLDSA87,
secretkey=alicesk.secretkey,
publickey=alicepk.publickey
)
message = "Hello".encode()
signature = secretkey.sign(message=message)
valid = publickey.verify(signature=signature, message=message)
assert valid, "Signature verification failed!"
print(f"Message: [{message.decode()}]")
print(f"Signature: [{signature.hex()[-64:]}]")
print(f"SecretKey: [{alicesk.secretkey.hex()[-64:]}]")
print(f"PublicKey: [{alicepk.publickey.hex()[-64:]}]")
KEM Example
from pisalt.quantum.kem import Algorithm, KeyPair
alicesk, alicepk = KeyPair(Algorithm.MLKEM.MLKEM1024)
_bobsk, _bobpk = KeyPair(Algorithm.MLKEM.MLKEM1024)
alice_secret_bytes = alicesk.secretkey
alice_public_bytes = alicepk.publickey
bob_secret_bytes = _bobsk.secretkey
bob_public_bytes = _bobpk.publickey
alicesk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=alice_secret_bytes)
alicepk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=alice_public_bytes)
bobsk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, secretkey=bob_secret_bytes)
bobpk_restored = KeyPair(Algorithm.MLKEM.MLKEM1024, publickey=bob_public_bytes)
bobss, bobct = alicepk_restored.encapsulate()
alicess = alicesk_restored.decapsulate(bobct)
assert alicess == bobss, "Shared secrets do not match!"
print(f"Alice's Shared Secret: [{alicess.hex()}]")
print(f"Bob's Shared Secret: [{bobss.hex()}]")
print(f"SecretKey: [{alicesk_restored.secretkey.hex()[-64:]}]")
print(f"PublicKey: [{alicepk_restored.publickey.hex()[-64:]}]")
📦 Install
pip install pisalt
🥳 Enjoy!