/** * Overwrite `buf` in-place with zero bytes. * * JavaScript cannot guarantee the garbage collector has not already relocated * or copied the underlying memory, so this is a best-effort operation. Its * purpose is to minimise the time window during which sensitive bytes * (secret keys, plaintext, derived material) remain readable on the heap * after they are no longer needed. Combine with aggressive buffer * scoping — allocate inside a function, zeroize, return nothing sensitive. */ export function zeroize(buf: Uint8Array): void { buf.fill(0); }