Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Python type declarations

The following type stub documents the native binding. Import public classes from quantaegis. Names beginning with an underscore describe implementation details. Import deterministic KEM test helpers from the public quantaegis.hazmat module. Using the Python API

"""PEP 484 type stubs for the native Rust extension module ``quantaegis._native``.

Secret memory hygiene: the native layer zeroizes its own Rust-side copies of secret material
(keys, seeds, derandomization inputs, shared secrets, decrypted plaintexts, PKCS#8 DER/PEM
buffers) on every exit path, including errors, and borrows secret arguments instead of copying
them where it can. Python ``bytes`` and ``str`` objects that hold
secrets -- arguments you pass in and values returned to you (secret keys, seeds, shared secrets,
plaintexts, private-key PEM text) -- are immutable and owned by the Python allocator, so this
library cannot zeroize them; they may remain in process memory until the interpreter reuses it.
Keep their lifetime short and avoid making extra copies.
"""

from collections.abc import Sequence
from typing import Final, final

__all__ = [
    "AgileKem",
    "AgileSignature",
    "DecryptionError",
    "Envelope",
    "InvalidCiphertextError",
    "InvalidKeyError",
    "MlDsa44",
    "MlDsa65",
    "MlDsa65Ed25519",
    "MlDsa87",
    "MlDsaMuHasher",
    "MlKem1024",
    "MlKem512",
    "MlKem768",
    "PolicyViolationError",
    "QuantAegisError",
    "SerializationError",
    "SlhDsaShake128f",
    "SlhDsaShake128s",
    "SlhDsaShake192f",
    "SlhDsaShake192s",
    "SlhDsaShake256f",
    "SlhDsaShake256s",
    "UnsupportedAlgorithmError",
    "VerificationError",
    "XWing",
    "_HazmatMlKem1024",
    "_HazmatMlKem512",
    "_HazmatMlKem768",
    "_HazmatXWing",
    "__version__",
    "ml_dsa_private_from_pkcs8_der",
    "ml_dsa_private_from_pkcs8_pem",
    "ml_dsa_public_from_spki_der",
    "ml_dsa_public_from_spki_pem",
    "ml_dsa_public_to_spki_der",
    "ml_dsa_public_to_spki_pem",
    "ml_dsa_seed_to_pkcs8_der",
    "ml_dsa_seed_to_pkcs8_pem",
    "ml_kem_private_from_pkcs8_der",
    "ml_kem_private_from_pkcs8_pem",
    "ml_kem_public_from_spki_der",
    "ml_kem_public_from_spki_pem",
    "ml_kem_public_to_spki_der",
    "ml_kem_public_to_spki_pem",
    "ml_kem_seed_to_pkcs8_der",
    "ml_kem_seed_to_pkcs8_pem",
    "sha3_256",
    "sha3_512",
    "shake128",
    "shake256",
    "slh_dsa_private_from_pkcs8_der",
    "slh_dsa_private_from_pkcs8_pem",
    "slh_dsa_private_to_pkcs8_der",
    "slh_dsa_private_to_pkcs8_pem",
    "slh_dsa_public_from_spki_der",
    "slh_dsa_public_from_spki_pem",
    "slh_dsa_public_to_spki_der",
    "slh_dsa_public_to_spki_pem",
]

__version__: Final[str]

class QuantAegisError(ValueError):
    """Base exception raised when a QuantAegis cryptographic, policy, or serialization operation fails."""

class VerificationError(QuantAegisError):
    """Raised when digital signature verification fails or a signature is malformed or has an invalid length."""

class InvalidKeyError(QuantAegisError):
    """Raised when an encapsulation, decapsulation, verifying, or signing key (or key seed) is malformed, has an invalid length, or fails validation."""

class InvalidCiphertextError(QuantAegisError):
    """Raised when a KEM ciphertext is malformed or has an invalid length."""

class DecryptionError(QuantAegisError):
    """Raised on envelope format/length errors and failed AEAD authentication.

    Before authentication, a declared KEM can also cause PolicyViolationError
    or InvalidKeyError during single-key open.
    """

class PolicyViolationError(QuantAegisError):
    """Raised when a requested algorithm or key violates the active SecurityPolicy."""

class SerializationError(QuantAegisError):
    """Raised when PEM, DER, SPKI, or PKCS#8 encoding/decoding fails."""

class UnsupportedAlgorithmError(QuantAegisError):
    """Raised when an unknown or unsupported algorithm or security policy name is requested."""

def sha3_256(data: bytes) -> bytes: ...
def sha3_512(data: bytes) -> bytes: ...
def shake128(data: bytes, output_len: int) -> bytes:
    """Computes ``SHAKE128(data)`` with an ``output_len``-byte output.

    ``output_len`` must be at most 16 MiB (``16 * 1024 * 1024`` bytes); larger values raise
    ``QuantAegisError`` (a ``ValueError``). Raises ``MemoryError`` if the output buffer cannot
    be allocated.
    """

def shake256(data: bytes, output_len: int) -> bytes:
    """Computes ``SHAKE256(data)`` with an ``output_len``-byte output.

    ``output_len`` must be at most 16 MiB (``16 * 1024 * 1024`` bytes); larger values raise
    ``QuantAegisError`` (a ``ValueError``). Raises ``MemoryError`` if the output buffer cannot
    be allocated.
    """

def ml_kem_public_to_spki_pem(algorithm: str, raw_ek: bytes) -> str: ...
def ml_kem_public_from_spki_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_kem_public_to_spki_der(algorithm: str, raw_ek: bytes) -> bytes: ...
def ml_kem_public_from_spki_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_kem_seed_to_pkcs8_pem(algorithm: str, seed: bytes) -> str: ...
def ml_kem_private_from_pkcs8_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_kem_seed_to_pkcs8_der(algorithm: str, seed: bytes) -> bytes: ...
def ml_kem_private_from_pkcs8_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...

def ml_dsa_public_to_spki_pem(algorithm: str, raw_pk: bytes) -> str: ...
def ml_dsa_public_from_spki_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_dsa_public_to_spki_der(algorithm: str, raw_pk: bytes) -> bytes: ...
def ml_dsa_public_from_spki_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_dsa_seed_to_pkcs8_pem(algorithm: str, seed: bytes) -> str: ...
def ml_dsa_private_from_pkcs8_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def ml_dsa_seed_to_pkcs8_der(algorithm: str, seed: bytes) -> bytes: ...
def ml_dsa_private_from_pkcs8_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...

def slh_dsa_public_to_spki_pem(algorithm: str, raw_pk: bytes) -> str: ...
def slh_dsa_public_from_spki_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def slh_dsa_public_to_spki_der(algorithm: str, raw_pk: bytes) -> bytes: ...
def slh_dsa_public_from_spki_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def slh_dsa_private_to_pkcs8_pem(algorithm: str, raw_sk: bytes) -> str: ...
def slh_dsa_private_from_pkcs8_pem(
    pem: str, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...
def slh_dsa_private_to_pkcs8_der(algorithm: str, raw_sk: bytes) -> bytes: ...
def slh_dsa_private_from_pkcs8_der(
    der: bytes, *, policy: str = "cryptrec_category3_plus"
) -> tuple[str, bytes]: ...

@final
class MlKem512:
    EK_LEN: Final[int]
    DK_LEN: Final[int]
    CT_LEN: Final[int]
    SHARED_SECRET_LEN: Final[int]
    SEED_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def encaps(ek: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def decaps(dk: bytes, ct: bytes) -> bytes: ...
    @staticmethod
    def validate_ek(ek: bytes) -> None: ...
    @staticmethod
    def validate_dk(dk: bytes) -> None: ...

@final
class MlKem768:
    EK_LEN: Final[int]
    DK_LEN: Final[int]
    CT_LEN: Final[int]
    SHARED_SECRET_LEN: Final[int]
    SEED_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def encaps(ek: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def decaps(dk: bytes, ct: bytes) -> bytes: ...
    @staticmethod
    def validate_ek(ek: bytes) -> None: ...
    @staticmethod
    def validate_dk(dk: bytes) -> None: ...

@final
class MlKem1024:
    EK_LEN: Final[int]
    DK_LEN: Final[int]
    CT_LEN: Final[int]
    SHARED_SECRET_LEN: Final[int]
    SEED_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def encaps(ek: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def decaps(dk: bytes, ct: bytes) -> bytes: ...
    @staticmethod
    def validate_ek(ek: bytes) -> None: ...
    @staticmethod
    def validate_dk(dk: bytes) -> None: ...

@final
class XWing:
    EK_LEN: Final[int]
    DK_LEN: Final[int]
    CT_LEN: Final[int]
    SHARED_SECRET_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def encaps(ek: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def decaps(dk: bytes, ct: bytes) -> bytes: ...
    @staticmethod
    def validate_ek(ek: bytes) -> None: ...

@final
class _HazmatMlKem512:
    SEED_LEN: Final[int]

    @staticmethod
    def keygen_derand(d: bytes, z: bytes) -> tuple[bytes, bytes]:
        """Deterministic key generation for known-answer tests. Use ``MlKem512.keygen()`` in production.

        Hazardous: ``d`` and ``z`` must come from a CSPRNG and be kept secret. Pass the same
        values again only to re-derive the same key pair.
        """
    @staticmethod
    def encaps_derand(ek: bytes, m: bytes) -> tuple[bytes, bytes]:
        """Deterministic encapsulation for known-answer tests. Use ``MlKem512.encaps()`` in production.

        Hazardous: ``m`` must come from a CSPRNG, be kept secret and be fresh for every call.
        Reusing ``m`` yields the same ciphertext and shared secret.
        """

@final
class _HazmatMlKem768:
    SEED_LEN: Final[int]

    @staticmethod
    def keygen_derand(d: bytes, z: bytes) -> tuple[bytes, bytes]:
        """Deterministic key generation for known-answer tests. Use ``MlKem768.keygen()`` in production.

        Hazardous: ``d`` and ``z`` must come from a CSPRNG and be kept secret. Pass the same
        values again only to re-derive the same key pair.
        """
    @staticmethod
    def encaps_derand(ek: bytes, m: bytes) -> tuple[bytes, bytes]:
        """Deterministic encapsulation for known-answer tests. Use ``MlKem768.encaps()`` in production.

        Hazardous: ``m`` must come from a CSPRNG, be kept secret and be fresh for every call.
        Reusing ``m`` yields the same ciphertext and shared secret.
        """

@final
class _HazmatMlKem1024:
    SEED_LEN: Final[int]

    @staticmethod
    def keygen_derand(d: bytes, z: bytes) -> tuple[bytes, bytes]:
        """Deterministic key generation for known-answer tests. Use ``MlKem1024.keygen()`` in production.

        Hazardous: ``d`` and ``z`` must come from a CSPRNG and be kept secret. Pass the same
        values again only to re-derive the same key pair.
        """
    @staticmethod
    def encaps_derand(ek: bytes, m: bytes) -> tuple[bytes, bytes]:
        """Deterministic encapsulation for known-answer tests. Use ``MlKem1024.encaps()`` in production.

        Hazardous: ``m`` must come from a CSPRNG, be kept secret and be fresh for every call.
        Reusing ``m`` yields the same ciphertext and shared secret.
        """

@final
class _HazmatXWing:
    ENCAPS_SEED_LEN: Final[int]

    @staticmethod
    def keygen_derand(sk: bytes) -> tuple[bytes, bytes]:
        """Deterministic key generation for known-answer tests. Use ``XWing.keygen()`` in production.

        Hazardous: ``sk`` (the 32-byte seed) must come from a CSPRNG and be kept secret. Pass
        the same value again only to re-derive the same key pair.
        """
    @staticmethod
    def encaps_derand(ek: bytes, eseed: bytes) -> tuple[bytes, bytes]:
        """Deterministic encapsulation for known-answer tests. Use ``XWing.encaps()`` in production.

        Hazardous: ``eseed`` must come from a CSPRNG, be kept secret and be fresh for every
        call. Reusing ``eseed`` yields the same ciphertext and shared secret.
        """

@final
class MlDsaMuHasher:
    MU_LEN: Final[int]

    @staticmethod
    def from_verifying_key(
        algorithm: str, pk: bytes, *, ctx: bytes | None = None
    ) -> MlDsaMuHasher: ...
    @staticmethod
    def from_signing_key(
        algorithm: str, sk: bytes, *, ctx: bytes | None = None
    ) -> MlDsaMuHasher: ...
    def update(self, chunk: bytes) -> None: ...
    def finalize(self) -> bytes: ...

@final
class MlDsa44:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    SEED_LEN: Final[int]
    MAX_CTX_LEN: Final[int]
    MU_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def from_seed(seed: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...
    @staticmethod
    def mu_hasher(pk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def mu_hasher_from_sk(sk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def sign_mu(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def sign_mu_deterministic(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def verify_mu(pk: bytes, mu: bytes, sig: bytes) -> None: ...

@final
class MlDsa65:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    SEED_LEN: Final[int]
    MAX_CTX_LEN: Final[int]
    MU_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def from_seed(seed: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...
    @staticmethod
    def mu_hasher(pk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def mu_hasher_from_sk(sk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def sign_mu(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def sign_mu_deterministic(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def verify_mu(pk: bytes, mu: bytes, sig: bytes) -> None: ...

@final
class MlDsa87:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    SEED_LEN: Final[int]
    MAX_CTX_LEN: Final[int]
    MU_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def from_seed(seed: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...
    @staticmethod
    def mu_hasher(pk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def mu_hasher_from_sk(sk: bytes, *, ctx: bytes | None = None) -> MlDsaMuHasher: ...
    @staticmethod
    def sign_mu(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def sign_mu_deterministic(sk: bytes, mu: bytes) -> bytes: ...
    @staticmethod
    def verify_mu(pk: bytes, mu: bytes, sig: bytes) -> None: ...

@final
class MlDsa65Ed25519:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def from_seed(seed: bytes) -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake128s:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake128f:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake192s:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake192f:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake256s:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class SlhDsaShake256f:
    PK_LEN: Final[int]
    SK_LEN: Final[int]
    SIG_LEN: Final[int]
    MAX_CTX_LEN: Final[int]

    @staticmethod
    def keygen() -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def sign_deterministic(sk: bytes, msg: bytes, *, ctx: bytes | None = None) -> bytes: ...
    @staticmethod
    def verify(pk: bytes, msg: bytes, sig: bytes, *, ctx: bytes | None = None) -> None: ...

@final
class Envelope:
    @staticmethod
    def generate_keypair(
        algorithm: str = "x-wing",
        policy: str = "cryptrec_category3_plus",
    ) -> tuple[bytes, bytes]: ...
    @staticmethod
    def seal(
        public_key: bytes,
        plaintext: bytes,
        *,
        aad: bytes | None = None,
        aead: str = "aes-256-gcm",
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def open(
        secret_key: bytes,
        envelope: bytes,
        *,
        aad: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def open_with_keyring(
        secret_keys: Sequence[bytes],
        envelope: bytes,
        *,
        aad: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes:
        """Decrypts ``envelope`` with the first matching key of a rotation keyring.

        The envelope's KEM algorithm is checked against ``policy`` first
        (``PolicyViolationError`` if forbidden). Only keys declaring that algorithm are parsed
        and tried, so legacy keys of other algorithms may remain in the ring during a migration.

        Every key's 7-byte wire header must be readable (``InvalidKeyError`` otherwise); the rest
        of a key of another algorithm is not examined. A key of the envelope's algorithm that
        fails to parse raises ``InvalidKeyError`` even if another key in the ring would decrypt.
        ``secret_keys`` must contain ``bytes`` objects.
        """
    @staticmethod
    def inspect(envelope: bytes) -> tuple[str, str, int]: ...

@final
class AgileKem:
    @staticmethod
    def generate_keypair(
        algorithm: str = "x-wing",
        policy: str = "cryptrec_category3_plus",
    ) -> tuple[bytes, bytes]: ...
    @staticmethod
    def encaps(
        public_key: bytes,
        *,
        policy: str = "cryptrec_category3_plus",
    ) -> tuple[bytes, bytes]: ...
    @staticmethod
    def decaps(
        secret_key: bytes,
        ciphertext: bytes,
        *,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def inspect_public_key(
        public_key: bytes,
        *,
        policy: str = "permissive",
    ) -> str: ...
    @staticmethod
    def public_from_raw(
        algorithm: str,
        raw_ek: bytes,
        *,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def secret_from_raw(
        algorithm: str,
        raw_dk: bytes,
        *,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...

@final
class AgileSignature:
    @staticmethod
    def generate_keypair(
        algorithm: str = "ml-dsa-65",
        policy: str = "cryptrec_category3_plus",
    ) -> tuple[bytes, bytes]: ...
    @staticmethod
    def sign(
        signing_key: bytes,
        msg: bytes,
        *,
        ctx: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def sign_deterministic(
        signing_key: bytes,
        msg: bytes,
        *,
        ctx: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> bytes: ...
    @staticmethod
    def verify(
        verifying_key: bytes,
        msg: bytes,
        signature: bytes,
        *,
        ctx: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> None: ...
    @staticmethod
    def verify_with_keyring(
        verifying_keys: Sequence[bytes],
        msg: bytes,
        signature: bytes,
        *,
        ctx: bytes | None = None,
        policy: str = "cryptrec_category3_plus",
    ) -> str:
        """Verifies ``signature`` against a keyring and returns the matched algorithm name.

        The signature's algorithm is checked against ``policy`` first
        (``PolicyViolationError`` if forbidden). Only keys declaring that algorithm are parsed
        and tried, so legacy keys of other algorithms may remain in the ring during a migration.

        Every key's wire frame (11-byte header and declared length) must be well-formed
        (``InvalidKeyError`` otherwise); the key material of a key of another algorithm is not
        examined. A key of the signature's algorithm that fails to parse raises
        ``InvalidKeyError`` even if another key in the ring would verify. A ``ctx`` longer than
        255 bytes raises ``QuantAegisError``, as in ``verify``.
        """
    @staticmethod
    def inspect_verifying_key(
        verifying_key: bytes,
        *,
        policy: str = "permissive",
    ) -> str: ...
    @staticmethod
    def inspect_signature(signature: bytes) -> str: ...