Add support for signing store paths using ML-DSA-65#449
Add support for signing store paths using ML-DSA-65#449
Conversation
ML-DSA-65 is a post-quantum cryptography signaturew scheme/ To use, just call `nix key generate-secret` with `--key-type ml-dsa-65`, otherwise it works the same as ed25519 (libsodium) signatures except that it produces much bigger keys/signatures
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughThis PR refactors deleter utilities into a shared library location and introduces multi-algorithm cryptographic key support by adding a KeyType system to enable Ed25519 and MLDSA-65 key generation, signing, and verification. ChangesDeleter Utility Refactoring
Key Type System & MLDSA-65 Support
Sequence Diagram(s)sequenceDiagram
participant User as User/CLI
participant Sigs as nix/sigs.cc
participant KeyLib as local-keys.cc
participant OpenSSL as OpenSSL (EVP)
participant FileIO as File Storage
User->>Sigs: Run key generation with --key-type
Sigs->>Sigs: Parse key type string
Sigs->>KeyLib: SecretKey::generate(name, KeyType::MLDSA65)
alt MLDSA-65
KeyLib->>OpenSSL: EVP_PKEY_CTX_new_id(NID_MLDSA65)
OpenSSL-->>KeyLib: EVP context
KeyLib->>OpenSSL: EVP_PKEY_keygen() + DER encode
OpenSSL-->>KeyLib: Encoded MLDSA-65 key
else Ed25519
KeyLib->>KeyLib: Generate Ed25519 key bytes
end
KeyLib-->>Sigs: SecretKey with type
Sigs->>FileIO: Write secret key (with type metadata)
Sigs-->>User: Key generation complete
User->>KeyLib: Sign with SecretKey
alt MLDSA-65
KeyLib->>OpenSSL: EVP_DigestSignInit with MLDSA-65
KeyLib->>OpenSSL: EVP_DigestSignFinal
OpenSSL-->>KeyLib: Deterministic signature
else Ed25519
KeyLib->>KeyLib: Native Ed25519 signing
end
KeyLib-->>User: Signed message
User->>KeyLib: Verify signature
KeyLib->>KeyLib: Detect key type from encoding
alt MLDSA-65
KeyLib->>OpenSSL: EVP_DigestVerifyInit
KeyLib->>OpenSSL: EVP_DigestVerifyFinal
OpenSSL-->>KeyLib: Verification result
else Ed25519
KeyLib->>KeyLib: Native Ed25519 verification
end
KeyLib-->>User: Verification complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Microsoft Presidio Analyzer (2.2.362)src/libfetchers/git-lfs-fetch.ccMicrosoft Presidio Analyzer failed to scan this file src/libfetchers/git-utils.ccMicrosoft Presidio Analyzer failed to scan this file Comment |
Motivation
ML-DSA-65 is a post-quantum cryptography signature scheme.
To use, just call
nix key generate-secretwith--key-type ml-dsa-65, otherwise it works the same as ed25519 (libsodium) signatures except that it produces much bigger keys/signatures.Context
Summary by CodeRabbit
New Features
--key-typeCLI flag to specify key algorithm (ed25519 or ml-dsa-65) when generating secret keys.nix key generate-secretcommand workflow with explicit key type specification.Chores