const OUTPUT_SIGN = new StaticArray<u8>(SIGNATURE_BYTELENGTH)
const OUTPUT_VERIFY = new StaticArray<u8>(MAX_VERIFY_BLOCKS)
+/** Clears all input and output buffers. */
+export function clearMemory (): void {
+ INPUT_MSG.fill(0)
+ INPUT_PRV.fill(0)
+ INPUT_PUB.fill(0)
+ INPUT_SIG.fill(0)
+ OUTPUT_DERIVE.fill(0)
+ OUTPUT_SIGN.fill(0)
+ OUTPUT_VERIFY.fill(0)
+}
+
/** Sets a byte in the static message input buffer. */
export function setInputMsgByte (index: i32, v0: i32): i32 {
if (index < 0 || MAX_MESSAGE_BYTELENGTH <= index) {
import { Nano25519TypeError, copy } from './primordials'
type Exports = WebAssembly.Instance['exports'] & {
+ clearMemory: () => void
derive: () => void
sign: (mlen: number) => number
verify: (mlen: number) => number
}
export function clearMemory (): void {
- for (let i = 0; i < MAX_MESSAGE_BYTELENGTH; i++) {
- MemoryBuffers.INPUT_MSG(i)(0)
- }
- for (let i = 0; i < KEY_BYTELENGTH; i++) {
- MemoryBuffers.INPUT_PRV(i)(0)
- }
- for (let i = 0; i < KEY_BYTELENGTH; i++) {
- MemoryBuffers.INPUT_PUB(i)(0)
- }
- for (let i = 0; i < SIGNATURE_BYTELENGTH; i++) {
- MemoryBuffers.INPUT_SIG(i)(0)
- }
+ exports.clearMemory()
locked = false
}