const privateKey = normalize('private key', KEY_BYTELENGTH, KEY_BYTELENGTH, prv)
const publicKey = new Uint8Array(KEY_BYTELENGTH)
let buffer = new Uint8Array(exports.memory.buffer)
+ Mutex.lock()
try {
- Mutex.lock()
for (let i = 0; i < KEY_BYTELENGTH; i++) {
buffer[Pointers.INPUT_PRV + i] = privateKey[i]
}
const publicKey = normalize('public key', KEY_BYTELENGTH, KEY_BYTELENGTH, pub)
const signature = new Uint8Array(SIGNATURE_BYTELENGTH)
let buffer = new Uint8Array(exports.memory.buffer)
+ Mutex.lock()
try {
- Mutex.lock()
for (let i = 0; i < message.byteLength; i++) {
buffer[Pointers.INPUT_MSG + i] = message[i]
}
export function verify (sig: unknown, msg: unknown, pub: unknown): boolean {
let buffer = new Uint8Array(exports.memory.buffer)
+ Mutex.lock()
try {
- Mutex.lock()
const message = normalize('message', 0, MAX_MESSAGE_BYTELENGTH, msg)
const publicKey = normalize('public key', KEY_BYTELENGTH, KEY_BYTELENGTH, pub)
const signature = normalize('signature', SIGNATURE_BYTELENGTH, SIGNATURE_BYTELENGTH, sig)
buffer[Pointers.INPUT_SIG + i] = signature[i]
}
exports.verify(message.byteLength)
- buffer = new Uint8Array(exports.memory.buffer)
+ if (exports.memory.buffer !== buffer.buffer) {
+ throw new Nano25519TypeError('WASM memory buffer detached')
+ }
const verified = buffer[Pointers.OUTPUT_VERIFY]
return verified === 0
} finally {
}
const verified = new Uint8Array(count)
let buffer = new Uint8Array(exports.memory.buffer)
+ Mutex.lock()
try {
- Mutex.lock()
const publicKey = normalize('public key', KEY_BYTELENGTH, KEY_BYTELENGTH, pub)
for (let i = 0; i < KEY_BYTELENGTH; i++) {
buffer[Pointers.INPUT_PUB + i] = publicKey[i]