Consthash function that would be used (e.g. sha256)
input keying material, the initial key
optional salt value (a non-secret random value)
optional context and application specific information bytes
length of output keying material in bytes.
RFC 5869 §2.3 allows 0..255*HashLen, so 0 returns an empty OKM.
Output keying material derived from the input key.
HKDF (RFC 5869): derive keys from an initial input.
import { hkdf } from '@noble/hashes/hkdf.js';
import { sha256 } from '@noble/hashes/sha2.js';
import { randomBytes, utf8ToBytes } from '@noble/hashes/utils.js';
const inputKey = randomBytes(32);
const salt = randomBytes(32);
const info = utf8ToBytes('application-key');
const okm = hkdf(sha256, inputKey, salt, info, 32);
HKDF (RFC 5869): derive keys from an initial input. Combines hkdf_extract + hkdf_expand in one step