miniproto_native::crypto
Provenance
Section titled “Provenance”- Rust visibility:
crate - Source:
rust/miniproto/src/crypto.rs - Python exposure: Not evidenced by static PyO3 attributes.
Documented items
Section titled “Documented items”miniproto_native::crypto::aes_256_cbc_decryptminiproto_native::crypto::aes_256_cbc_encryptminiproto_native::crypto::aes_256_ctr_cryptminiproto_native::crypto::aes_256_gcm_decryptminiproto_native::crypto::aes_256_gcm_encryptminiproto_native::crypto::aes_256_ige_decryptminiproto_native::crypto::aes_256_ige_encryptminiproto_native::crypto::mtproto_auth_key_idminiproto_native::crypto::mtproto_decrypt_payloadminiproto_native::crypto::mtproto_derive_aes_key_ivminiproto_native::crypto::mtproto_encrypt_payloadminiproto_native::crypto::mtproto_message_keyminiproto_native::crypto::native_availableminiproto_native::crypto::pq_factorizeminiproto_native::crypto::registerminiproto_native::crypto::scrypt_deriveminiproto_native::crypto::sha1_digestminiproto_native::crypto::sha256_digestminiproto_native::crypto::xor_bytes
cargo-docs-md rendering
Section titled “cargo-docs-md rendering”miniproto_native / crypto
Module crypto
Section titled “Module crypto”Registers cryptographic Python callables. Native cryptographic primitives used by MTProto and its Python fallback-compatible API.
Each #[pyfunction] is exported under its Rust name in miniproto._native. Selected wrappers detach for large workloads, while *_raw functions operate without Python objects. PyO3 conversion errors propagate unchanged, and algorithm or byte-shape validation returns ValueError. Python wrappers may select a fallback even when these native exports are available.
Contents
Section titled “Contents”- Functions
detach_if_largeregisternative_available__pyfunction_native_availablesha1_digest__pyfunction_sha1_digestsha256_digest__pyfunction_sha256_digestmtproto_auth_key_id__pyfunction_mtproto_auth_key_idmtproto_message_key__pyfunction_mtproto_message_keymtproto_derive_aes_key_iv__pyfunction_mtproto_derive_aes_key_ivmtproto_encrypt_payload__pyfunction_mtproto_encrypt_payloadmtproto_decrypt_payload__pyfunction_mtproto_decrypt_payloadxor_bytes__pyfunction_xor_bytesaes_256_ige_encrypt__pyfunction_aes_256_ige_encryptaes_256_ige_decrypt__pyfunction_aes_256_ige_decryptaes_256_cbc_encrypt__pyfunction_aes_256_cbc_encryptaes_256_cbc_decrypt__pyfunction_aes_256_cbc_decryptaes_256_ctr_crypt__pyfunction_aes_256_ctr_cryptaes_256_gcm_encrypt__pyfunction_aes_256_gcm_encryptaes_256_gcm_decrypt__pyfunction_aes_256_gcm_decryptscrypt_derive__pyfunction_scrypt_derivepq_factorize__pyfunction_pq_factorizesha1_digest_rawsha256_digest_rawmtproto_auth_key_id_rawmtproto_message_key_rawmtproto_derive_aes_key_iv_rawmtproto_encrypt_payload_rawmtproto_decrypt_payload_rawxor_bytes_rawaes_256_ige_encrypt_rawaes_256_ige_decrypt_rawaes_256_cbc_encrypt_rawaes_256_cbc_decrypt_rawaes_256_ctr_crypt_rawaes_256_gcm_encrypt_rawaes_256_gcm_decrypt_rawscrypt_derive_rawpq_factorize_rawvalidate_auth_keyvalidate_msg_keyvalidate_block_multiplevalidate_aes_keyvalidate_ige_ivvalidate_cbc_ctr_ivvalidate_gcm_noncedirection_offsetxor_blockincrement_countergcdmul_modpow_modis_prime_u64factor_u64
- Constants
Quick Reference
Section titled “Quick Reference”| Item | Kind | Description |
|---|---|---|
detach_if_large |
fn | Runs f without the GIL when its input work estimate exceeds the native threshold. |
register |
fn | Registers this module’s fallback-compatible Python callables on miniproto._native. |
native_available |
fn | Implements Python native_available, which always returns true while this compiled callable is importable. |
__pyfunction_native_available |
fn | |
sha1_digest |
fn | Computes Python sha1_digest(data) and returns the 20-byte SHA-1 digest. |
__pyfunction_sha1_digest |
fn | |
sha256_digest |
fn | Computes Python sha256_digest(data) and returns the 32-byte SHA-256 digest. |
__pyfunction_sha256_digest |
fn | |
mtproto_auth_key_id |
fn | Computes Python mtproto_auth_key_id(auth_key) from a validated 256-byte key. |
__pyfunction_mtproto_auth_key_id |
fn | |
mtproto_message_key |
fn | Computes Python mtproto_message_key for padded plaintext and one MTProto direction. |
__pyfunction_mtproto_message_key |
fn | |
mtproto_derive_aes_key_iv |
fn | Derives the AES-256 key and IV used by Python mtproto_derive_aes_key_iv. |
__pyfunction_mtproto_derive_aes_key_iv |
fn | |
mtproto_encrypt_payload |
fn | Encrypts padded MTProto plaintext for Python mtproto_encrypt_payload. |
__pyfunction_mtproto_encrypt_payload |
fn | |
mtproto_decrypt_payload |
fn | Decrypts and verifies Python mtproto_decrypt_payload ciphertext. |
__pyfunction_mtproto_decrypt_payload |
fn | |
xor_bytes |
fn | Returns the bytewise exclusive-or of Python xor_bytes(left, right) inputs. |
__pyfunction_xor_bytes |
fn | |
aes_256_ige_encrypt |
fn | Encrypts block-aligned bytes with Python aes_256_ige_encrypt. |
__pyfunction_aes_256_ige_encrypt |
fn | |
aes_256_ige_decrypt |
fn | Decrypts block-aligned bytes with Python aes_256_ige_decrypt. |
__pyfunction_aes_256_ige_decrypt |
fn | |
aes_256_cbc_encrypt |
fn | Encrypts block-aligned bytes with Python aes_256_cbc_encrypt without padding. |
__pyfunction_aes_256_cbc_encrypt |
fn | |
aes_256_cbc_decrypt |
fn | Decrypts block-aligned bytes with Python aes_256_cbc_decrypt without padding. |
__pyfunction_aes_256_cbc_decrypt |
fn | |
aes_256_ctr_crypt |
fn | Applies Python aes_256_ctr_crypt to data using AES-CTR keystream XOR. |
__pyfunction_aes_256_ctr_crypt |
fn | |
aes_256_gcm_encrypt |
fn | Authenticated-encrypts Python aes_256_gcm_encrypt plaintext and associated data. |
__pyfunction_aes_256_gcm_encrypt |
fn | |
aes_256_gcm_decrypt |
fn | Authenticated-decrypts Python aes_256_gcm_decrypt ciphertext-and-tag bytes. |
__pyfunction_aes_256_gcm_decrypt |
fn | |
scrypt_derive |
fn | Derives Python scrypt_derive bytes from password, salt and scrypt cost parameters. |
__pyfunction_scrypt_derive |
fn | |
pq_factorize |
fn | Factorizes Python pq_factorize(pq) into ordered nontrivial u64 factors. |
__pyfunction_pq_factorize |
fn | |
sha1_digest_raw |
fn | Computes SHA-1 for Rust callers without Python or GIL interaction. |
sha256_digest_raw |
fn | Computes SHA-256 for Rust callers without Python or GIL interaction. |
mtproto_auth_key_id_raw |
fn | Derives the trailing eight SHA-1 bytes that identify a validated MTProto authorization key. |
mtproto_message_key_raw |
fn | Derives an MTProto 2.0 message key from a validated authorization key and padded plaintext. |
mtproto_derive_aes_key_iv_raw |
fn | Derives the MTProto 2.0 AES-IGE key and IV from validated fixed-width key material. |
mtproto_encrypt_payload_raw |
fn | Produces the auth-key identifier, message key and AES-IGE ciphertext for padded plaintext. |
mtproto_decrypt_payload_raw |
fn | Decrypts and authenticates an MTProto payload using validated directional key derivation. |
xor_bytes_raw |
fn | Computes bytewise XOR for equal-length Rust byte slices. |
aes_256_ige_encrypt_raw |
fn | Encrypts a block-aligned byte slice using AES-256 IGE for Rust callers. |
aes_256_ige_decrypt_raw |
fn | Decrypts a block-aligned AES-256 IGE ciphertext for Rust callers. |
aes_256_cbc_encrypt_raw |
fn | Encrypts a block-aligned byte slice with unpadded AES-256 CBC. |
aes_256_cbc_decrypt_raw |
fn | Decrypts a block-aligned unpadded AES-256 CBC ciphertext. |
aes_256_ctr_crypt_raw |
fn | XORs bytes with an AES-256 CTR keystream; the same operation encrypts and decrypts. |
aes_256_gcm_encrypt_raw |
fn | Authenticated-encrypts plaintext with AES-256 GCM and returns ciphertext plus tag. |
aes_256_gcm_decrypt_raw |
fn | Authenticated-decrypts AES-256 GCM ciphertext-and-tag data. |
scrypt_derive_raw |
fn | Runs scrypt with the library’s output and resource limits for Rust callers |
pq_factorize_raw |
fn | Finds and orders the two nontrivial factors of an MTProto pq value. |
validate_auth_key |
fn | Validates the fixed 256-byte MTProto authorization-key width. |
validate_msg_key |
fn | Validates the fixed 16-byte MTProto message-key width. |
validate_block_multiple |
fn | Validates that AES block-mode input has a whole-number count of AES blocks. |
validate_aes_key |
fn | Validates a 32-byte AES-256 key and returns ValueError otherwise. |
validate_ige_iv |
fn | Validates the two-block, 32-byte IV required by AES-IGE. |
validate_cbc_ctr_iv |
fn | Validates the one-block IV or counter used by CBC and CTR modes. |
validate_gcm_nonce |
fn | Validates the 12-byte nonce mandated by this AES-GCM interface. |
direction_offset |
fn | Returns the MTProto key-schedule offset for the requested packet direction. |
xor_block |
fn | Computes a fixed-width XOR block used by the AES block-mode loops. |
increment_counter |
fn | Advances a big-endian AES-CTR counter in place, wrapping at the full block width. |
gcd |
fn | Computes the greatest common divisor used by Pollard-rho factorization. |
mul_mod |
fn | Multiplies modulo modulus with a widened intermediate to avoid u64 overflow. |
pow_mod |
fn | Computes modular exponentiation for deterministic Miller-Rabin witnesses. |
is_prime_u64 |
fn | Deterministically tests whether a u64 is prime using fixed Miller-Rabin witnesses. |
factor_u64 |
fn | Returns one factor using bounded Pollard-rho iteration, the input when prime or None when exhausted |
AES_BLOCK_SIZE |
const | AES’s fixed block size in bytes. |
MT_PROTO_AUTH_KEY_SIZE |
const | Required byte length of an MTProto authorization key. |
MT_PROTO_MSG_KEY_SIZE |
const | Required byte length of an MTProto 2.0 message key. |
GIL_RELEASE_THRESHOLD_BYTES |
const | Work-size threshold above which native wrappers detach from the Python GIL. |
SCRYPT_MAX_MEMORY_BYTES |
const | Maximum memory estimate accepted by the public scrypt primitive. |
SCRYPT_MAX_WORK_BYTES |
const | Maximum CPU-work estimate accepted by the public scrypt primitive. |
PQ_FACTOR_ATTEMPTS |
const | Maximum Pollard-rho retries, matching the Python fallback |
PQ_FACTOR_ITERATIONS |
const | Maximum Pollard-rho iterations per retry, matching the Python fallback |
Functions
Section titled “Functions”detach_if_large
Section titled “detach_if_large”fn detach_if_large<T, F>(py: Python<'_>, work_bytes: usize, f: F) -> Twhere T: Ungil, F: Ungil + FnOnce() -> TDefined in rust/miniproto/src/crypto.rs:48-58
Runs f without the GIL when its input work estimate exceeds the native threshold.
work_bytes controls thread detachment, and f must satisfy PyO3’s Ungil requirements. Detachment releases the GIL on GIL-enabled builds. The computation remains synchronous.
Arguments
Section titled “Arguments”T: The GIL-independent result type returned byf.F: The one-shot GIL-independent closure performing the native operation.py: The acquired GIL token that can detachf.work_bytes: Conservative byte-work estimate compared with the detach threshold.f: The native computation to run attached or detached.
register
Section titled “register”fn register(m: &Bound<'_, pyo3::types::PyModule>) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:67-87
Registers this module’s fallback-compatible Python callables on miniproto._native.
Returns a PyO3 exception if a callable cannot be added to m.
Arguments
Section titled “Arguments”m: The Python extension module receiving the crypto callables.
native_available
Section titled “native_available”fn native_available() -> boolDefined in rust/miniproto/src/crypto.rs:92-94
Implements Python native_available, which always returns true while this compiled callable
is importable. Python fallback selection happens before this function can be called.
__pyfunction_native_available
Section titled “__pyfunction_native_available”unsafe fn __pyfunction_native_available<'py>(py: ::pyo3::Python<'py>, _slf: *mut ::pyo3::ffi::PyObject) -> ::pyo3::PyResult<*mut ::pyo3::ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:91
sha1_digest
Section titled “sha1_digest”fn sha1_digest(py: Python<'_>, data: Vec<u8>) -> Vec<u8>Defined in rust/miniproto/src/crypto.rs:105-107
Computes Python sha1_digest(data) and returns the 20-byte SHA-1 digest.
Large inputs are hashed with the GIL released.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach a large hash operation.data: Bytes to hash.
__pyfunction_sha1_digest
Section titled “__pyfunction_sha1_digest”unsafe fn __pyfunction_sha1_digest<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:104
sha256_digest
Section titled “sha256_digest”fn sha256_digest(py: Python<'_>, data: Vec<u8>) -> Vec<u8>Defined in rust/miniproto/src/crypto.rs:118-120
Computes Python sha256_digest(data) and returns the 32-byte SHA-256 digest.
Large inputs are hashed with the GIL released.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach a large hash operation.data: Bytes to hash.
__pyfunction_sha256_digest
Section titled “__pyfunction_sha256_digest”unsafe fn __pyfunction_sha256_digest<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:117
mtproto_auth_key_id
Section titled “mtproto_auth_key_id”fn mtproto_auth_key_id(auth_key: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:130-132
Computes Python mtproto_auth_key_id(auth_key) from a validated 256-byte key.
Returns ValueError when auth_key has the wrong length.
Arguments
Section titled “Arguments”auth_key: The 256-byte MTProto authorization key.
__pyfunction_mtproto_auth_key_id
Section titled “__pyfunction_mtproto_auth_key_id”unsafe fn __pyfunction_mtproto_auth_key_id<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:129
mtproto_message_key
Section titled “mtproto_message_key”fn mtproto_message_key(py: Python<'_>, auth_key: Vec<u8>, plaintext_with_padding: Vec<u8>, client_to_server: bool) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:146-161
Computes Python mtproto_message_key for padded plaintext and one MTProto direction.
Returns a 16-byte message key; rejects an invalid authorization key and releases the GIL for large inputs.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach a large hash operation.auth_key: The 256-byte MTProto authorization key.plaintext_with_padding: Inner plaintext including padding, with no alignment or padding validation hereclient_to_server: Selects the directional MTProto key offset.
__pyfunction_mtproto_message_key
Section titled “__pyfunction_mtproto_message_key”unsafe fn __pyfunction_mtproto_message_key<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:145
mtproto_derive_aes_key_iv
Section titled “mtproto_derive_aes_key_iv”fn mtproto_derive_aes_key_iv(py: Python<'_>, auth_key: Vec<u8>, msg_key: Vec<u8>, client_to_server: bool) -> PyResult<(Vec<u8>, Vec<u8>)>Defined in rust/miniproto/src/crypto.rs:174-190
Derives the AES-256 key and IV used by Python mtproto_derive_aes_key_iv.
Returns (key, iv) after validating both inputs. Valid inputs total 272 bytes (auth_key 256 plus msg_key 16), so successful derivations run below the detach threshold.
Arguments
Section titled “Arguments”py: The acquired GIL token retained by this bounded-size operation.auth_key: The 256-byte MTProto authorization key.msg_key: The 16-byte MTProto message key.client_to_server: Selects the directional MTProto key offset.
__pyfunction_mtproto_derive_aes_key_iv
Section titled “__pyfunction_mtproto_derive_aes_key_iv”unsafe fn __pyfunction_mtproto_derive_aes_key_iv<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:173
mtproto_encrypt_payload
Section titled “mtproto_encrypt_payload”fn mtproto_encrypt_payload(py: Python<'_>, auth_key: Vec<u8>, plaintext_with_padding: Vec<u8>, client_to_server: bool) -> PyResult<(Vec<u8>, Vec<u8>, Vec<u8>)>Defined in rust/miniproto/src/crypto.rs:204-214
Encrypts padded MTProto plaintext for Python mtproto_encrypt_payload.
Returns (auth_key_id, msg_key, ciphertext) or ValueError for invalid key or block input;
large work runs without the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large encryption work.auth_key: The 256-byte MTProto authorization key.plaintext_with_padding: AES-block-aligned inner plaintext to encrypt.client_to_server: Selects the directional MTProto key schedule.
__pyfunction_mtproto_encrypt_payload
Section titled “__pyfunction_mtproto_encrypt_payload”unsafe fn __pyfunction_mtproto_encrypt_payload<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:203
mtproto_decrypt_payload
Section titled “mtproto_decrypt_payload”fn mtproto_decrypt_payload(py: Python<'_>, auth_key: Vec<u8>, msg_key: Vec<u8>, ciphertext: Vec<u8>, client_to_server: bool) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:229-240
Decrypts and verifies Python mtproto_decrypt_payload ciphertext.
Returns padded plaintext or ValueError for invalid lengths, key material or message-key
verification; large work runs without the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large decryption work.auth_key: The 256-byte MTProto authorization key.msg_key: The 16-byte message key to verify.ciphertext: AES-IGE ciphertext whose length must be an AES-block multiple.client_to_server: Selects the directional MTProto key schedule.
__pyfunction_mtproto_decrypt_payload
Section titled “__pyfunction_mtproto_decrypt_payload”unsafe fn __pyfunction_mtproto_decrypt_payload<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:228
xor_bytes
Section titled “xor_bytes”fn xor_bytes(left: &[u8], right: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:251-253
Returns the bytewise exclusive-or of Python xor_bytes(left, right) inputs.
Returns ValueError unless both inputs have equal length.
Arguments
Section titled “Arguments”left: First equal-length byte sequence.right: Second equal-length byte sequence.
__pyfunction_xor_bytes
Section titled “__pyfunction_xor_bytes”unsafe fn __pyfunction_xor_bytes<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:250
aes_256_ige_encrypt
Section titled “aes_256_ige_encrypt”fn aes_256_ige_encrypt(py: Python<'_>, plaintext: Vec<u8>, key: Vec<u8>, iv: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:267-277
Encrypts block-aligned bytes with Python aes_256_ige_encrypt.
Requires a 32-byte key and IV; returns ValueError for invalid lengths and releases the GIL
for large plaintexts.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large encryption work.plaintext: AES-block-aligned bytes to encrypt.key: The 32-byte AES-256 key.iv: The 32-byte AES-IGE initialization vector.
__pyfunction_aes_256_ige_encrypt
Section titled “__pyfunction_aes_256_ige_encrypt”unsafe fn __pyfunction_aes_256_ige_encrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:266
aes_256_ige_decrypt
Section titled “aes_256_ige_decrypt”fn aes_256_ige_decrypt(py: Python<'_>, ciphertext: Vec<u8>, key: Vec<u8>, iv: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:291-301
Decrypts block-aligned bytes with Python aes_256_ige_decrypt.
Requires a 32-byte key and IV; returns ValueError for invalid lengths and releases the GIL
for large ciphertexts.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large decryption work.ciphertext: AES-block-aligned bytes to decrypt.key: The 32-byte AES-256 key.iv: The 32-byte AES-IGE initialization vector.
__pyfunction_aes_256_ige_decrypt
Section titled “__pyfunction_aes_256_ige_decrypt”unsafe fn __pyfunction_aes_256_ige_decrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:290
aes_256_cbc_encrypt
Section titled “aes_256_cbc_encrypt”fn aes_256_cbc_encrypt(py: Python<'_>, plaintext: Vec<u8>, key: Vec<u8>, iv: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:315-325
Encrypts block-aligned bytes with Python aes_256_cbc_encrypt without padding.
Requires 32-byte key and 16-byte IV inputs; invalid lengths become ValueError and large
plaintexts release the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large encryption work.plaintext: AES-block-aligned bytes to encrypt.key: The 32-byte AES-256 key.iv: The 16-byte CBC initialization vector.
__pyfunction_aes_256_cbc_encrypt
Section titled “__pyfunction_aes_256_cbc_encrypt”unsafe fn __pyfunction_aes_256_cbc_encrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:314
aes_256_cbc_decrypt
Section titled “aes_256_cbc_decrypt”fn aes_256_cbc_decrypt(py: Python<'_>, ciphertext: Vec<u8>, key: Vec<u8>, iv: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:339-349
Decrypts block-aligned bytes with Python aes_256_cbc_decrypt without padding.
Requires 32-byte key and 16-byte IV inputs; invalid lengths become ValueError and large
ciphertexts release the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large decryption work.ciphertext: AES-block-aligned bytes to decrypt.key: The 32-byte AES-256 key.iv: The 16-byte CBC initialization vector.
__pyfunction_aes_256_cbc_decrypt
Section titled “__pyfunction_aes_256_cbc_decrypt”unsafe fn __pyfunction_aes_256_cbc_decrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:338
aes_256_ctr_crypt
Section titled “aes_256_ctr_crypt”fn aes_256_ctr_crypt(py: Python<'_>, data: Vec<u8>, key: Vec<u8>, iv: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:363-373
Applies Python aes_256_ctr_crypt to data using AES-CTR keystream XOR.
The same routine encrypts and decrypts; it validates the 32-byte key and 16-byte counter IV, and releases the GIL for large data.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large counter-mode work.data: Bytes to encrypt or decrypt.key: The 32-byte AES-256 key.iv: The 16-byte initial counter block.
__pyfunction_aes_256_ctr_crypt
Section titled “__pyfunction_aes_256_ctr_crypt”unsafe fn __pyfunction_aes_256_ctr_crypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:362
aes_256_gcm_encrypt
Section titled “aes_256_gcm_encrypt”fn aes_256_gcm_encrypt(py: Python<'_>, plaintext: Vec<u8>, key: Vec<u8>, nonce: Vec<u8>, associated_data: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:388-399
Authenticated-encrypts Python aes_256_gcm_encrypt plaintext and associated data.
Returns ciphertext followed by its GCM tag or ValueError for a bad 32-byte key, 12-byte
nonce or encryption failure; large work releases the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large authenticated-encryption work.plaintext: Bytes to encrypt.key: The 32-byte AES-256 key.nonce: The 12-byte GCM nonce.associated_data: Authenticated bytes that are not encrypted.
__pyfunction_aes_256_gcm_encrypt
Section titled “__pyfunction_aes_256_gcm_encrypt”unsafe fn __pyfunction_aes_256_gcm_encrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:387
aes_256_gcm_decrypt
Section titled “aes_256_gcm_decrypt”fn aes_256_gcm_decrypt(py: Python<'_>, ciphertext_and_tag: Vec<u8>, key: Vec<u8>, nonce: Vec<u8>, associated_data: Vec<u8>) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:414-425
Authenticated-decrypts Python aes_256_gcm_decrypt ciphertext-and-tag bytes.
Returns plaintext or ValueError for invalid key/nonce material or authentication failure;
large work releases the GIL.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach large authenticated-decryption work.ciphertext_and_tag: GCM ciphertext followed by its authentication tag.key: The 32-byte AES-256 key.nonce: The 12-byte GCM nonce.associated_data: Authenticated bytes that are not encrypted.
__pyfunction_aes_256_gcm_decrypt
Section titled “__pyfunction_aes_256_gcm_decrypt”unsafe fn __pyfunction_aes_256_gcm_decrypt<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:413
scrypt_derive
Section titled “scrypt_derive”fn scrypt_derive(py: Python<'_>, password: Vec<u8>, salt: Vec<u8>, n: u32, r: u32, p: u32, length: usize) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:443-460
Derives Python scrypt_derive bytes from password, salt and scrypt cost parameters.
n must be a power of two above one and length is limited to 1..=1024; invalid parameters
return ValueError. Estimated memory is capped at 256 MiB and aggregate work at 1 GiB. The
GIL is released when the 128 * n * r * p work estimate exceeds 4 KiB.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach only sufficiently large scrypt work.password: Password bytes accepted by scrypt.salt: Salt bytes accepted by scrypt.n: CPU/memory cost, required to be a power of two greater than one.r: scrypt block-size cost parameter.p: scrypt parallelization cost parameter.length: Requested derived-key length in the inclusive range 1..=1024.
__pyfunction_scrypt_derive
Section titled “__pyfunction_scrypt_derive”unsafe fn __pyfunction_scrypt_derive<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:442
pq_factorize
Section titled “pq_factorize”fn pq_factorize(py: Python<'_>, pq: u64) -> PyResult<(u64, u64)>Defined in rust/miniproto/src/crypto.rs:472-474
Factorizes Python pq_factorize(pq) into ordered nontrivial u64 factors.
Returns ValueError for non-composite values and runs the potentially expensive search with
the GIL released.
Arguments
Section titled “Arguments”py: The acquired GIL token used to detach the factorization search.pq: Composite MTProto handshake value to split into ordered factors.
__pyfunction_pq_factorize
Section titled “__pyfunction_pq_factorize”unsafe fn __pyfunction_pq_factorize<'py>(py: Python<'py>, _slf: *mut ffi::PyObject, _args: *const *mut ffi::PyObject, _nargs: ffi::Py_ssize_t, _kwargs: *mut ffi::PyObject) -> PyResult<*mut ffi::PyObject>Defined in rust/miniproto/src/crypto.rs:471
sha1_digest_raw
Section titled “sha1_digest_raw”fn sha1_digest_raw(data: &[u8]) -> Vec<u8>Defined in rust/miniproto/src/crypto.rs:481-483
Computes SHA-1 for Rust callers without Python or GIL interaction.
Arguments
Section titled “Arguments”data: Bytes to hash.
sha256_digest_raw
Section titled “sha256_digest_raw”fn sha256_digest_raw(data: &[u8]) -> Vec<u8>Defined in rust/miniproto/src/crypto.rs:490-492
Computes SHA-256 for Rust callers without Python or GIL interaction.
Arguments
Section titled “Arguments”data: Bytes to hash.
mtproto_auth_key_id_raw
Section titled “mtproto_auth_key_id_raw”fn mtproto_auth_key_id_raw(auth_key: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:501-505
Derives the trailing eight SHA-1 bytes that identify a validated MTProto authorization key.
Returns ValueError if the key is not exactly 256 bytes; does not acquire the GIL.
Arguments
Section titled “Arguments”auth_key: Authorization key whose SHA-1 tail supplies the identifier.
mtproto_message_key_raw
Section titled “mtproto_message_key_raw”fn mtproto_message_key_raw(auth_key: &[u8], plaintext_with_padding: &[u8], client_to_server: bool) -> Vec<u8>Defined in rust/miniproto/src/crypto.rs:517-528
Derives an MTProto 2.0 message key from a validated authorization key and padded plaintext.
Callers must validate the authorization-key length before use because this internal primitive slices its fixed protocol ranges directly.
Arguments
Section titled “Arguments”auth_key: Previously validated 256-byte authorization key.plaintext_with_padding: Padded inner plaintext to include in the SHA-256 derivation.client_to_server: Selects the directional key offset.
mtproto_derive_aes_key_iv_raw
Section titled “mtproto_derive_aes_key_iv_raw”fn mtproto_derive_aes_key_iv_raw(auth_key: &[u8], msg_key: &[u8], client_to_server: bool) -> (Vec<u8>, Vec<u8>)Defined in rust/miniproto/src/crypto.rs:539-565
Derives the MTProto 2.0 AES-IGE key and IV from validated fixed-width key material.
Callers must validate auth_key and msg_key before calling; the function has no GIL use.
Arguments
Section titled “Arguments”auth_key: Previously validated 256-byte authorization key.msg_key: Previously validated 16-byte message key.client_to_server: Selects the directional key offset.
mtproto_encrypt_payload_raw
Section titled “mtproto_encrypt_payload_raw”fn mtproto_encrypt_payload_raw(auth_key: &[u8], plaintext_with_padding: &[u8], client_to_server: bool) -> PyResult<(Vec<u8>, Vec<u8>, Vec<u8>)>Defined in rust/miniproto/src/crypto.rs:576-588
Produces the auth-key identifier, message key and AES-IGE ciphertext for padded plaintext.
Returns ValueError for malformed keys or non-block-aligned plaintext; no GIL interaction.
Arguments
Section titled “Arguments”auth_key: 256-byte authorization key used for id, message key and AES derivation.plaintext_with_padding: AES-block-aligned inner plaintext to encrypt.client_to_server: Selects the directional MTProto key schedule.
mtproto_decrypt_payload_raw
Section titled “mtproto_decrypt_payload_raw”fn mtproto_decrypt_payload_raw(auth_key: &[u8], msg_key: &[u8], ciphertext: &[u8], client_to_server: bool) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:600-617
Decrypts and authenticates an MTProto payload using validated directional key derivation.
Returns ValueError for malformed inputs or a message-key mismatch; no GIL interaction.
Arguments
Section titled “Arguments”auth_key: 256-byte authorization key used for directional AES derivation.msg_key: 16-byte message key expected after decryption.ciphertext: AES-block-aligned encrypted payload.client_to_server: Selects the directional MTProto key schedule.
xor_bytes_raw
Section titled “xor_bytes_raw”fn xor_bytes_raw(left: &[u8], right: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:627-634
Computes bytewise XOR for equal-length Rust byte slices.
Returns ValueError for unequal lengths and does not use the GIL.
Arguments
Section titled “Arguments”left: First equal-length byte slice.right: Second equal-length byte slice.
aes_256_ige_encrypt_raw
Section titled “aes_256_ige_encrypt_raw”fn aes_256_ige_encrypt_raw(plaintext: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:645-671
Encrypts a block-aligned byte slice using AES-256 IGE for Rust callers.
Returns ValueError unless the key, IV and plaintext lengths meet AES-IGE requirements.
Arguments
Section titled “Arguments”plaintext: AES-block-aligned bytes to encrypt.key: The 32-byte AES-256 key.iv: The 32-byte AES-IGE initialization vector.
aes_256_ige_decrypt_raw
Section titled “aes_256_ige_decrypt_raw”fn aes_256_ige_decrypt_raw(ciphertext: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:682-708
Decrypts a block-aligned AES-256 IGE ciphertext for Rust callers.
Returns ValueError unless the key, IV and ciphertext lengths meet AES-IGE requirements.
Arguments
Section titled “Arguments”ciphertext: AES-block-aligned bytes to decrypt.key: The 32-byte AES-256 key.iv: The 32-byte AES-IGE initialization vector.
aes_256_cbc_encrypt_raw
Section titled “aes_256_cbc_encrypt_raw”fn aes_256_cbc_encrypt_raw(plaintext: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:719-738
Encrypts a block-aligned byte slice with unpadded AES-256 CBC.
Returns ValueError unless the key, IV and plaintext lengths are valid.
Arguments
Section titled “Arguments”plaintext: AES-block-aligned bytes to encrypt.key: The 32-byte AES-256 key.iv: The 16-byte CBC initialization vector.
aes_256_cbc_decrypt_raw
Section titled “aes_256_cbc_decrypt_raw”fn aes_256_cbc_decrypt_raw(ciphertext: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:749-769
Decrypts a block-aligned unpadded AES-256 CBC ciphertext.
Returns ValueError unless the key, IV and ciphertext lengths are valid.
Arguments
Section titled “Arguments”ciphertext: AES-block-aligned bytes to decrypt.key: The 32-byte AES-256 key.iv: The 16-byte CBC initialization vector.
aes_256_ctr_crypt_raw
Section titled “aes_256_ctr_crypt_raw”fn aes_256_ctr_crypt_raw(data: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:780-794
XORs bytes with an AES-256 CTR keystream; the same operation encrypts and decrypts.
Returns ValueError unless key is 32 bytes and iv is one AES block.
Arguments
Section titled “Arguments”data: Bytes to XOR with the generated CTR keystream.key: The 32-byte AES-256 key.iv: The 16-byte initial counter block.
aes_256_gcm_encrypt_raw
Section titled “aes_256_gcm_encrypt_raw”fn aes_256_gcm_encrypt_raw(plaintext: &[u8], key: &[u8], nonce: &[u8], associated_data: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:806-827
Authenticated-encrypts plaintext with AES-256 GCM and returns ciphertext plus tag.
Returns ValueError for an invalid key or nonce or if the cipher rejects the operation.
Arguments
Section titled “Arguments”plaintext: Bytes to encrypt.key: The 32-byte AES-256 key.nonce: The 12-byte GCM nonce.associated_data: Authenticated bytes that are not encrypted.
aes_256_gcm_decrypt_raw
Section titled “aes_256_gcm_decrypt_raw”fn aes_256_gcm_decrypt_raw(ciphertext_and_tag: &[u8], key: &[u8], nonce: &[u8], associated_data: &[u8]) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:839-860
Authenticated-decrypts AES-256 GCM ciphertext-and-tag data.
Returns ValueError for invalid key/nonce material or a failed authentication check.
Arguments
Section titled “Arguments”ciphertext_and_tag: GCM ciphertext followed by its authentication tag.key: The 32-byte AES-256 key.nonce: The 12-byte GCM nonce.associated_data: Authenticated bytes that are not encrypted.
scrypt_derive_raw
Section titled “scrypt_derive_raw”fn scrypt_derive_raw(password: &[u8], salt: &[u8], n: u32, r: u32, p: u32, length: usize) -> PyResult<Vec<u8>>Defined in rust/miniproto/src/crypto.rs:875-911
Runs scrypt with the library’s output and resource limits for Rust callers
Returns ValueError for invalid cost parameters, an unsupported output length or derivation
failure. This is a synchronous, GIL-free primitive.
Arguments
Section titled “Arguments”password: Password bytes accepted by scrypt.salt: Salt bytes accepted by scrypt.n: CPU/memory cost, required to be a power of two greater than one.r: scrypt block-size cost parameter.p: scrypt parallelization cost parameter.length: Requested derived-key length in the inclusive range 1..=1024.
pq_factorize_raw
Section titled “pq_factorize_raw”fn pq_factorize_raw(pq: u64) -> PyResult<(u64, u64)>Defined in rust/miniproto/src/crypto.rs:920-935
Finds and orders the two nontrivial factors of an MTProto pq value.
Returns ValueError for values below four, primes or an exhausted factorization budget
Arguments
Section titled “Arguments”pq: Candidate composite integer to split into its two ordered factors.
validate_auth_key
Section titled “validate_auth_key”fn validate_auth_key(auth_key: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:944-949
Validates the fixed 256-byte MTProto authorization-key width.
Returns ValueError rather than allowing fixed-offset protocol code to panic.
Arguments
Section titled “Arguments”auth_key: Candidate authorization key expected to contain 256 bytes.
validate_msg_key
Section titled “validate_msg_key”fn validate_msg_key(msg_key: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:958-963
Validates the fixed 16-byte MTProto message-key width.
Returns ValueError on a malformed input slice.
Arguments
Section titled “Arguments”msg_key: Candidate message key expected to contain 16 bytes.
validate_block_multiple
Section titled “validate_block_multiple”fn validate_block_multiple(data: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:972-979
Validates that AES block-mode input has a whole-number count of AES blocks.
Returns ValueError when the byte length is not divisible by 16.
Arguments
Section titled “Arguments”data: Candidate AES block-mode input.
validate_aes_key
Section titled “validate_aes_key”fn validate_aes_key(key: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:986-991
Validates a 32-byte AES-256 key and returns ValueError otherwise.
Arguments
Section titled “Arguments”key: Candidate AES-256 key.
validate_ige_iv
Section titled “validate_ige_iv”fn validate_ige_iv(iv: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:998-1003
Validates the two-block, 32-byte IV required by AES-IGE.
Arguments
Section titled “Arguments”iv: Candidate AES-IGE initialization vector.
validate_cbc_ctr_iv
Section titled “validate_cbc_ctr_iv”fn validate_cbc_ctr_iv(iv: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:1010-1015
Validates the one-block IV or counter used by CBC and CTR modes.
Arguments
Section titled “Arguments”iv: Candidate CBC initialization vector or CTR counter block.
validate_gcm_nonce
Section titled “validate_gcm_nonce”fn validate_gcm_nonce(nonce: &[u8]) -> PyResult<()>Defined in rust/miniproto/src/crypto.rs:1022-1027
Validates the 12-byte nonce mandated by this AES-GCM interface.
Arguments
Section titled “Arguments”nonce: Candidate AES-GCM nonce.
direction_offset
Section titled “direction_offset”fn direction_offset(client_to_server: bool) -> usizeDefined in rust/miniproto/src/crypto.rs:1034-1036
Returns the MTProto key-schedule offset for the requested packet direction.
Arguments
Section titled “Arguments”client_to_server: Whether the packet travels from client to server.
xor_block
Section titled “xor_block”fn xor_block(left: &[u8; 16], right: &[u8; 16]) -> [u8; 16]Defined in rust/miniproto/src/crypto.rs:1044-1050
Computes a fixed-width XOR block used by the AES block-mode loops.
Arguments
Section titled “Arguments”left: First AES-sized block.right: Second AES-sized block.
increment_counter
Section titled “increment_counter”fn increment_counter(counter: &mut [u8; 16])Defined in rust/miniproto/src/crypto.rs:1057-1065
Advances a big-endian AES-CTR counter in place, wrapping at the full block width.
Arguments
Section titled “Arguments”counter: Mutable AES-sized counter block to increment.
fn gcd(left: u64, right: u64) -> u64Defined in rust/miniproto/src/crypto.rs:1073-1080
Computes the greatest common divisor used by Pollard-rho factorization.
Arguments
Section titled “Arguments”left: First nonnegative integer.right: Second nonnegative integer.
mul_mod
Section titled “mul_mod”fn mul_mod(left: u64, right: u64, modulus: u64) -> u64Defined in rust/miniproto/src/crypto.rs:1093-1095
Multiplies modulo modulus with a widened intermediate to avoid u64 overflow.
Panics
Section titled “Panics”A zero modulus panics at the remainder operation. Widening the product to u128 prevents multiplication overflow for u64 inputs.
Arguments
Section titled “Arguments”left: First modular multiplicand.right: Second modular multiplicand.modulus: Nonzero modulus used for the reduced product.
pow_mod
Section titled “pow_mod”fn pow_mod(base: u64, exponent: u64, modulus: u64) -> u64Defined in rust/miniproto/src/crypto.rs:1108-1118
Computes modular exponentiation for deterministic Miller-Rabin witnesses.
Panics
Section titled “Panics”A zero modulus panics when exponent is nonzero. Products use mul_mod and its widened intermediate to avoid multiplication overflow.
Arguments
Section titled “Arguments”base: Base to exponentiate modulomodulus.exponent: Nonnegative exponent encoded asu64.modulus: Nonzero modulus used for every reduction.
is_prime_u64
Section titled “is_prime_u64”fn is_prime_u64(value: u64) -> boolDefined in rust/miniproto/src/crypto.rs:1125-1164
Deterministically tests whether a u64 is prime using fixed Miller-Rabin witnesses.
Arguments
Section titled “Arguments”value: Unsigned integer to classify as prime or composite.
factor_u64
Section titled “factor_u64”fn factor_u64(value: u64, attempts: usize, iterations: usize) -> Option<u64>Defined in rust/miniproto/src/crypto.rs:1173-1200
Returns one factor using bounded Pollard-rho iteration, the input when prime or None when exhausted
Arguments
Section titled “Arguments”value: Composite unsigned integer whose nontrivial factor is requested.attempts: Maximum number of polynomial constants to tryiterations: Maximum sequence iterations for each constant
Constants
Section titled “Constants”AES_BLOCK_SIZE
Section titled “AES_BLOCK_SIZE”const AES_BLOCK_SIZE: usize = 16usize;Defined in rust/miniproto/src/crypto.rs:21
AES’s fixed block size in bytes.
MT_PROTO_AUTH_KEY_SIZE
Section titled “MT_PROTO_AUTH_KEY_SIZE”const MT_PROTO_AUTH_KEY_SIZE: usize = 256usize;Defined in rust/miniproto/src/crypto.rs:23
Required byte length of an MTProto authorization key.
MT_PROTO_MSG_KEY_SIZE
Section titled “MT_PROTO_MSG_KEY_SIZE”const MT_PROTO_MSG_KEY_SIZE: usize = 16usize;Defined in rust/miniproto/src/crypto.rs:25
Required byte length of an MTProto 2.0 message key.
GIL_RELEASE_THRESHOLD_BYTES
Section titled “GIL_RELEASE_THRESHOLD_BYTES”const GIL_RELEASE_THRESHOLD_BYTES: usize = 4_096usize;Defined in rust/miniproto/src/crypto.rs:27
Work-size threshold above which native wrappers detach from the Python GIL.
SCRYPT_MAX_MEMORY_BYTES
Section titled “SCRYPT_MAX_MEMORY_BYTES”const SCRYPT_MAX_MEMORY_BYTES: usize = 268_435_456usize;Defined in rust/miniproto/src/crypto.rs:29
Maximum memory estimate accepted by the public scrypt primitive.
SCRYPT_MAX_WORK_BYTES
Section titled “SCRYPT_MAX_WORK_BYTES”const SCRYPT_MAX_WORK_BYTES: usize = 1_073_741_824usize;Defined in rust/miniproto/src/crypto.rs:31
Maximum CPU-work estimate accepted by the public scrypt primitive.
PQ_FACTOR_ATTEMPTS
Section titled “PQ_FACTOR_ATTEMPTS”const PQ_FACTOR_ATTEMPTS: usize = 16usize;Defined in rust/miniproto/src/crypto.rs:33
Maximum Pollard-rho retries, matching the Python fallback
PQ_FACTOR_ITERATIONS
Section titled “PQ_FACTOR_ITERATIONS”const PQ_FACTOR_ITERATIONS: usize = 100_000usize;Defined in rust/miniproto/src/crypto.rs:35
Maximum Pollard-rho iterations per retry, matching the Python fallback