Securely overwrite a Uint8Array containing secret material.
Two-pass wipe: random bytes first (defeats simple memory-dump
recovery of the original pattern), then zeros (defeats the dump
of the random pass).
⚠️ Honest limitation: JavaScript GC may retain copies of the
buffer (JIT optimization, closure capture). This function
mitigates casual memory inspection; it is NOT a guarantee
against a determined attacker with core-dump access. For
strong guarantees use non-extractable CryptoKey (WebCrypto)
or hardware-backed keys.
Parameters
array: Uint8Array
The Uint8Array to overwrite. Modified in place.
Returns void
Example
constseed = deriveFromMnemonic(words); // ... use the seed secureWipe(seed); // immediately before it goes out of scope
Securely overwrite a Uint8Array containing secret material.
Two-pass wipe: random bytes first (defeats simple memory-dump recovery of the original pattern), then zeros (defeats the dump of the random pass).
⚠️ Honest limitation: JavaScript GC may retain copies of the buffer (JIT optimization, closure capture). This function mitigates casual memory inspection; it is NOT a guarantee against a determined attacker with core-dump access. For strong guarantees use non-extractable CryptoKey (WebCrypto) or hardware-backed keys.