mirror of
https://github.com/apple/swift-crypto
synced 2026-11-24 04:37:48 +00:00
Add support for ML-DSA post-quantum digital signatures inside `_CryptoExtras`. ### Motivation: With the advent of quantum computing, the mathematical foundations on which the cryptographic protocols in use today are based have been questioned, as they can easily be circumvented and violated by quantum computers. While waiting for the creation of quantum computers that work at full capacity, and to protect network communications from "[Harvest Now, Decrypt Later](https://en.wikipedia.org/wiki/Harvest_now,_decrypt_later)" attacks, the cryptographic community is working on post-quantum cryptography algorithms, which work on the traditional computers we use today, but are resistant to future attacks by quantum computers. One of these algorithms is ML-DSA (AKA Dilithium), a module lattice-based signature scheme standardized by NIST in [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final), that is available inside BoringSSL. By including ML-DSA inside Swift Crypto, we can get closer to normalizing quantum secure algorithms and start implementing them into our apps and libraries to make them quantum-proof. ### Modifications: Added a `MLDSA65` enum inside the `_CryptoExtras` module with corresponding `PrivateKey`, `PublicKey` and `Signature` structs that use BoringSSL methods to produce and verify ML-DSA-65 digital signatures, with the code style of other signature schemes in the library. Added tests that cover use cases of the ML-DSA scheme, including [test vectors taken from the BoringSSL repo](https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/mldsa/mldsa_nist_keygen_tests.txt) (extracted from a `.txt` file and encoded in JSON). ### Result: ML-DSA-65 digital signatures can be created and verified with Swift Crypto. --------- Co-authored-by: Cory Benfield <lukasa@apple.com>