Skip to content

miniproto.crypto.native.scrypt_derive

scrypt_derive(password: bytes, salt: bytes, n: int, r: int, p: int, length: int) -> bytes

Derive key material with Scrypt through the available session backend.

Parameters:

  • password (bytes) – Secret input bytes.
  • salt (bytes) – Caller-selected salt bytes.
  • n (int) – CPU/memory cost, which must be a power of two greater than one.
  • r (int) – Block-size cost parameter.
  • p (int) – Parallelization cost parameter.
  • length (int) – Requested output length.

Returns:

  • bytes – The derived key bytes.

Raises:

  • ValueError – If Scrypt parameters or output length are rejected.

Uses native Scrypt only when the optional symbol exists, otherwise cryptography. Parameter selection and resource limits are caller-owned; the backends may report validation failures differently at their edges.