From: Chris Duncan Date: Sat, 26 Sep 2026 16:14:04 +0000 (-0700) Subject: Use primordial byteLength instead of prototype method. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=124afa1d9d274ef254db7cbd9786383e3cf766ab;p=nano25519.git Use primordial byteLength instead of prototype method. --- diff --git a/src/lib/sign.ts b/src/lib/sign.ts index 85d0710..3f10308 100644 --- a/src/lib/sign.ts +++ b/src/lib/sign.ts @@ -19,7 +19,7 @@ export function sign (msg: unknown, prv: unknown, pub: unknown, out?: unknown): setInput('msg', message) setInput('prv', privateKey) setInput('pub', publicKey) - wasm_sign(message.byteLength) + wasm_sign(byteLength(message)) for (let i = 0; i < SIGNATURE_BYTELENGTH; i++) { signature[i] = getOutput('sign', i) } diff --git a/src/lib/verify.ts b/src/lib/verify.ts index 983cbb4..b31f61e 100644 --- a/src/lib/verify.ts +++ b/src/lib/verify.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2026 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { isArray, normalize } from './primordials' +import { byteLength, isArray, normalize } from './primordials' import { Mutex, clearMemory, constants, getOutput, setInput, verify as wasm_verify, verify_blocks as wasm_verify_blocks, } from './wasm' const { BLOCKHASH_BYTELENGTH, KEY_BYTELENGTH, MAX_MESSAGE_BYTELENGTH, MAX_VERIFY_BLOCKS, SIGNATURE_BYTELENGTH, } = constants @@ -15,7 +15,7 @@ export function verify (sig: unknown, msg: unknown, pub: unknown): boolean { setInput('msg', message) setInput('pub', publicKey) setInput('sig', signature) - wasm_verify(message.byteLength) + wasm_verify(byteLength(message)) const verified = getOutput('verify', 0) return verified === 1 } finally {