@neuraiproject/neurai-key 2.8.6 → 2.8.8

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Neuraiproject
3
+ Copyright (c) 2026 Neuraiproject
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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@2.8.5/dist/NeuraiKey.js
8
+ **CDN**: https://cdn.jsdelivr.net/npm/@neuraiproject/neurai-key@2.8.8/dist/NeuraiKey.js
9
9
 
10
10
  ## Features
11
11
 
@@ -14,7 +14,24 @@ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
14
14
  - ✅ Support for passphrase (25th word) for additional security
15
15
  - ✅ Multi-language mnemonic support (English, Spanish, French, Italian, etc.)
16
16
  - ✅ Mainnet and Testnet support for Neurai (XNA)
17
+ - ✅ Support for both XNA (BIP44: 1900) and XNA Legacy (BIP44: 0) networks
17
18
  - ✅ Convert raw public keys into Neurai mainnet or testnet addresses
19
+ - ✅ PostQuantum addresses using ML-DSA-44 (FIPS 204) with Bech32m encoding
20
+
21
+ ## Network Types
22
+
23
+ This library supports three Neurai network configurations:
24
+
25
+ - **`xna` / `xna-test`**: Current Neurai standard (BIP44 coin type: 1900)
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)
28
+
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)
33
+
34
+ **Note**: Using different network types will generate completely different addresses from the same mnemonic.
18
35
 
19
36
 
20
37
  ## Example get external and internal (change) addresses by path
@@ -31,7 +48,7 @@ import NeuraiKey from "@neuraiproject/neurai-key";
31
48
  const mnemonic = NeuraiKey.generateMnemonic();
32
49
  const ACCOUNT = 0; //default is zero
33
50
  const POSITION = 1; //the second address for this wallet
34
- const network = "xna"; //or xna-test for testnet
51
+ const network = "xna"; //or xna-test for testnet, xna-legacy for legacy addresses
35
52
  const addressPair = NeuraiKey.getAddressPair(
36
53
  network,
37
54
  mnemonic,
@@ -166,6 +183,75 @@ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
166
183
 
167
184
  `publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
168
185
 
186
+ ## PostQuantum (ML-DSA-44) Addresses
187
+
188
+ 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.
189
+
190
+ ### Generate a PQ address
191
+
192
+ ```javascript
193
+ import NeuraiKey from "@neuraiproject/neurai-key";
194
+
195
+ const mnemonic = NeuraiKey.generateMnemonic();
196
+ const network = "xna-pq"; // or "xna-pq-test" for testnet
197
+ const ACCOUNT = 0;
198
+ const INDEX = 0;
199
+
200
+ const pqAddress = NeuraiKey.getPQAddress(network, mnemonic, ACCOUNT, INDEX);
201
+ console.log(pqAddress);
202
+ ```
203
+
204
+ Outputs
205
+
206
+ ```
207
+ {
208
+ address: 'nq1...', // Bech32m address
209
+ path: "m/100'/1900'/0'/0/0", // PQ derivation path
210
+ publicKey: '...', // ML-DSA-44 public key (2624 hex chars = 1312 bytes)
211
+ privateKey: '...', // ML-DSA-44 private key (5120 hex chars = 2560 bytes)
212
+ seedKey: '...' // 32-byte BIP32 seed used for ML-DSA keygen (64 hex chars)
213
+ }
214
+ ```
215
+
216
+ ### Generate a random PQ wallet
217
+
218
+ ```javascript
219
+ const pqWallet = NeuraiKey.generatePQAddressObject("xna-pq");
220
+ console.log(pqWallet.mnemonic); // 12-word mnemonic
221
+ console.log(pqWallet.address); // nq1...
222
+ ```
223
+
224
+ ### Reconstruct a PQ address from its public key
225
+
226
+ ```javascript
227
+ const pqAddress = NeuraiKey.getPQAddress("xna-pq", mnemonic, 0, 0);
228
+ const reconstructed = NeuraiKey.pqPublicKeyToAddress("xna-pq", pqAddress.publicKey);
229
+ // reconstructed === pqAddress.address
230
+ ```
231
+
232
+ ### Advanced: derive by path with HD key reuse
233
+
234
+ ```javascript
235
+ const hdKey = NeuraiKey.getPQHDKey("xna-pq", mnemonic);
236
+ const addr0 = NeuraiKey.getPQAddressByPath("xna-pq", hdKey, "m/100'/1900'/0'/0/0");
237
+ const addr1 = NeuraiKey.getPQAddressByPath("xna-pq", hdKey, "m/100'/1900'/0'/0/1");
238
+ ```
239
+
240
+ ### PQ Address Details
241
+
242
+ | Property | Value |
243
+ |----------|-------|
244
+ | Signature algorithm | ML-DSA-44 (FIPS 204) |
245
+ | Address encoding | Bech32m (witness version 1) |
246
+ | Mainnet HRP / prefix | `nq` / `nq1...` |
247
+ | Testnet HRP / prefix | `tnq` / `tnq1...` |
248
+ | Public key size | 1312 bytes |
249
+ | Derivation path (mainnet) | `m/100'/1900'/0'/0/index` |
250
+ | Derivation path (testnet) | `m/100'/1900'/0'/1/index` |
251
+ | Address hash | HASH160(0x05 \|\| pubkey) |
252
+
253
+ **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.
254
+
169
255
  ## Get public key from WIF
170
256
 
171
257
  If you have a private key in Wallet Import Format (WIF) and want the corresponding compressed public key:
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Neurai Legacy (XNA-LEGACY) chain configuration data
3
+ * This replaces the dependency on @hyperbitjs/chains with only the data needed for Neurai Legacy
4
+ */
5
+
6
+ const xnaLegacy = {
7
+ mainnet: {
8
+ name: "Neurai",
9
+ unit: "XNA",
10
+ symbol: "xna",
11
+ decimalPlaces: 100000000,
12
+ messagePrefix: "Neurai Signed Message:\n",
13
+ confirmations: 6,
14
+ website: "https://neurai.org/",
15
+ projectUrl: "https://github.com/NeuraiProject",
16
+ id: "94C49B3B-2C88-4408-B566-3D277C596778",
17
+ network: "mainnet",
18
+ hashGenesisBlock: "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806",
19
+ port: 19000,
20
+ portRpc: 19001,
21
+ protocol: {
22
+ magic: 1381320014
23
+ },
24
+ seedsDns: [
25
+ "seed1.neurai.org",
26
+ "seed2.neurai.org",
27
+ "neurai-ipv4.neuraiexplorer.com"
28
+ ],
29
+ versions: {
30
+ bip32: {
31
+ private: 76066276,
32
+ public: 76067358
33
+ },
34
+ bip44: 0,
35
+ private: 128,
36
+ public: 53,
37
+ scripthash: 117
38
+ }
39
+ },
40
+ testnet: {
41
+ name: "Neurai",
42
+ unit: "XNA",
43
+ symbol: "xna",
44
+ decimalPlaces: 100000000,
45
+ messagePrefix: "Neurai Signed Message:\n",
46
+ confirmations: 6,
47
+ website: "https://neurai.org/",
48
+ projectUrl: "https://github.com/NeuraiProject",
49
+ id: "1EB2ACBA-E8E0-4970-BB20-37DA4B70F6A6",
50
+ network: "testnet",
51
+ hashGenesisBlock: "0000006af8b8297448605b0283473ec712f9768f81cc7eae6269b875dee3b0cf",
52
+ port: 19100,
53
+ portRpc: 19101,
54
+ protocol: {
55
+ magic: 1313166674
56
+ },
57
+ seedsDns: [
58
+ "testnet1.neuracrypt.org",
59
+ "testnet2.neuracrypt.org",
60
+ "testnet3.neuracrypt.org"
61
+ ],
62
+ versions: {
63
+ bip32: {
64
+ private: 70615956,
65
+ public: 70617039
66
+ },
67
+ bip44: 1,
68
+ private: 239,
69
+ public: 127,
70
+ scripthash: 196
71
+ }
72
+ }
73
+ };
74
+
75
+ const chains = {
76
+ "xna-legacy": xnaLegacy
77
+ };
78
+
79
+ module.exports = {
80
+ xnaLegacy,
81
+ chains
82
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Neurai (XNA) PostQuantum chain configuration data
3
+ * ML-DSA-44 addresses using Bech32m encoding with witness version 1
4
+ */
5
+
6
+ const xnaPQ = {
7
+ mainnet: {
8
+ hrp: "nq",
9
+ witnessVersion: 1,
10
+ purpose: 100,
11
+ coinType: 1900,
12
+ changeIndex: 0,
13
+ bip32: {
14
+ private: 76066276,
15
+ public: 76067358
16
+ }
17
+ },
18
+ testnet: {
19
+ hrp: "tnq",
20
+ witnessVersion: 1,
21
+ purpose: 100,
22
+ coinType: 1900,
23
+ changeIndex: 1,
24
+ bip32: {
25
+ private: 70615956,
26
+ public: 70617039
27
+ }
28
+ }
29
+ };
30
+
31
+ const pqChains = {
32
+ "xna-pq": xnaPQ.mainnet,
33
+ "xna-pq-test": xnaPQ.testnet
34
+ };
35
+
36
+ module.exports = {
37
+ xnaPQ,
38
+ pqChains
39
+ };
package/coins/xna.js ADDED
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Neurai (XNA) chain configuration data
3
+ * This replaces the dependency on @hyperbitjs/chains with only the data needed for Neurai
4
+ */
5
+
6
+ const xna = {
7
+ mainnet: {
8
+ name: "Neurai",
9
+ unit: "XNA",
10
+ symbol: "xna",
11
+ decimalPlaces: 100000000,
12
+ messagePrefix: "Neurai Signed Message:\n",
13
+ confirmations: 6,
14
+ website: "https://neurai.org/",
15
+ projectUrl: "https://github.com/NeuraiProject",
16
+ id: "94C49B3B-2C88-4408-B566-3D277C596778",
17
+ network: "mainnet",
18
+ hashGenesisBlock: "00000044d33c0c0ba019be5c0249730424a69cb4c222153322f68c6104484806",
19
+ port: 19000,
20
+ portRpc: 19001,
21
+ protocol: {
22
+ magic: 1381320014
23
+ },
24
+ seedsDns: [
25
+ "seed1.neurai.org",
26
+ "seed2.neurai.org",
27
+ "neurai-ipv4.neuraiexplorer.com"
28
+ ],
29
+ versions: {
30
+ bip32: {
31
+ private: 76066276,
32
+ public: 76067358
33
+ },
34
+ bip44: 1900,
35
+ private: 128,
36
+ public: 53,
37
+ scripthash: 117
38
+ }
39
+ },
40
+ testnet: {
41
+ name: "Neurai",
42
+ unit: "XNA",
43
+ symbol: "xna",
44
+ decimalPlaces: 100000000,
45
+ messagePrefix: "Neurai Signed Message:\n",
46
+ confirmations: 6,
47
+ website: "https://neurai.org/",
48
+ projectUrl: "https://github.com/NeuraiProject",
49
+ id: "1EB2ACBA-E8E0-4970-BB20-37DA4B70F6A6",
50
+ network: "testnet",
51
+ hashGenesisBlock: "0000006af8b8297448605b0283473ec712f9768f81cc7eae6269b875dee3b0cf",
52
+ port: 19100,
53
+ portRpc: 19101,
54
+ protocol: {
55
+ magic: 1313166674
56
+ },
57
+ seedsDns: [
58
+ "testnet1.neuracrypt.org",
59
+ "testnet2.neuracrypt.org",
60
+ "testnet3.neuracrypt.org"
61
+ ],
62
+ versions: {
63
+ bip32: {
64
+ private: 70615956,
65
+ public: 70617039
66
+ },
67
+ bip44: 1,
68
+ private: 239,
69
+ public: 127,
70
+ scripthash: 196
71
+ }
72
+ }
73
+ };
74
+
75
+ const chains = {
76
+ xna
77
+ };
78
+
79
+ module.exports = {
80
+ xna,
81
+ chains
82
+ };