Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Kdf

Derive key bytes from IKM or a passphrase. Leaves ByteList — wrap with Key.<algo> … Key.fromBytes^ for Cipher.

ConstantRole
Kdf.hkdfSha256After X25519 agree → AEAD key
Kdf.argon2idPassphrase → key
// ( algo:s params:DO -- bytes:ByteList )
Kdf.hkdfSha256 params Kdf.derive^

HKDF-SHA-256 params

FieldRequiredNotes
ikmyesByteList | String
lengthyesInt (output bytes)
infonodefault empty
saltnooptional
{ shared "ikm" "final-aead" "info" 32 "length" }
Kdf.hkdfSha256 swap Kdf.derive^
Key.aes256gcm swap Key.fromBytes^

Argon2id params

FieldRequiredDefault if omitted
passwordyes—
saltyes (≥ 8 bytes)—
lengthyes—
timeno3
memoryKiBno65536 (64 MiB)
parallelismno4
16 SecureRandom.bytes^ >xs
{
  "demo-passphrase" "password"
  x:peek "salt"
  32 "length"
}
Kdf.argon2id swap Kdf.derive^

Demos may lower time / memoryKiB / parallelism for speed; production should omit them (safe defaults) or set higher costs.

Example: examples/crypto/1c-derive-key.fnl (X25519 → HKDF → AES-GCM, plus Argon2id).