@neuraiproject/neurai-key 2.8.4 → 2.8.6

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "liveServer.settings.port": 5501
3
+ }
package/README.md CHANGED
@@ -4,6 +4,9 @@ Generate Neurai addresses from a mnemonic phrase following the standards BIP32,
4
4
 
5
5
  That is, use your 12 words to get addresses for Neurai mainnet and testnet.
6
6
 
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
9
+
7
10
  ## Features
8
11
 
9
12
  - ✅ Generate HD wallets from mnemonic phrases (BIP39)
@@ -11,6 +14,7 @@ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
11
14
  - ✅ Support for passphrase (25th word) for additional security
12
15
  - ✅ Multi-language mnemonic support (English, Spanish, French, Italian, etc.)
13
16
  - ✅ Mainnet and Testnet support for Neurai (XNA)
17
+ - ✅ Convert raw public keys into Neurai mainnet or testnet addresses
14
18
 
15
19
 
16
20
  ## Example get external and internal (change) addresses by path
@@ -48,13 +52,15 @@ Mnemonic result pact model attract result puzzle final boss private educate lugg
48
52
  internal: {
49
53
  address: 'NQM5zP6jkwDgCZ2UQiUicW4e3YcWc4NY4S',
50
54
  path: "m/44'/0'/0'/1/1",
51
- privateKey: '03e17c16cbab7390c8eea1919cbeefbcb7e5ccdb84e3cfc84f3d5a60dfaa6b68',
52
- WIF: 'Kwy4Dv5yF4vSYJvbmk5v1eYJPBgSKRLqDc6BJ5tLfYN7p8RbfCaF'
55
+ publicKey: '02fe9a4190973398c54cdea353cb5b18aba4f272324ac3f15f4f204ef0884538e7',
56
+ privateKey: '8ce41bc45958cf3f4124bcd40b940752fbaf9be58ed8dec2dd7551388523f0a9',
57
+ WIF: 'L1was5cU14EbQDfz4BpiWhNAWZdmc4o1VSzv5w5GgKzSJwHpnGzP'
53
58
  },
54
59
  external: {
55
60
  address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
56
61
  path: "m/44'/0'/0'/0/1",
57
- privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
62
+ publicKey: '024108b96e53795cc28fb8b64532e61f17aa3c149e06815958361c5dddba1e7ec0',
63
+ privateKey: '08ae5a08aa6a464619c177a551488c868010b4d2b2249892712be9a4990f9fc3',
58
64
  WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
59
65
  },
60
66
  position: 1
@@ -131,11 +137,49 @@ Outputs
131
137
  {
132
138
  address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
133
139
  path: "m/44'/0'/0'/0/1",
134
- privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
140
+ publicKey: '024108b96e53795cc28fb8b64532e61f17aa3c149e06815958361c5dddba1e7ec0',
141
+ privateKey: '08ae5a08aa6a464619c177a551488c868010b4d2b2249892712be9a4990f9fc3',
135
142
  WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
136
143
  }
137
144
  ```
138
145
 
146
+ ## Convert a public key into a Neurai address
147
+
148
+ Every derived address now exposes the compressed public key so you can verify or reconstruct the address later. If you only have the raw public key (33-byte compressed or 65-byte uncompressed) you can convert it back into a Neurai address on either network:
149
+
150
+ ```javascript
151
+ import NeuraiKey from "@neuraiproject/neurai-key";
152
+
153
+ const mnemonic = "result pact model attract result puzzle final boss private educate luggage era";
154
+ const pair = NeuraiKey.getAddressPair("xna", mnemonic, 0, 1);
155
+
156
+ // `publicKey` is a hex string, but Buffers are also accepted
157
+ const reconstructed = NeuraiKey.publicKeyToAddress("xna", pair.external.publicKey);
158
+
159
+ console.log(reconstructed); // NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp
160
+
161
+ // Works the same way for testnet
162
+ const testPair = NeuraiKey.getAddressPair("xna-test", mnemonic, 0, 1);
163
+ const testAddress = NeuraiKey.publicKeyToAddress("xna-test", testPair.external.publicKey);
164
+ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
165
+ ```
166
+
167
+ `publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
168
+
169
+ ## Get public key from WIF
170
+
171
+ If you have a private key in Wallet Import Format (WIF) and want the corresponding compressed public key:
172
+
173
+ ```javascript
174
+ import NeuraiKey from "@neuraiproject/neurai-key";
175
+
176
+ const network = "xna"; // or "xna-test"
177
+ const wif = "KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq";
178
+
179
+ const pubkeyHex = NeuraiKey.getPubkeyByWIF(network, wif);
180
+ console.log(pubkeyHex);
181
+ ```
182
+
139
183
  ## How to import into your project
140
184
 
141
185
  ### ES6 module