0 branches
Tree Top files
Code
Clone with HTTPS:
56 years ago
..
README.md all: super batch 2 fixes last Apr 4 1.05 KB
encoding.v all: super_batch6 fixes last Apr 17 13.27 KB
mldsa.c.v all: super batch 2 fixes last Apr 4 3.37 KB
ntt.v all: super_batch3 fixes last Apr 13 6.39 KB
prehash.v all: super_batch6 fixes last Apr 17 2.17 KB

mldsa

Pure V implementation of ML-DSA (FIPS 204), a post-quantum digital signature algorithm. Supports all three parameter sets (ML-DSA-44, ML-DSA-65, ML-DSA-87).

This is still experimental It is verified against NIST ACVP test vectors for keygen, signing, and verification, but not yet production-ready.

Example

import x.crypto.mldsa

fn main() {
    // generate a new ML-DSA-65 key pair
    sk := mldsa.PrivateKey.generate(.ml_dsa_65)!
    pk := sk.public_key()

    // sign a message (with an optional context string)
    msg := 'Hello ML-DSA'.bytes()
    sig := sk.sign(msg, context: 'not-a-drill')!

    // verify the signature with the same context
    verified := pk.verify(msg, sig, context: 'not-a-drill')!
    assert verified // true

    // deterministic signing is also available
    sig2 := sk.sign(msg, context: 'not-a-drill', deterministic: true)!
    verified2 := pk.verify(msg, sig2, context: 'not-a-drill')!
    assert verified2 // true
}