@openforge-sh/liboqs - v0.14.3
    Preparing search index...

    Class MLDSA87

    ML-DSA-87 digital signature wrapper class

    Provides high-level interface for ML-DSA-87 digital signature operations. Automatically manages WASM memory and validates inputs.

    MLDSA87

    const sig = await createMLDSA87();
    const { publicKey, secretKey } = sig.generateKeyPair();

    const message = new TextEncoder().encode('Hello, quantum world!');
    const signature = sig.sign(message, secretKey);

    const isValid = sig.verify(message, signature, publicKey);
    console.log('Valid:', isValid); // true

    sig.destroy();
    Index

    Accessors

    • get info(): {
          name: "ML-DSA-87";
          identifier: "ML-DSA-87";
          type: "sig";
          securityLevel: 5;
          standardized: true;
          description: string;
          keySize: { publicKey: 2592; secretKey: 4896; signature: 4627 };
      }

      Get algorithm information

      Returns {
          name: "ML-DSA-87";
          identifier: "ML-DSA-87";
          type: "sig";
          securityLevel: 5;
          standardized: true;
          description: string;
          keySize: { publicKey: 2592; secretKey: 4896; signature: 4627 };
      }

      Algorithm metadata

    Methods

    • Generate a new ML-DSA-87 keypair

      Creates a new public/private keypair for digital signatures. The secret key must be kept confidential.

      Returns { publicKey: Uint8Array; secretKey: Uint8Array }

      If key generation fails

      const { publicKey, secretKey } = sig.generateKeyPair();
      
    • Sign a message using the secret key

      Generates a digital signature for the provided message. The signature can be verified using the corresponding public key.

      Parameters

      • message: Uint8Array<ArrayBufferLike>

        Message to sign (arbitrary length)

      • secretKey: Uint8Array<ArrayBufferLike>

        Secret key for signing (4896 bytes)

      Returns Uint8Array<ArrayBufferLike>

      Digital signature (up to 4627 bytes)

      If inputs are invalid

      If signing fails

      const message = new TextEncoder().encode('Hello!');
      const signature = sig.sign(message, secretKey);
    • Verify a signature against a message using the public key

      Verifies that the signature is valid for the given message and public key.

      Parameters

      • message: Uint8Array<ArrayBufferLike>

        Original message that was signed

      • signature: Uint8Array<ArrayBufferLike>

        Signature to verify

      • publicKey: Uint8Array<ArrayBufferLike>

        Public key for verification (2592 bytes)

      Returns boolean

      True if signature is valid, false otherwise

      If inputs are invalid

      const isValid = sig.verify(message, signature, publicKey);
      if (isValid) {
      console.log('Signature is valid!');
      }
    • Clean up WASM resources

      Frees the native signature structure. The instance cannot be used after calling destroy().

      Returns void

      sig.destroy();