From: Chris Duncan Date: Sun, 17 Aug 2025 22:23:03 +0000 (-0700) Subject: Offload type checking to called function.. X-Git-Tag: v0.10.5~41^2~84 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=f628f1d3a34c5d9ee8db0ed102db99ba2b500698;p=libnemo.git Offload type checking to called function.. --- 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 })