@neuraiproject/neurai-key 2.8.7 → 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/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
 
@@ -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 two Neurai network configurations:
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 BIP44 derivation path:
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
 
@@ -180,6 +183,75 @@ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
180
183
 
181
184
  `publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
182
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
+
183
255
  ## Get public key from WIF
184
256
 
185
257
  If you have a private key in Wallet Import Format (WIF) and want the corresponding compressed public key:
@@ -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
+ };