Introduction
Overview
OP_NET supports ML-DSA (Module-Lattice-Based Digital Signature Algorithm), also known as FIPS 204, providing quantum-resistant cryptography alongside traditional ECDSA/Schnorr signatures. This hybrid approach ensures your transactions and signatures remain secure even when quantum computers become capable of breaking classical cryptographic schemes.
OP_NET currently supports only ML-DSA LEVEL2.
The following features are included in this implementation:
- Mnemonic Support: BIP39 + BIP360 for quantum key derivation.
- Wallet Management: Hybrid classical + quantum key management.
- Universal Public Key: address.toHex() provides the user's quantum address (SHA-256 of ML-DSA public key).
- Message Signing: ML-DSA and Schnorr signature support.
- Address Verification: Validation for ML-DSA public keys and classical address types.
- Security Levels: Three levels of quantum resistance (LEVEL2, LEVEL3, LEVEL5).
What is ML-DSA?
ML-DSA is a post-quantum cryptographic algorithm standardized by NIST as FIPS 204. It uses lattice-based mathematics that are believed to be resistant to attacks by both classical and quantum computers.
Security Levels
ML-DSA offers three security levels with different key sizes and security guarantees:
| Level | Name | Public Key Size | Signature Size | Security Equivalent | Status |
|---|---|---|---|---|---|
| LEVEL2 | ML-DSA-44 | 1,312 bytes | 2,420 bytes | AES-128 | RECOMMENDED DEFAULT |
| LEVEL3 | ML-DSA-65 | 1,952 bytes | 3,309 bytes | AES-192 | Optional |
| LEVEL5 | ML-DSA-87 | 2,592 bytes | 4,627 bytes | AES-256 | Optional (maximum security) |
Use LEVEL2 (ML-DSA-44): this is the BIP360 default and provides strong quantum resistance with reasonable key sizes. Use LEVEL3 or LEVEL5 only if you need higher security for specific high-value applications.
Hybrid Architecture
OP_NET uses a dual-key system for maximum compatibility and security.
How It Works
- Universal Public Key: ML-DSA public keys are SHA256-hashed to 32 bytes via address.toHex() - this is the user's universal identifier.
- Classical Keys: Maintained separately for Bitcoin transaction signing (P2TR, P2WPKH, etc.).
- Quantum Keys: Provide quantum-resistant authentication and signatures.
- P2OP Addresses: Contract address format (witness version 16) - for OP_NET contracts ONLY, not for user addresses.
Quick Start
import { Mnemonic, MessageSigner, MLDSASecurityLevel } from '@btc-vision/transaction';
import { networks } from '@btc-vision/bitcoin';
// Generate a new quantum-resistant wallet
const mnemonic = Mnemonic.generate(undefined, '', networks.bitcoin, MLDSASecurityLevel.LEVEL2);
// Derive a wallet
const wallet = mnemonic.derive(0);
// Get quantum address (universal public key)
const quantumAddress = wallet.address.toHex();
console.log('Quantum Address:', quantumAddress);
// Sign a message with ML-DSA
const message = 'Hello, Quantum World!';
const signature = MessageSigner.signMLDSAMessage(wallet.mldsaKeypair, message);
console.log('ML-DSA Signature:', Buffer.from(signature.signature).toString('hex'));