]> git.codecow.com Git - nano25519.git/commitdiff
Use primordial byteLength instead of prototype method.
authorChris Duncan <chris@codecow.com>
Sat, 26 Sep 2026 16:14:04 +0000 (09:14 -0700)
committerChris Duncan <chris@codecow.com>
Sat, 26 Sep 2026 16:14:04 +0000 (09:14 -0700)
src/lib/sign.ts
src/lib/verify.ts

index 85d071017945630cda261ff0e66d171cf207e09d..3f103080f0173beec8c825d9c26493d053914c11 100644 (file)
@@ -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)
                }
index 983cbb4aac399b46368c4f9e6367cee85fe92097..b31f61e350af61495d2d668c5ba5953b444158df 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2026 Chris Duncan <chris@codecow.com>
 //! 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 {