@neuraiproject/neurai-key 2.8.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -21
- package/dist/NeuraiKey.global.js +24091 -0
- package/dist/NeuraiKey.global.js.map +1 -0
- package/dist/browser.js +24084 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.cjs +24105 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +661 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -19
- package/.vscode/settings.json +0 -3
- package/coins/xna-legacy.js +0 -82
- package/coins/xna.js +0 -82
- package/dist/NeuraiKey.js +0 -57243
- package/dist/main.js +0 -326
- package/dist/main.js.map +0 -1
- package/dist/module.js +0 -303
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts +0 -76
- package/dist/types.d.ts.map +0 -1
- package/example-passphrase.js +0 -34
- package/index.ts +0 -217
- package/test-html/NeuraiKey.js +0 -60497
- package/test-html/index.html +0 -543
- package/test.js +0 -181
- package/types.ts +0 -8
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Generate Neurai addresses from a mnemonic phrase following the standards BIP32,
|
|
|
5
5
|
That is, use your 12 words to get addresses for Neurai mainnet and testnet.
|
|
6
6
|
|
|
7
7
|
**NPM**: https://www.npmjs.com/package/@neuraiproject/neurai-key
|
|
8
|
-
**CDN**: https://cdn.jsdelivr.net/npm/@neuraiproject/neurai-key@
|
|
8
|
+
**CDN**: https://cdn.jsdelivr.net/npm/@neuraiproject/neurai-key@3.0.0/dist/NeuraiKey.global.js
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
@@ -16,17 +16,20 @@ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
|
|
|
16
16
|
- ✅ Mainnet and Testnet support for Neurai (XNA)
|
|
17
17
|
- ✅ Support for both XNA (BIP44: 1900) and XNA Legacy (BIP44: 0) networks
|
|
18
18
|
- ✅ Convert raw public keys into Neurai mainnet or testnet addresses
|
|
19
|
+
- ✅ PostQuantum addresses using ML-DSA-44 (FIPS 204) with Bech32m encoding
|
|
19
20
|
|
|
20
21
|
## Network Types
|
|
21
22
|
|
|
22
|
-
This library supports
|
|
23
|
+
This library supports three Neurai network configurations:
|
|
23
24
|
|
|
24
25
|
- **`xna` / `xna-test`**: Current Neurai standard (BIP44 coin type: 1900)
|
|
25
26
|
- **`xna-legacy` / `xna-legacy-test`**: Legacy Neurai addresses (BIP44 coin type: 0)
|
|
27
|
+
- **`xna-pq` / `xna-pq-test`**: PostQuantum ML-DSA-44 addresses (Bech32m, witness v1)
|
|
26
28
|
|
|
27
|
-
The main difference is the
|
|
28
|
-
- **XNA**: `m/44'/1900'/0'/0/0` (recommended for new wallets)
|
|
29
|
-
- **XNA Legacy**: `m/44'/0'/0'/0/0` (for compatibility with older wallets)
|
|
29
|
+
The main difference is the derivation path and address encoding:
|
|
30
|
+
- **XNA**: `m/44'/1900'/0'/0/0` — Base58Check, prefix `N` (recommended for new wallets)
|
|
31
|
+
- **XNA Legacy**: `m/44'/0'/0'/0/0` — Base58Check, prefix `N` (for compatibility with older wallets)
|
|
32
|
+
- **XNA PostQuantum**: `m/100'/1900'/0'/0/0` — Bech32m, prefix `nq1` (for future quantum-resistant fork)
|
|
30
33
|
|
|
31
34
|
**Note**: Using different network types will generate completely different addresses from the same mnemonic.
|
|
32
35
|
|
|
@@ -37,10 +40,8 @@ A simple and "spot on" way to generate/derive addresses.
|
|
|
37
40
|
|
|
38
41
|
If you need brutal performance check out getAddressByPath example below.
|
|
39
42
|
|
|
40
|
-
```
|
|
43
|
+
```javascript
|
|
41
44
|
import NeuraiKey from "@neuraiproject/neurai-key";
|
|
42
|
-
//Or import as CommonsJS module
|
|
43
|
-
//const NeuraiKey = require("@neuraiproject/neurai-key");
|
|
44
45
|
|
|
45
46
|
const mnemonic = NeuraiKey.generateMnemonic();
|
|
46
47
|
const ACCOUNT = 0; //default is zero
|
|
@@ -180,6 +181,75 @@ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
|
|
|
180
181
|
|
|
181
182
|
`publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
|
|
182
183
|
|
|
184
|
+
## PostQuantum (ML-DSA-44) Addresses
|
|
185
|
+
|
|
186
|
+
Generate quantum-resistant addresses using the ML-DSA-44 signature scheme (FIPS 204). These addresses use Bech32m encoding with witness version 1, preparing for a future post-quantum fork.
|
|
187
|
+
|
|
188
|
+
### Generate a PQ address
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
import NeuraiKey from "@neuraiproject/neurai-key";
|
|
192
|
+
|
|
193
|
+
const mnemonic = NeuraiKey.generateMnemonic();
|
|
194
|
+
const network = "xna-pq"; // or "xna-pq-test" for testnet
|
|
195
|
+
const ACCOUNT = 0;
|
|
196
|
+
const INDEX = 0;
|
|
197
|
+
|
|
198
|
+
const pqAddress = NeuraiKey.getPQAddress(network, mnemonic, ACCOUNT, INDEX);
|
|
199
|
+
console.log(pqAddress);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Outputs
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
{
|
|
206
|
+
address: 'nq1...', // Bech32m address
|
|
207
|
+
path: "m/100'/1900'/0'/0/0", // PQ derivation path
|
|
208
|
+
publicKey: '...', // ML-DSA-44 public key (2624 hex chars = 1312 bytes)
|
|
209
|
+
privateKey: '...', // ML-DSA-44 private key (5120 hex chars = 2560 bytes)
|
|
210
|
+
seedKey: '...' // 32-byte BIP32 seed used for ML-DSA keygen (64 hex chars)
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Generate a random PQ wallet
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
const pqWallet = NeuraiKey.generatePQAddressObject("xna-pq");
|
|
218
|
+
console.log(pqWallet.mnemonic); // 12-word mnemonic
|
|
219
|
+
console.log(pqWallet.address); // nq1...
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Reconstruct a PQ address from its public key
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
const pqAddress = NeuraiKey.getPQAddress("xna-pq", mnemonic, 0, 0);
|
|
226
|
+
const reconstructed = NeuraiKey.pqPublicKeyToAddress("xna-pq", pqAddress.publicKey);
|
|
227
|
+
// reconstructed === pqAddress.address
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Advanced: derive by path with HD key reuse
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
const hdKey = NeuraiKey.getPQHDKey("xna-pq", mnemonic);
|
|
234
|
+
const addr0 = NeuraiKey.getPQAddressByPath("xna-pq", hdKey, "m/100'/1900'/0'/0/0");
|
|
235
|
+
const addr1 = NeuraiKey.getPQAddressByPath("xna-pq", hdKey, "m/100'/1900'/0'/0/1");
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### PQ Address Details
|
|
239
|
+
|
|
240
|
+
| Property | Value |
|
|
241
|
+
|----------|-------|
|
|
242
|
+
| Signature algorithm | ML-DSA-44 (FIPS 204) |
|
|
243
|
+
| Address encoding | Bech32m (witness version 1) |
|
|
244
|
+
| Mainnet HRP / prefix | `nq` / `nq1...` |
|
|
245
|
+
| Testnet HRP / prefix | `tnq` / `tnq1...` |
|
|
246
|
+
| Public key size | 1312 bytes |
|
|
247
|
+
| Derivation path (mainnet) | `m/100'/1900'/0'/0/index` |
|
|
248
|
+
| Derivation path (testnet) | `m/100'/1900'/0'/1/index` |
|
|
249
|
+
| Address hash | HASH160(0x05 \|\| pubkey) |
|
|
250
|
+
|
|
251
|
+
**Note**: PQ addresses do not have a WIF (Wallet Import Format) field since WIF is specific to secp256k1 keys. The `seedKey` field contains the 32-byte BIP32-derived seed used for deterministic ML-DSA-44 key generation, useful for cross-implementation verification.
|
|
252
|
+
|
|
183
253
|
## Get public key from WIF
|
|
184
254
|
|
|
185
255
|
If you have a private key in Wallet Import Format (WIF) and want the corresponding compressed public key:
|
|
@@ -196,47 +266,58 @@ console.log(pubkeyHex);
|
|
|
196
266
|
|
|
197
267
|
## How to import into your project
|
|
198
268
|
|
|
199
|
-
###
|
|
269
|
+
### ESM default
|
|
200
270
|
|
|
201
|
-
```
|
|
202
|
-
//As ES6 module
|
|
271
|
+
```javascript
|
|
203
272
|
import NeuraiKey from "@neuraiproject/neurai-key";
|
|
204
273
|
```
|
|
205
274
|
|
|
206
|
-
###
|
|
275
|
+
### ESM browser explicit
|
|
207
276
|
|
|
277
|
+
```javascript
|
|
278
|
+
import NeuraiKey from "@neuraiproject/neurai-key/browser";
|
|
208
279
|
```
|
|
209
|
-
|
|
280
|
+
|
|
281
|
+
### CommonJS
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
210
284
|
const NeuraiKey = require("@neuraiproject/neurai-key");
|
|
211
285
|
```
|
|
212
286
|
|
|
213
|
-
###
|
|
287
|
+
### Global build for HTML
|
|
214
288
|
|
|
215
|
-
```
|
|
216
|
-
//A browseriy:d version, with all the dependencies bundled for the web
|
|
289
|
+
```html
|
|
217
290
|
<html>
|
|
218
291
|
<body>
|
|
219
|
-
<script src="./node_modules/@neuraiproject/neurai-key/dist/NeuraiKey.js"></script>
|
|
292
|
+
<script src="./node_modules/@neuraiproject/neurai-key/dist/NeuraiKey.global.js"></script>
|
|
220
293
|
<script>
|
|
221
|
-
alert(NeuraiKey.generateMnemonic());
|
|
294
|
+
alert(globalThis.NeuraiKey.generateMnemonic());
|
|
222
295
|
</script>
|
|
223
296
|
</body>
|
|
224
297
|
</html>
|
|
225
298
|
```
|
|
226
299
|
|
|
300
|
+
## Package layout in `3.0.0`
|
|
301
|
+
|
|
302
|
+
- `dist/index.js`: ESM main entry
|
|
303
|
+
- `dist/index.cjs`: CommonJS entry
|
|
304
|
+
- `dist/browser.js`: explicit browser ESM bundle
|
|
305
|
+
- `dist/NeuraiKey.global.js`: global build for `<script>`
|
|
306
|
+
- `dist/index.d.ts`: TypeScript declarations
|
|
307
|
+
|
|
227
308
|
## install
|
|
228
309
|
|
|
229
|
-
`
|
|
310
|
+
`npm install @neuraiproject/neurai-key`
|
|
230
311
|
|
|
231
312
|
## build
|
|
232
313
|
|
|
233
|
-
`
|
|
314
|
+
`npm run build`
|
|
234
315
|
|
|
235
316
|
## test
|
|
236
317
|
|
|
237
318
|
`npm test`
|
|
238
319
|
|
|
239
|
-
|
|
320
|
+
The test script already builds the package before running Jest.
|
|
240
321
|
|
|
241
322
|
## BIP32
|
|
242
323
|
|