From 5bdc5de35c7cde5de65b1ff825b995fcc671a4d2 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 6 Sep 2026 01:25:50 -0700 Subject: [PATCH] Fix output buffers in speed test page. --- test/index.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/index.html b/test/index.html index 0981e68..2f6743d 100644 --- a/test/index.html +++ b/test/index.html @@ -129,6 +129,9 @@ SPDX-License-Identifier: GPL-3.0-or-later return [...bytes].map(b => b.toString(16).padStart(2, '0')).join('') } + const outPub = new Uint8Array(32) + const outSig = new Uint8Array(64) + /** * @param {Uint8Array} prv * @param {string} api @@ -137,7 +140,8 @@ SPDX-License-Identifier: GPL-3.0-or-later const derive = (prv, api) => { switch (api) { case 'nano25519': { - return nano25519.derive(prv) + nano25519.derive(prv, outPub) + return outPub } case 'NanocurrencyWeb': { const { publicKey } = NanocurrencyWeb.wallet.legacyAccounts(b2a(prv))[0] @@ -165,9 +169,9 @@ SPDX-License-Identifier: GPL-3.0-or-later const sign = (msg, prv, pub, api) => { const sk = new Uint8Array([...prv, ...pub]) switch (api) { - case 'nano25519': - case 'nano25519 with bulk block verification': { - return nano25519.sign(msg, prv, pub) + case 'nano25519': { + nano25519.sign(msg, prv, pub, outSig) + return outSig } case 'NanocurrencyWeb': { const { privateKey } = NanocurrencyWeb.wallet.legacyAccounts(b2a(prv))[0] @@ -266,13 +270,13 @@ SPDX-License-Identifier: GPL-3.0-or-later failures += +!test result = nano25519.derive(NANO_ORG_VECTOR.privateKeyBytes) - test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() + test = result.toLowerCase() === NANO_ORG_VECTOR.publicKey.toLowerCase() check(`derive from bytes ${NANO_ORG_VECTOR.privateKey}`, test) passes += +test failures += +!test result = nano25519.sign(NANO_ORG_VECTOR.blockHashBytes, NANO_ORG_VECTOR.privateKeyBytes, NANO_ORG_VECTOR.publicKeyBytes) - test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() + test = result.toLowerCase() === NANO_ORG_VECTOR.signature.toLowerCase() check(`sign message bytes ${NANO_ORG_VECTOR.blockHash}`, test) passes += +test failures += +!test @@ -309,13 +313,13 @@ SPDX-License-Identifier: GPL-3.0-or-later const signatureBytes = new Uint8Array(signature.match(/.{2}/g)?.slice(0, 64).map(b => parseInt(b, 16)) ?? []) result = nano25519.derive(privateKeyBytes) - test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === publicKey + test = result.toLowerCase() === publicKey check(`derive from ${privateKey}`, test) passes += +test failures += +!test result = nano25519.sign(messageBytes, privateKeyBytes, publicKeyBytes) - test = [...result].map(b => b.toString(16).padStart(2, '0')).join('').toLowerCase() === signature.slice(0, 128) + test = result.toLowerCase() === signature.slice(0, 128) check(`sign message ${message}`, test) passes += +test failures += +!test -- 2.52.0