CARVIEW |
Select Language
HTTP/2 200
date: Tue, 29 Jul 2025 12:43:12 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"e8564b95abecbba054e4624436924aa7"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=Q6nB5%2F3KyAcHykkTqJSig4zWaWsaWxtFu1HeEXsixO7LY%2F2RmJiNSNfm4oepqnk7t1tCmEyN0Yr0U%2Fsl7ScuoQF2MIqRgZqW6%2BhHLOqmE1%2BpIhs%2FQaOjSMKJtMsFnGmB9zufQtcA5GxjQo9vFJHbiYWjc265oX1SqKSZXkAZ0xVepU0gXgSzA5scBTWkfWblLjAqLRMx35my1YLwNuXFoamqkFszZgfn2UK5R3Ogax95QZ3%2BKG3SMzTO4lcOsFUc5WP27wKM37JAenoVLZODNw%3D%3D--aW8VmA7ipRMtYw1u--zXWuqfog1Lyq0ZDVIS57YQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1972534838.1753792992; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 12:43:12 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 12:43:12 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E38E:8860:B0037F:D14BB6:6888C1E0
API Reference · aabmets/quantcrypt Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 6
API Reference
Mattias Aabmets edited this page Mar 18, 2025
·
12 revisions
- Key Encapsulation Mechanisms
- Digital Signature Schemes
- The Krypton Cipher
- Key Derivation Functions
- Utilities
- Compilation Tools
class MLKEM_512(BaseKEM):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLKEM_512 key encapsulation mechanism algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> KEMParamSizes:
"""Returns the size of the params of this KEM algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def encaps(self, public_key: bytes) -> tuple[bytes, bytes]:
"""Returns a tuple of ciphertext and shared secret bytes."""
def decaps(self, secret_key: bytes, cipher_text: bytes) -> bytes:
"""Returns the bytes of the decapsulated shared secret."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class MLKEM_768(BaseKEM):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLKEM_768 key encapsulation mechanism algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> KEMParamSizes:
"""Returns the size of the params of this KEM algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def encaps(self, public_key: bytes) -> tuple[bytes, bytes]:
"""Returns a tuple of ciphertext and shared secret bytes."""
def decaps(self, secret_key: bytes, cipher_text: bytes) -> bytes:
"""Returns the bytes of the decapsulated shared secret."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class MLKEM_1024(BaseKEM):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLKEM_1024 key encapsulation mechanism algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> KEMParamSizes:
"""Returns the size of the params of this KEM algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def encaps(self, public_key: bytes) -> tuple[bytes, bytes]:
"""Returns a tuple of ciphertext and shared secret bytes."""
def decaps(self, secret_key: bytes, cipher_text: bytes) -> bytes:
"""Returns the bytes of the decapsulated shared secret."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class MLDSA_44(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLDSA_44 digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class MLDSA_65(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLDSA_65 digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class MLDSA_87(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the MLDSA_87 digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class FALCON_512(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the FALCON_512 digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class FALCON_1024(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the FALCON_1024 digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class FAST_SPHINCS(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the FAST_SPHINCS digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class SMALL_SPHINCS(BaseDSS):
variant: PQAVariant
spec: AlgoSpec
def __init__(self, variant: const.PQAVariant = None, *, allow_fallback: bool = True) -> None:
"""Initializes the SMALL_SPHINCS digital signature scheme algorithm
instance with compiled C extension binaries."""
@property
def param_sizes(self) -> DSSParamSizes:
"""Returns the size of the params of this DSS algorithm."""
def keygen(self) -> tuple[bytes, bytes]:
"""Returns a tuple of public key and secret key bytes."""
def sign(self, secret_key: bytes, message: bytes) -> bytes:
"""Returns bytes of the generated signature."""
def verify(
self,
public_key: bytes,
message: bytes,
signature: bytes,
*,
raises: bool = True
) -> bool:
"""Returns True on successful signature verification."""
def sign_file(
self,
secret_key: str | bytes,
data_file: str | Path,
callback: Optional[Callable] = None
) -> SignedFile:
"""Computes and signs the hash of the data file to generate the signature."""
def verify_file(
self,
public_key: str | bytes,
data_file: str | Path,
signature: bytes,
callback: Optional[Callable] = None,
*,
raises: bool = True
) -> bool:
"""Verifies the signature against the computed hash of the data file."""
def armor(self, key_bytes: bytes) -> str:
"""Returns a base64-encoded ASCII string of the key bytes."""
def dearmor(self, armored_key: str) -> bytes:
"""Returns the key bytes from an armored key ASCII string."""
class Krypton:
def __init__(
self,
secret_key: bytes,
context: bytes = b'',
chunk_size: ChunkSize.Atd = None
) -> None:
"""
Creates a new Krypton instance for encrypting and/or decrypting
multiple messages with the same secret key and configuration.
"""
def flush(self) -> None:
"""Resets the ciphers internal state."""
def begin_encryption(self, header: bytes = b'') -> None:
"""Prepares the Krypton instance for encryption mode."""
def encrypt(self, plaintext: bytes) -> bytes:
"""Encrypts plaintext into ciphertext."""
def finish_encryption(self) -> bytes:
"""Finalizes the encryption process."""
def begin_decryption(self, verif_data: bytes, header: bytes = b'') -> None:
"""Prepares the Krypton instance for decryption mode."""
def decrypt(self, ciphertext: bytes) -> bytes:
"""Decrypts ciphertext into plaintext."""
def finish_decryption(self) -> None:
"""Finalizes the decryption process."""
class KryptonFile:
def __init__(
self,
secret_key: bytes,
context: bytes = b'',
callback: Optional[Callable] = None,
chunk_size: ChunkSize.Atd = None
) -> None:
"""
Creates a new KryptonFile instance for encrypting and/or decrypting multiple
files of arbitrary sizes with the same secret key using the same configuration.
"""
def encrypt(
self,
data_file: str | Path,
output_file: str | Path,
header: bytes = b''
) -> None:
"""
Reads plaintext from the `data_file` in chunks and encrypts them into
ciphertext, writing the encrypted ciphertext chunks into the output_file.
The header data is also written into the `output_file`.
"""
def decrypt_to_file(
self,
encrypted_file: str | Path,
output_file: str | Path
) -> bytes:
"""
Reads ciphertext from the `encrypted_file` in chunks and decrypts them
into plaintext, writing the decrypted plaintext chunks into the output_file.
"""
def decrypt_to_memory(self, encrypted_file: str | Path) -> DecryptedFile:
"""
Reads ciphertext from the `encrypted_file` in chunks and decrypts
them into plaintext, storing the entire decrypted plaintext into memory.
"""
@classmethod
def read_file_header(cls, encrypted_file: str | Path) -> bytes:
"""Reads the header bytes from a Krypton ciphertext file."""
class KryptonKEM:
def __init__(
self,
kem_class: Type[BaseKEM],
kdf_params: KDFParams = None,
context: bytes = b"quantcrypt",
callback: Optional[Callable] = None,
chunk_size: ChunkSize.Atd = None
) -> None:
"""
Creates a new KryptonKEM instance for encrypting and/or decrypting
multiple files of arbitrary sizes with KEM public and private keys
using the same configuration. Internally uses **KryptonFile** class.
"""
def encrypt(
self,
public_key: str | bytes,
data_file: str | Path,
output_file: str | Path
) -> None:
"""
Encapsulates the provided public_key into a shared secret, which is
transformed with Argon2.Key into a 64 byte key for the KryptonFile class.
Then, encrypts the plaintext data from the data_file and writes it into
the output_file along with any necessary metadata to decrypt the file
with the secret_key of the KEM keypair.
"""
def decrypt_to_file(
self,
secret_key: str | bytes,
encrypted_file: str | Path,
output_file: str | Path = None
) -> bytes:
"""
Decapsulates the shared secret from the file metadata using the
provided KEM secret key, which is then transformed with Argon2.Key
into a 64 byte key for the KryptonFile class. Then, decrypts the
ciphertext data from the encrypted file and writes the plaintext
into the output_file, recreating the original plaintext file.
"""
def decrypt_to_memory(
self,
secret_key: str | bytes,
encrypted_file: str | Path
) -> DecryptedFile:
"""
Decapsulates the shared secret from the file metadata using the
provided KEM secret key, which is then transformed with Argon2.Key
into a 64 byte key for the KryptonFile class. Then, decrypts the
ciphertext data from the encrypted file and writes the plaintext
into memory. **Note:** Do NOT decrypt huge files (>100MB) into
memory, use your best judgement.
"""
class Argon2:
Hash = Argon2Hash
Key = Argon2Key
class Argon2Hash(BaseArgon2):
public_hash: Optional[str] = None
rehashed: bool = False
verified: bool = False
def __init__(
self,
password: str | bytes,
verif_hash: str | bytes = None,
*,
min_years: int = 1,
params: KDFParams = None
) -> None:
"""
Computes the Argon2 hash immediately on class
instantiation using the provided parameters.
"""
class Argon2Key(BaseArgon2):
secret_key: Optional[bytes] = None
public_salt: Optional[str] = None
def __init__(
self,
password: str | bytes,
public_salt: str | bytes = None,
*,
min_years: int = 10,
params: KDFParams = None
) -> None:
"""
Computes the Argon2 derived secret key immediately on
class instantiation using the provided parameters.
"""
class KKDF:
def __new__(
cls,
master: bytes,
key_len: int = 32,
num_keys: int = 1,
salt: bytes = None,
context: bytes = None
) -> tuple[bytes, ...]:
"""
Computes the KMAC-KDF derived secret keys immediately
on class instantiation using the provided parameters.
Returns the generated keys as a tuple of bytes.
"""
@dataclass
class DecryptedFile:
plaintext: bytes
header: bytes
class MemCost:
MB = MemCostMB
GB = MemCostGB
class MemCostMB(dict):
def __init__(self, size: Literal[32, 64, 128, 256, 512]) -> None:
"""Converts the size input argument value of megabytes to kilobytes."""
class MemCostGB(dict):
def __init__(self, size: Literal[1, 2, 3, 4, 5, 6, 7, 8]) -> None:
"""Converts the size input argument value of gigabytes to kilobytes."""
class KDFParams(DotMap):
def __init__(
self,
memory_cost: MemCostMB | MemCostGB,
parallelism: int,
time_cost: int,
hash_len: int = 32,
salt_len: int = 32
) -> None:
"""
Custom parameters for altering the security
level of key derivation functions.
"""
class PQAVariant(ExtendedEnum):
REF = "clean"
OPT_AMD = "avx2"
OPT_ARM = "aarch64"
class PQAType(ExtendedEnum):
KEM = "crypto_kem"
DSS = "crypto_sign"
@dataclass(frozen=True)
class AlgoSpec:
type: PQAType
src_subdir: Path
pqclean_name: str
class_name: str
class AlgoSpecsList(list):
def pqclean_names(self: list[AlgoSpec]) -> list[str]:
"""Returns the pqclean_names of all contained AlgoSpecs."""
def armor_names(self: list[AlgoSpec], pqa_type: PQAType | None = None) -> list[str]:
"""Returns the armor_names of all contained AlgoSpecs. Permits filtering by PQAType."""
def filter(self, armor_names: list[str], invert: bool = False) -> list[AlgoSpec]:
"""Returns specs which exist in armor_names. Can invert filtering behavior."""
SupportedAlgos: AlgoSpecList[AlgoSpec]
@dataclass
class SignedFile:
algo_name: str
signature: bytes
file_digest: bytes
class ChunkSize:
KB = ChunkSizeKB
MB = ChunkSizeMB
class ChunkSizeKB(dict):
def __init__(self, size: Literal[1, 2, 4, 8, 16, 32, 64, 128, 256]) -> None:
"""Converts the size input argument value of kilobytes to bytes."""
class ChunkSizeMB(dict):
def __init__(self, size: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -> None:
"""Converts the size input argument value of megabytes to bytes."""
@dataclass(frozen=True)
class Target:
spec: const.AlgoSpec
variant: const.PQAVariant
source_dir: Path
required_flags: list[str]
accepted: bool
class Compiler:
@classmethod
def run(cls,
target_variants: list[const.PQAVariant] = None,
target_algos: list[const.AlgoSpec] = None,
*,
in_subprocess: bool = False,
verbose: bool = False,
debug: bool = False,
) -> subprocess.Popen | list[Target]:
"""
Compiles the target variants of the target algorithms and stores the
compiled binaries within the internals of the QuantCrypt library.
"""
Clone this wiki locally
You can’t perform that action at this time.