]> git.codecow.com Git - nano25519.git/commitdiff
Add option to check bulk verification on speed test page.
authorChris Duncan <chris@codecow.com>
Thu, 27 Aug 2026 04:24:39 +0000 (21:24 -0700)
committerChris Duncan <chris@codecow.com>
Thu, 27 Aug 2026 04:24:39 +0000 (21:24 -0700)
test/index.html

index 6e91b1d60341ee9e92bcf03aa92f5224cab6dbdd..8f3cdbd477488f6c0f3b1c37b00758fbe7ce090a 100644 (file)
@@ -121,7 +121,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
                const derive = (prv, api) => {
                        const prv8 = new Uint8Array(prv.match(/.{2}/g).map(b => parseInt(b, 16)))
                        switch (api) {
-                               case 'nano25519': {
+                               case 'nano25519':
+                               case 'nano25519 with bulk block verification': {
                                        const pub8 = nano25519.derive(prv8)
                                        return [...pub8].map(b => b.toString(16).padStart(2, '0')).join('')
                                }
@@ -147,7 +148,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        const pub8 = new Uint8Array(pub.match(/.{2}/g).map(b => parseInt(b, 16)))
                        const sk8 = new Uint8Array((prv + pub).match(/.{2}/g).map(b => parseInt(b, 16)))
                        switch (api) {
-                               case 'nano25519': {
+                               case 'nano25519':
+                               case 'nano25519 with bulk block verification': {
                                        const sig8 = nano25519.sign(msg8, prv8, pub8)
                                        return [...sig8].map(b => b.toString(16).padStart(2, '0')).join('')
                                }
@@ -176,6 +178,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
                                case 'nano25519': {
                                        return nano25519.verify(sig8, msg8, pub8)
                                }
+                               case 'nano25519 with bulk block verification': {
+                                       const blocks = []
+                                       for (let i = 0; i < 256; i++) blocks[i] = { hash: msg8, signature: sig8 }
+                                       const verified = nano25519.verify_blocks(pub8, blocks)
+                                       return verified.every(v => v === true)
+                               }
                                case 'NanocurrencyWeb': {
                                        return NanocurrencyWeb.tools.verify(pub, sig, msg)
                                }
@@ -394,6 +402,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                                                }
                                                end = performance.now()
                                                duration = end - start
+                                               duration /= (api === 'nano25519 with bulk block verification') ? 256 : 1
                                                verifyTimes[i].push(duration)
                                        } catch (err) {
                                                document.getElementById('output').innerHTML += `Error: ${err.message}<br/>`
@@ -506,6 +515,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                <label for="api">API</label>
                <select id="api">
                        <option>nano25519</option>
+                       <option>nano25519 with bulk block verification</option>
                        <option>NanocurrencyWeb</option>
                        <option>Sodium</option>
                        <option>TweetNaCl.js</option>