From f628f1d3a34c5d9ee8db0ed102db99ba2b500698 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 17 Aug 2025 15:23:03 -0700 Subject: [PATCH] Offload type checking to called function.. --- src/lib/crypto/nano-nacl.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/lib/crypto/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts index a942801..5b8c2b0 100644 --- a/src/lib/crypto/nano-nacl.ts +++ b/src/lib/crypto/nano-nacl.ts @@ -487,20 +487,7 @@ export class NanoNaCl { static detached (message: Uint8Array, privateKey: Uint8Array): Uint8Array static detached (message: unknown, privateKey: unknown): Uint8Array { try { - if (!(message instanceof Uint8Array)) { - throw new TypeError('Message must be Uint8Array') - } - if (!(privateKey instanceof Uint8Array)) { - throw new TypeError('Private key must be Uint8Array') - } - const m = new Uint8Array(message) - const mLen = m.length - const prv = new Uint8Array(privateKey) - message = undefined - privateKey = undefined - const sm = new Uint8Array(this.crypto_sign_BYTES + mLen) - const pub = this.convert(prv) - this.crypto_sign(sm, m, mLen, prv, pub) + const sm = this.sign(message as Uint8Array, privateKey as Uint8Array) return new Uint8Array(sm.buffer.slice(0, this.crypto_sign_BYTES)) } catch (err) { throw new Error('Failed to sign and return signature', { cause: err }) -- 2.47.3