From: Chris Duncan Date: Sun, 18 Oct 2026 10:43:53 +0000 (-0700) Subject: v2.0.0 X-Git-Tag: v2.0.0^0 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=4a4ed6339a00df7b1bfd6b0f3784fb3218172172;p=nano25519.git v2.0.0 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 5741418..083baba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,33 @@ SPDX-License-Identifier: GPL-3.0-or-later # Changelog +## v2.0.0 + +- Add `verify_blocks()` which uses ed25519-donna policy to align with nano-node. + It can verify up to 64 signatures for a given public key which speeds up + verification by ~9%. `verify()` still uses a stricter cofactored policy which + offers SUF-CMA and SBS for tamper-proof unambiguous signatures. +- Remove async API; all primitives are synchronous functions only. +- Improve memory sanitization by exporting setters instead of the raw WASM + buffer, zeroing bytes as soon as they are no longer needed, and decoding with + character code arithmetic instead of variable-time intrinsic functions. +- Update `derive()` to always return a hex string by default. Passing an + optional preallocated output buffer will write bytes to it directly and return + `undefined` instead of a string: `derive(prv[, out]);` +- Update `sign()` to take private and public keys as separate parameters instead + of a concatenated 64-byte secret key: `sign(msg, prv, pub)` +- Update `sign()` to always return a hex string by default. Passing an + optional preallocated output buffer will write bytes to it directly and return + `undefined` instead of a string: `sign(msg, prv, pub[, out]);` +- Update `sign()` to always rederive the public key and throw if it does not + match the relevant user input. +- Update `verify()` to reject non-canonical R. +- Fix `verify()` to properly expand integer types prior to shifting. +- Reject `ArrayBuffer` arguments and only accept bytes as `Uint8Array`. +- Increase maximum message size for signing and verification to 64 KiB. +- Export important constants for ease of integration. +- Improve error logging and greatly expanded unit testing. + ## v1.0.8 - Remove extraneous error logging and fix relevant tests. diff --git a/README.md b/README.md index fa2ed2d..9637624 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,12 @@ CDN URL works, and modern browsers make it even simpler with import maps: "nano25519": "https://unpkg.com/nano25519@2.0.0/dist/browser.js" }, "integrity": { - "https://unpkg.com/nano25519@2.0.0/dist/browser.js": "sha512-123Abc..." + "https://unpkg.com/nano25519@2.0.0/dist/browser.js": "sha512-bJnXSxESvcTNkzXTtqJThciGM7+TbjpSWzGN5bsVQk6CylYm1PO6lCNb/Nh7xvO2VwP4BNqRaHCOVF/m+oKOSA==" } } ``` @@ -77,10 +77,11 @@ To be able to clear a private key after use, pass it as bytes viewed over an `ArrayBuffer`, and clear it with `fill(0)`, as the examples below do: ```javascript -// `usersPrivateKeyBuffer` is an ArrayBuffer holding the 32-byte private key, so -// `prv` is a view of it, not a copy +// `usersPrivateKeyBuffer` is an ArrayBuffer holding the 32-byte private key +// `prv` is a Uint8Array view over the private key buffer const prv = new Uint8Array(usersPrivateKeyBuffer); +// `pub` is public key for a Nano account as a 64-character hexadecimal string const pub = nano25519.derive(prv); // clean up prv.fill(0); @@ -126,7 +127,7 @@ const prv = new Uint8Array(usersPrivateKeyBuffer); // `pub` is an empty 32-byte Uint8Array const pub = new Uint8Array(32); -// return discarded, 32-byte public key is written to `pub` +// 32-byte public key is written to `pub`, return value is `undefined` nano25519.derive(prv, pub); // clean up prv.fill(0); @@ -174,7 +175,7 @@ const pub = new Uint8Array(publicKeyBuffer); // `sig` is an empty 64-byte Uint8Array const sig = new Uint8Array(64); -// return value is discarded, 64-byte signature is written to `sig` +// 64-byte signature is written to `sig`, return value is `undefined` nano25519.sign(msg, prv, pub, sig); // clean up prv.fill(0); @@ -350,12 +351,12 @@ See AUTHORS.md GNU GPL version 3 or later -libsodium is distributed under the ISC license and was referenced from the -following commit hash: +libsodium is distributed under the ISC license and was originally referenced +from the following commit hash: -tweetnacl-js is public domain under the Unlicense and was referenced from the -following commit hash: +tweetnacl-js is public domain under the Unlicense and was originally referenced +from the following commit hash: ## Donations diff --git a/package-lock.json b/package-lock.json index 8859b0f..71fe1e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "nano25519", - "version": "1.0.8", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nano25519", - "version": "1.0.8", - "license": "(GPL-3.0-or-later AND MIT)", + "version": "2.0.0", + "license": "(GPL-3.0-or-later AND ISC)", "devDependencies": { "@types/node": "26.2.0", "assemblyscript": "0.28.20", diff --git a/package.json b/package.json index 4b212cf..fb9de86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nano25519", - "version": "1.0.8", + "version": "2.0.0", "description": "Public key derivation, transaction signing, and signature verification for Nano cryptocurrency using AssemblyScript.", "keywords": [ "nemo", diff --git a/test/index.html b/test/index.html index aa5e4ea..569dca9 100644 --- a/test/index.html +++ b/test/index.html @@ -18,7 +18,7 @@ SPDX-License-Identifier: GPL-3.0-or-later "libsodium-wrappers": "https://unpkg.com/libsodium-wrappers@0.8.4/dist/modules-esm/libsodium-wrappers.mjs", "nano25519": "https://unpkg.com/nano25519@2.0.0/dist/browser.js", "tweetnacl": "https://unpkg.com/tweetnacl@1.0.3/nacl-fast.js", - "#vectors": "https://git.codecow.com/?p=nano25519.git;a=blob_plain;f=test/vectors.mjs;hb=refs/heads/main" + "#vectors": "https://git.codecow.com/?p=nano25519.git;a=blob_plain;f=test/vectors.mjs;hb=refs/tags/v2.0.0" }, "scopes": { "/test/": { @@ -28,10 +28,17 @@ SPDX-License-Identifier: GPL-3.0-or-later }, "integrity": { "https://unpkg.com/@noble/hashes@2.4.0/sha2.js": "sha256-RxdGu6bsTGI4ykE1jR07QLb/Mc8zY/C01VDGScGo6Ds=", + "https://unpkg.com/@noble/hashes@2.4.0/_md.js": "sha256-YM8wEP2onj5NPw5/8c4knpxGfzS0/UG2/WEB2fab52M=", + "https://unpkg.com/@noble/hashes@2.4.0/_u64.js": "sha256-sJ2owH/oGHwHZJSUzbfNC88T35C1BqlHPRnk1fjC4QI=", + "https://unpkg.com/@noble/hashes@2.4.0/utils.js": "sha256-A3rUmtt4FotraZWY/TP4X3h3RWsdKLTQMuKhoWgHlHw=", "https://unpkg.com/@noble/ed25519@3.2.0/index.js": "sha256-pPYx0YdrXZ5DqGzXEZTKJ7XhRR7fS6TbmkGPQKR1Vpo=", "https://unpkg.com/libsodium@0.8.4/dist/modules-esm/libsodium.mjs": "sha512-8NozLMgdpZ2aM7BpDlekMIWsfF9pVq8fy1Gela2kBuP6DZmOd51NBxBZSbncxiDknW1EJYmu7Th3WYWhjgUygw==", "https://unpkg.com/libsodium-wrappers@0.8.4/dist/modules-esm/libsodium-wrappers.mjs": "sha512-8lc4H4LWq+iFFPBBVIxpwTbOVJxeF0V4GgEDQIrlTOUzBEl7FT6zKQPoFi7prCeUVHnunjOyHrXgAFX7mWPupw==", - "https://unpkg.com/tweetnacl@1.0.3/nacl-fast.js": "sha512-vtXgmExiD+YrImVtOeCfoGiVKgouA3SgPHZbLQKcC972FeFo5i881KTOMxtK7dsZa2z5vjpyCpDSd1lGvJY3bg==" + "https://unpkg.com/nano25519@2.0.0/dist/browser.js": "sha512-bJnXSxESvcTNkzXTtqJThciGM7+TbjpSWzGN5bsVQk6CylYm1PO6lCNb/Nh7xvO2VwP4BNqRaHCOVF/m+oKOSA==", + "https://unpkg.com/tweetnacl@1.0.3/nacl-fast.js": "sha512-vtXgmExiD+YrImVtOeCfoGiVKgouA3SgPHZbLQKcC972FeFo5i881KTOMxtK7dsZa2z5vjpyCpDSd1lGvJY3bg==", + "https://git.codecow.com/?p=nano25519.git;a=blob_plain;f=test/vectors.mjs;hb=refs/tags/v2.0.0": "sha512-8da7GVIhpvrVoF7TE9RWpNoPIh2SC0Co+QoBCn0scO3FeQbV1e4yfuijFahSMTHaUx2/wlNm0b5yNRyiqsMehQ==", + "./vectors/mjs": "sha512-8da7GVIhpvrVoF7TE9RWpNoPIh2SC0Co+QoBCn0scO3FeQbV1e4yfuijFahSMTHaUx2/wlNm0b5yNRyiqsMehQ==", + "../dist/browser.js": "sha512-bJnXSxESvcTNkzXTtqJThciGM7+TbjpSWzGN5bsVQk6CylYm1PO6lCNb/Nh7xvO2VwP4BNqRaHCOVF/m+oKOSA==" } }