I think it’s time to introduce Thistle as a serious cryptography project evolving within the Mojo ecosystem, now that ED25519 and X25519 have been fully implemented in pure Mojo, utilizing just a few files. This project will allow TLS to be in native Mojo in the near future. Additionally, no more linking the SSL library with millions of lines of code just for crypto operations. And most important no object overhead from Python calling hashlib; there is a 150x reduction in speed when Python has to call objects and Mojo’s runtime has to go and fetch this, or having to FFI link (becomes unauditable).
Currently supported Algorithms:
- Argon2
- Blake2b
- Blake3
- Camellia
- Pbkdf2
- SHA2
- SHA-NI
- SHA3
- ChaCha20
- KCipher-2
- ML-KEM / ML-DSA (FFI PQC, this is soon to be replaced with pure mojo implementation)
- AES-GPU (XTS/CBC/ECB/CTR/GCM/ECB/CTR)
- AES-NI (XTS/CBC/ECB/CTR/GCM/ECB/CTR)
- AES-Software (XTS/CBC/ECB/CTR/GCM/ECB/CTR)
- ECDSA/EdDSA (ED25519/X25519)
Benchmarks (Mac Mini M4):
sha256 | throughput: 462.06 mb/s, hashes: 10, time: 2.16s
sha512 | throughput: 561.36 mb/s, hashes: 12, time: 2.13s
sha3-256 | throughput: 731.94 mb/s, hashes: 15, time: 2.04s
blake2b | throughput: 1511.3 mb/s, hashes: 31, time: 2.05s
blake3 | throughput: 10270. mb/s, hashes: 206, time: 2.00s
camellia | throughput: 848.38 mb/s, blocks: 111198959, time: 2.00s
chacha20 | throughput: 954.56 mb/s, encrypts: 1910, time: 2.00s
kcipher2 | throughput: 857.47 mb/s, encrypts: 1715, time: 2.00s
aes-128-cpu | throughput: 30.382 mb/s, blocks: 3982288, time: 2.0s
aes-128-gpu-ecb | throughput: 3.8553 gb/s, iterations: 50
aes-128-gpu-cbc | throughput: 4.4409 gb/s, iterations: 50
aes-128-gpu-ctr | throughput: 4.5398 gb/s, iterations: 50
argon2id | throughput: 41.420 h/s, hashes: 83, time: 2.00s
RTX 2070 Super GPU tests:
AES-CTR: 15.9 GB/s
AES-ECB: 27 GB/s
AES-CBC: 23 GB/s
Thistle Crypto Test Vectors
Argon2 [pass] (30 vectors)
BLAKE2b [pass] (30 vectors)
BLAKE3 [pass] (35 vectors)
Camellia [pass] (26 vectors)
ChaCha20 [pass] (30 vectors)
KCipher2 [pass] (192 vectors)
PBKDF2 [pass] (26 vectors)
SHA [pass] (259 vectors)
AES-128-CPU [pass] (10001 vectors)
AES-128-NI [pass] (10001 vectors)
SHA256-NI [pass] (65 vectors)
Total: 20695 pass, 0 fail
Asymmetric:
Wycheproof Ed25519 150 passed
Wycheproof x25519 518 passed
All Tests pass
Notes:
Some benchmarks are not demonstrated here, such as SHA-NI or AES-NI (these do not matter for the purpose of demonstration, as they are lowered via LLVM intrinsics).
Thistle is not claiming formal proof of security (nobody can for this matter). Compiler bugs, backend difference, and target lowering issues are always possible causing crypto operations to fail.
Supported OS: Linux, macOS (ARM).
Repo: GitHub - libalpm64/Thistle: Native Crypto Helper Library Written in Mojo · GitHub