@neuraiproject/neurai-key 2.8.2 → 2.8.4

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) 2022 Raven Rebels
3
+ Copyright (c) 2025 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
@@ -1,8 +1,16 @@
1
- # Neurai-key
1
+ # neurai-key
2
2
 
3
3
  Generate Neurai addresses from a mnemonic phrase following the standards BIP32, BIP39, BIP44.
4
4
 
5
- That is, use your 12 words to get addresses for Neurai mainnet.
5
+ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
6
+
7
+ ## Features
8
+
9
+ - ✅ Generate HD wallets from mnemonic phrases (BIP39)
10
+ - ✅ Derive addresses using BIP32/BIP44 standards
11
+ - ✅ Support for passphrase (25th word) for additional security
12
+ - ✅ Multi-language mnemonic support (English, Spanish, French, Italian, etc.)
13
+ - ✅ Mainnet and Testnet support for Neurai (XNA)
6
14
 
7
15
 
8
16
  ## Example get external and internal (change) addresses by path
@@ -18,8 +26,8 @@ import NeuraiKey from "@neuraiproject/neurai-key";
18
26
 
19
27
  const mnemonic = NeuraiKey.generateMnemonic();
20
28
  const ACCOUNT = 0; //default is zero
21
- const POSITION = 0; //the first address for this wallet
22
- const network = "xna"; //or rvn-test for testnet
29
+ const POSITION = 1; //the second address for this wallet
30
+ const network = "xna"; //or xna-test for testnet
23
31
  const addressPair = NeuraiKey.getAddressPair(
24
32
  network,
25
33
  mnemonic,
@@ -32,27 +40,66 @@ console.info("Mnemonic", mnemonic);
32
40
  console.log(addressPair);
33
41
  ```
34
42
 
35
- Outputs (Old example but you get the point)
43
+ Outputs
36
44
 
37
45
  ```
38
- Mnemonic wrong breeze brick wrestle exotic erode news clown copy install marble promote
46
+ Mnemonic result pact model attract result puzzle final boss private educate luggage era
39
47
  {
40
48
  internal: {
41
- address: 'RC7Vn28tGaNrJtBm8MX5RCeCvzMpqZ1MgG',
42
- path: "m/44'/175'/0'/1/0",
43
- privateKey: 'a2c71a4284ed6792debd68d830a10515051fd166ce00535bf9fd19573ed5413b',
44
- WIF: 'L2g8U3ZNBLBQcy5f6C67h2eosps3MGkNmeNnk6Y8fZiMdSB9TuCJ'
49
+ address: 'NQM5zP6jkwDgCZ2UQiUicW4e3YcWc4NY4S',
50
+ path: "m/44'/0'/0'/1/1",
51
+ privateKey: '03e17c16cbab7390c8eea1919cbeefbcb7e5ccdb84e3cfc84f3d5a60dfaa6b68',
52
+ WIF: 'Kwy4Dv5yF4vSYJvbmk5v1eYJPBgSKRLqDc6BJ5tLfYN7p8RbfCaF'
45
53
  },
46
54
  external: {
47
- address: 'RE8YxTSYYcftnbX56rnAEwaiddqaqt8UgX',
48
- path: "m/44'/175'/0'/0/0",
49
- privateKey: 'b998a218e6bfde7162460893f79afc14b82b14e368507f5a85de28848ea96439',
50
- WIF: 'L3SV871B2mpUPTvj4U38UEp3Ah3wCVukF7tG2btHgjkiUSXRftSw'
55
+ address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
56
+ path: "m/44'/0'/0'/0/1",
57
+ privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
58
+ WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
51
59
  },
52
- position: 0
60
+ position: 1
53
61
  }
54
62
  ```
55
63
 
64
+ ## Example with Passphrase (BIP39 25th word)
65
+
66
+ For enhanced security, you can use an optional passphrase (also known as the "25th word").
67
+ This creates a completely different set of addresses from the same mnemonic.
68
+
69
+ **Important**: If you lose your passphrase, you cannot recover your wallet even with the mnemonic!
70
+
71
+ ```javascript
72
+ import NeuraiKey from "@neuraiproject/neurai-key";
73
+
74
+ const mnemonic = "result pact model attract result puzzle final boss private educate luggage era";
75
+ const passphrase = "my secret passphrase"; // Optional but highly secure
76
+ const network = "xna";
77
+ const ACCOUNT = 0;
78
+ const POSITION = 0;
79
+
80
+ // Generate address with passphrase
81
+ const addressPair = NeuraiKey.getAddressPair(
82
+ network,
83
+ mnemonic,
84
+ ACCOUNT,
85
+ POSITION,
86
+ passphrase // 5th parameter (optional)
87
+ );
88
+
89
+ console.log(addressPair.external.address);
90
+ // This will generate a DIFFERENT address than without the passphrase
91
+
92
+ // Without passphrase (or empty string)
93
+ const addressPairNoPass = NeuraiKey.getAddressPair(network, mnemonic, ACCOUNT, POSITION);
94
+ console.log(addressPairNoPass.external.address);
95
+ // This generates the standard address
96
+ ```
97
+
98
+ **Use cases for passphrase:**
99
+ - Extra layer of security beyond the mnemonic
100
+ - Create multiple wallets from a single mnemonic
101
+ - Plausible deniability (different passphrases = different wallets)
102
+
56
103
  ## Example get the first public address for a wallet by BIP44 path
57
104
 
58
105
  Note this is the fastest way to generate/derive addresses since we can re-use the hdKey object.
@@ -64,10 +111,13 @@ import NeuraiKey from "@neuraiproject/neurai-key";
64
111
 
65
112
  //use NeuraiKey.generateMnemonic() to generate mnemonic codes
66
113
  const mnemonic =
67
- "Mnemonic erosion total live dial hamster helmet top response cash obey anger balcony";
68
- const path = "m/44'/175'/0'/0/0";
69
- const network = "xna";
70
- const hdKey = NeuraiKey.getHDKey("xna", mnemonic);
114
+ "result pact model attract result puzzle final boss private educate luggage era";
115
+ const path = "m/44'/175'/0'/0/1";
116
+ const network = "xna"; //or xna-test for testnet
117
+
118
+ // Optional: add passphrase as third parameter
119
+ const passphrase = ""; // empty string or omit for no passphrase
120
+ const hdKey = NeuraiKey.getHDKey(network, mnemonic, passphrase);
71
121
 
72
122
  const address = NeuraiKey.getAddressByPath(network, hdKey, path);
73
123
 
@@ -75,14 +125,14 @@ console.log(address);
75
125
 
76
126
  ```
77
127
 
78
- Outputs (Again another old example but you get the point)
128
+ Outputs
79
129
 
80
130
  ```
81
131
  {
82
- address: 'RWj697pj6PijkEcJLW3BLPG4GKre3BtgRP',
83
- path: "m/44'/175'/0'/0/0",
84
- privateKey: 'a5592434532a09a73350906f7846d272135a56b5a34d900659b31d2bb1aa6dfe',
85
- WIF: 'L2m8GmGYVAkvUEtLdhbFidQW2Zn3fULpE7sbWgmXChygNEBPd1PK'
132
+ address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
133
+ path: "m/44'/0'/0'/0/1",
134
+ privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
135
+ WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
86
136
  }
87
137
  ```
88
138
 
@@ -156,9 +206,9 @@ Source: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
156
206
 
157
207
  `m / purpose' / coin_type' / account' / change / address_index`
158
208
 
159
- So in the case of Neurai the path m/44'/175'/0'/0/0 says "give me the first address"
209
+ So in the case of Neurai the path m/44'/0'/0'/0/1 says "give me the second address"
160
210
 
161
- The first part m/44'/175' says that the purpose is to use BIP44 with Neurai (175). Consider that static code.
211
+ The first part m/44'/0' says that the purpose is to use BIP44 with Neurai (coin_type 0). Consider that static code.
162
212
 
163
213
  Accounts is deprecated and should be 0
164
214