Dilithium Overview
Understanding BTQ's post-quantum cryptographic signature scheme
Dilithium Overview
BTQ Core implements CRYSTALS-Dilithium as specified in NIST FIPS 204, providing quantum-resistant digital signatures that protect against future quantum computer attacks.
Why Dilithium?
Current Bitcoin uses ECDSA (Elliptic Curve Digital Signature Algorithm) based on the secp256k1 curve. While secure against classical computers, ECDSA is vulnerable to quantum attacks:
- Shor's Algorithm can break ECDSA in polynomial time on a sufficiently powerful quantum computer
- A quantum computer with ~2,330 logical qubits could theoretically break Bitcoin's cryptography
- While such computers don't exist today, "harvest now, decrypt later" attacks are a real concern
Dilithium is a lattice-based signature scheme that:
- Was selected by NIST for post-quantum standardization (2024)
- Is based on the Module Learning with Errors (MLWE) problem
- Is believed secure against both classical and quantum adversaries
- Has fast verification (faster than ECDSA!)
Dilithium2 Parameters
BTQ uses Dilithium2 (NIST Security Level 2, equivalent to AES-128):
| Parameter | Value |
|---|---|
| Public Key Size | 1,312 bytes |
| Secret Key Size | 2,560 bytes |
| Signature Size | 2,420 bytes |
| Security Level | NIST Level 2 (128-bit quantum) |
Dilithium signatures are approximately 34x larger than ECDSA signatures (~71 bytes), and public keys are 40x larger (33 bytes for ECDSA).
Comparison with ECDSA
| Aspect | ECDSA (Bitcoin) | Dilithium (BTQ) |
|---|---|---|
| Public Key | 33 bytes | 1,312 bytes |
| Signature | ~71 bytes | 2,420 bytes |
| Transaction Size | ~250 bytes | ~3,824 bytes |
| Quantum Resistant | No | Yes |
| Verification Speed | ~2ms | ~1.5ms |
| NIST Standardized | Yes (FIPS 186-4) | Yes (FIPS 204) |
How It Works
Key Generation
(pk, sk) = Dilithium2.KeyGen()Where:
pkis the 1,312-byte public keyskis the 2,560-byte secret key
Key generation uses SHAKE-256 as the extendable output function (XOF) for deterministic randomness expansion.
Signing
sig = Dilithium2.Sign(sk, m)Where:
skis the secret keymis the message (transaction sighash)sigis the 2,420-byte signature
The signing process:
- Compute sighash of transaction (SHA-256 double-hash, same as Bitcoin)
- Generate Dilithium signature over sighash
- Append sighash type byte (e.g.,
0x01forSIGHASH_ALL) - Total signature: 2,421 bytes
Verification
result = Dilithium2.Verify(pk, m, sig)Verification returns 1 (valid) or 0 (invalid). BTQ nodes verify Dilithium signatures during:
- Mempool acceptance
- Block validation
- Script execution
Security Properties
Dilithium provides:
- EUF-CMA Security: Existential Unforgeability under Chosen Message Attack
- Quantum Resistance: Based on MLWE hardness, resistant to Shor's algorithm
- Deterministic Signatures: Same inputs produce same signature
- Fast Verification: ~1.5ms on modern hardware
Implementation Architecture
BTQ wraps the Dilithium C reference implementation in C++ classes:
CDilithiumKey (Private Key)
class CDilithiumKey {
void MakeNewKey(); // Generate new keypair
bool Sign(hash, signature); // Sign 32-byte hash
bool Load(privkey); // Import private key
CDilithiumPubKey GetPubKey(); // Extract public key
};CDilithiumPubKey (Public Key)
class CDilithiumPubKey {
bool Verify(hash, signature); // Verify signature
CKeyID GetID(); // 160-bit key identifier
size_t Size(); // Returns 1312
};The key identifier is computed as RIPEMD160(SHA256(pubkey)), consistent with Bitcoin's approach.
Network Parameters
BTQ adjusts consensus parameters to accommodate larger Dilithium signatures:
| Parameter | Bitcoin | BTQ |
|---|---|---|
| Max Block Size | 1MB (4MW) | 8MB (8MW) |
| Max Sigops | 20,000 | 80,000 |
| Max Script Element | 520 bytes | 1,400+ bytes |
This ensures Dilithium transactions are valid under consensus rules while maintaining network security.
Current Status
| Phase | Status | Description |
|---|---|---|
| Phase 1 | ✅ Complete | Core cryptography (CDilithiumKey, CDilithiumPubKey) |
| Phase 2 | ✅ Complete | Address formats & script opcodes |
| Phase 3 | ✅ Complete | Wallet integration & key storage |
| Phase 4 | ⚠️ Partial | Transaction signing (mempool works) |
| Phase 5 | ⚠️ Partial | Network & mempool policy |
| Phase 6 | ✅ Complete | RPC interface |
Block mining with Dilithium transactions requires additional Phase 4 work for witness commitments. Transactions can be created, signed, and broadcast to mempool.
Learn More
- Dilithium Addresses - Address formats and encoding
- Dilithium Signatures - Signing and verification
- Dilithium Cryptography - Technical deep-dive
- BIP360 P2MR - Witness v2 Pay-to-Merkle-Root rules and behavior