```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">
## 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
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
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
// `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);
```