]> git.codecow.com Git - nano25519.git/commitdiff
Update README.
authorChris Duncan <chris@zoso.dev>
Sun, 6 Sep 2026 09:31:16 +0000 (02:31 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 6 Sep 2026 09:31:16 +0000 (02:31 -0700)
README.md

index 77e695e8689946ccdee22e73befb8d5e48bb7907..87b86a210ac5ba0e1f479518736e07e82f32b203 100644 (file)
--- a/README.md
+++ b/README.md
@@ -35,12 +35,12 @@ CDN URL works, and modern browsers make it even simpler with import maps:
 ```html
 <script type="importmap">
   {
-   "imports": {
-    "nano25519": "https://unpkg.com/nano25519@1.0.8/dist/browser.js"
-   },
-   "integrity": {
-    "https://unpkg.com/nano25519@1.0.8/dist/browser.js": "sha512-8NozLMgdpZ2aM7BpDlekMIWsfF9pVq8fy1Gela2kBuP6DZmOd51NBxBZSbncxiDknW1EJYmu7Th3WYWhjgUygw=="
-   }
+    "imports": {
+      "nano25519": "https://unpkg.com/nano25519@1.0.8/dist/browser.js"
+    },
+    "integrity": {
+      "https://unpkg.com/nano25519@1.0.8/dist/browser.js": "sha512-8NozLMgdpZ2aM7BpDlekMIWsfF9pVq8fy1Gela2kBuP6DZmOd51NBxBZSbncxiDknW1EJYmu7Th3WYWhjgUygw=="
+    }
   }
 </script>
 <script type="module">
@@ -64,23 +64,34 @@ import * as nano25519 from "nano25519";
 
 ## Usage
 
-Each primitive implementation is synchronous. Inputs can be passed as Uint8Array byte arrays (preferable) or strings. The
-output will return the same type as the input. A preallocated output buffer can
-be passed as an additional optional argument for `derive()`
-and `sign()`, and the result bytes will be written into it.
+Each primitive implementation is synchronous. Inputs can be passed as Uint8Array
+byte arrays (preferable) or strings. The output will return the same type as the
+input. A preallocated output buffer can be passed as an additional optional'
+argument for `derive()` and `sign()`, and the result bytes will be written into
+it.
 
-### Derive
+### Derive (bytes)
 
 ```javascript
 // `prv` is a 32-byte private key
 const prv = new Uint8Array(usersPrivateKeyBuffer);
 
-// `pub` is a 32-byte Uint8Array public key for a Nano account
+// `pub` is public key for a Nano account as a 64-character hexadecimal string
 const pub = nano25519.derive(prv);
 // clean up
 prv.fill(0);
 ```
 
+### Derive (strings)
+
+```javascript
+// `prv` is a private key as a 64-character hexadecimal string
+const prv = "0000000000000000000000000000000000000000000000000000000000000000";
+
+// `pub` is a public key for a Nano account as a 64-character hexadecimal string
+const pub = nano25519.derive(prv);
+```
+
 ### Derive into preallocated buffer
 
 ```javascript
@@ -95,32 +106,36 @@ nano25519.derive(prv, pub);
 prv.fill(0);
 ```
 
-### Derive (strings)
+### Sign (bytes)
 
 ```javascript
-// `prv` is a 64-character hex string private key
-const prv = "0000000000000000000000000000000000000000000000000000000000000000";
-
-// `pub` is a 64-character hex string public key for a Nano account
-const pub = nano25519.derive(prv);
-```
-
-### Sign
-
-```javascript
-// `msg` is a 32-byte hash of a valid Nano transaction block
+// `msg` is a 32-byte Nano transaction block hash
 const msg = new Uint8Array(blockHashBuffer);
 // `prv` is a 32-byte private key
 const prv = new Uint8Array(privateKeyBuffer);
 // `pub` is a 32-byte public key derived from `prv`
 const pub = new Uint8Array(publicKeyBuffer);
 
-// `sig` is a 64-byte Uint8Array signature for the block hash
+// `sig` is a signature for the message as a 128-character hexadecimal string
 const sig = nano25519.sign(msg, prv, pub);
 // clean up
 sk.fill(0);
 ```
 
+### Sign (strings)
+
+```javascript
+// `msg` is a Nano transaction block hash as a 64-character hexadecimal string
+const msg = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
+// `prv` is a private key as a 64-character hexadecimal string
+const prv = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
+// `pub` is a public key derived from `prv` as a 64-chararacter hexadecimal string
+const pub = nano25519.derive(prv);
+
+// `sig` is a signature for the message as a 128-char hexadecimal string
+const sig = nano25519.sign(msg, prv, pub);
+```
+
 ### Sign into preallocated buffer
 
 ```javascript
@@ -139,21 +154,7 @@ nano25519.sign(msg, prv, pub);
 sk.fill(0);
 ```
 
-### Sign (strings)
-
-```javascript
-// `msg` is a 64-char hex string hash of a valid Nano transaction block
-const msg = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
-// `prv` is a 64-char hex string private key
-const prv = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
-// `pub` is a 64-char hex string public key derived from `prv`
-const pub = nano25519.derive(prv);
-
-// `sig` is a 128-char hex string signature for the block hash
-const sig = nano25519.sign(msg, prv, pub);
-```
-
-### Verify
+### Verify (bytes)
 
 ```javascript
 // `sig` is a 64-byte signature
@@ -163,22 +164,24 @@ const msg = new Uint8Array(blockHashBuffer);
 // `pub` is a 32-byte public key for a Nano account
 const pub = new Uint8Array(usersPublicKeyBuffer);
 
-// `v` is a boolean 'true' if the same `prv` that derives `pub` was also used to create `sig` by signing `msg`, else 'false'
+// `v` is a boolean 'true' if the same `prv` that derives `pub` was also used to
+// create `sig` by signing `msg`, else 'false'
 const v = nano25519.verify(sig, msg, pub);
 ```
 
 ### Verify (strings)
 
 ```javascript
-// `sig` is a 128-char hex string signature
+// `sig` is a signature as a 128-character hexadecimal string
 const sig =
   "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
-// `msg` is a 64-char hex string hash of a valid Nano transaction block
+// `msg` is a Nano transaction block hash as a 64-character hexadecimal string
 const msg = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
-// `pub` is a 64-char hex string public key for a Nano account
+// `pub` is a public key for a Nano account as a 64-character hexadecimal string
 const pub = "fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210";
 
-// `v` is a boolean 'true' if the same `prv` that derives `pub` was also used to create `sig` by signing `msg`, else 'false'
+// `v` is a boolean 'true' if the same `prv` that derives `pub` was also used to
+// create `sig` by signing `msg`, else 'false'
 const v = nano25519.verify(sig, msg, pub);
 ```