# 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.
"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=="
}
}
</script>
<script type="module">
- import { derive, sign, verify } from "nano25519";
+ import { derive, sign, verify, verify_blocks } from "nano25519";
</script>
```
`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);
// `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);
// `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);
GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
-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:
<https://github.com/jedisct1/libsodium/tree/d24faf56214469b354b01c8ba36257e04737101e>
-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:
<https://github.com/dchest/tweetnacl-js/tree/e6141a20553498697e9e7d92fbc4517994caff52>
## Donations
{
"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",
{
"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",
"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/": {
},
"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=="
}
}
</script>