@neuraiproject/neurai-key 2.8.3 → 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/README.md CHANGED
@@ -3,7 +3,14 @@
3
3
  Generate Neurai addresses from a mnemonic phrase following the standards BIP32, BIP39, BIP44.
4
4
 
5
5
  That is, use your 12 words to get addresses for Neurai mainnet and testnet.
6
- The library also support Evrmorecoin EVR, both 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)
7
14
 
8
15
 
9
16
  ## Example get external and internal (change) addresses by path
@@ -19,7 +26,7 @@ import NeuraiKey from "@neuraiproject/neurai-key";
19
26
 
20
27
  const mnemonic = NeuraiKey.generateMnemonic();
21
28
  const ACCOUNT = 0; //default is zero
22
- const POSITION = 0; //the first address for this wallet
29
+ const POSITION = 1; //the second address for this wallet
23
30
  const network = "xna"; //or xna-test for testnet
24
31
  const addressPair = NeuraiKey.getAddressPair(
25
32
  network,
@@ -36,24 +43,63 @@ console.log(addressPair);
36
43
  Outputs
37
44
 
38
45
  ```
39
- 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
40
47
  {
41
48
  internal: {
42
- address: 'RC7Vn28tGaNrJtBm8MX5RCeCvzMpqZ1MgG',
43
- path: "m/44'/175'/0'/1/0",
44
- privateKey: 'a2c71a4284ed6792debd68d830a10515051fd166ce00535bf9fd19573ed5413b',
45
- WIF: 'L2g8U3ZNBLBQcy5f6C67h2eosps3MGkNmeNnk6Y8fZiMdSB9TuCJ'
49
+ address: 'NQM5zP6jkwDgCZ2UQiUicW4e3YcWc4NY4S',
50
+ path: "m/44'/0'/0'/1/1",
51
+ privateKey: '03e17c16cbab7390c8eea1919cbeefbcb7e5ccdb84e3cfc84f3d5a60dfaa6b68',
52
+ WIF: 'Kwy4Dv5yF4vSYJvbmk5v1eYJPBgSKRLqDc6BJ5tLfYN7p8RbfCaF'
46
53
  },
47
54
  external: {
48
- address: 'RE8YxTSYYcftnbX56rnAEwaiddqaqt8UgX',
49
- path: "m/44'/175'/0'/0/0",
50
- privateKey: 'b998a218e6bfde7162460893f79afc14b82b14e368507f5a85de28848ea96439',
51
- WIF: 'L3SV871B2mpUPTvj4U38UEp3Ah3wCVukF7tG2btHgjkiUSXRftSw'
55
+ address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
56
+ path: "m/44'/0'/0'/0/1",
57
+ privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
58
+ WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
52
59
  },
53
- position: 0
60
+ position: 1
54
61
  }
55
62
  ```
56
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
+
57
103
  ## Example get the first public address for a wallet by BIP44 path
58
104
 
59
105
  Note this is the fastest way to generate/derive addresses since we can re-use the hdKey object.
@@ -65,10 +111,13 @@ import NeuraiKey from "@neuraiproject/neurai-key";
65
111
 
66
112
  //use NeuraiKey.generateMnemonic() to generate mnemonic codes
67
113
  const mnemonic =
68
- "Mnemonic erosion total live dial hamster helmet top response cash obey anger balcony";
69
- const path = "m/44'/175'/0'/0/0";
114
+ "result pact model attract result puzzle final boss private educate luggage era";
115
+ const path = "m/44'/175'/0'/0/1";
70
116
  const network = "xna"; //or xna-test for testnet
71
- const hdKey = NeuraiKey.getHDKey("xna", mnemonic);
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);
72
121
 
73
122
  const address = NeuraiKey.getAddressByPath(network, hdKey, path);
74
123
 
@@ -80,10 +129,10 @@ Outputs
80
129
 
81
130
  ```
82
131
  {
83
- address: 'RWj697pj6PijkEcJLW3BLPG4GKre3BtgRP',
84
- path: "m/44'/175'/0'/0/0",
85
- privateKey: 'a5592434532a09a73350906f7846d272135a56b5a34d900659b31d2bb1aa6dfe',
86
- WIF: 'L2m8GmGYVAkvUEtLdhbFidQW2Zn3fULpE7sbWgmXChygNEBPd1PK'
132
+ address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
133
+ path: "m/44'/0'/0'/0/1",
134
+ privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
135
+ WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
87
136
  }
88
137
  ```
89
138
 
@@ -157,9 +206,9 @@ Source: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
157
206
 
158
207
  `m / purpose' / coin_type' / account' / change / address_index`
159
208
 
160
- 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"
161
210
 
162
- 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.
163
212
 
164
213
  Accounts is deprecated and should be 0
165
214