@neuraiproject/neurai-key 2.8.4 → 2.8.5

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
@@ -11,6 +11,7 @@ That is, use your 12 words to get addresses for Neurai mainnet and testnet.
11
11
  - ✅ Support for passphrase (25th word) for additional security
12
12
  - ✅ Multi-language mnemonic support (English, Spanish, French, Italian, etc.)
13
13
  - ✅ Mainnet and Testnet support for Neurai (XNA)
14
+ - ✅ Convert raw public keys into Neurai mainnet or testnet addresses
14
15
 
15
16
 
16
17
  ## Example get external and internal (change) addresses by path
@@ -48,13 +49,15 @@ Mnemonic result pact model attract result puzzle final boss private educate lugg
48
49
  internal: {
49
50
  address: 'NQM5zP6jkwDgCZ2UQiUicW4e3YcWc4NY4S',
50
51
  path: "m/44'/0'/0'/1/1",
51
- privateKey: '03e17c16cbab7390c8eea1919cbeefbcb7e5ccdb84e3cfc84f3d5a60dfaa6b68',
52
- WIF: 'Kwy4Dv5yF4vSYJvbmk5v1eYJPBgSKRLqDc6BJ5tLfYN7p8RbfCaF'
52
+ publicKey: '02fe9a4190973398c54cdea353cb5b18aba4f272324ac3f15f4f204ef0884538e7',
53
+ privateKey: '8ce41bc45958cf3f4124bcd40b940752fbaf9be58ed8dec2dd7551388523f0a9',
54
+ WIF: 'L1was5cU14EbQDfz4BpiWhNAWZdmc4o1VSzv5w5GgKzSJwHpnGzP'
53
55
  },
54
56
  external: {
55
57
  address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
56
58
  path: "m/44'/0'/0'/0/1",
57
- privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
59
+ publicKey: '024108b96e53795cc28fb8b64532e61f17aa3c149e06815958361c5dddba1e7ec0',
60
+ privateKey: '08ae5a08aa6a464619c177a551488c868010b4d2b2249892712be9a4990f9fc3',
58
61
  WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
59
62
  },
60
63
  position: 1
@@ -131,11 +134,35 @@ Outputs
131
134
  {
132
135
  address: 'NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp',
133
136
  path: "m/44'/0'/0'/0/1",
134
- privateKey: '0456b9eed4a0fd4c2a87f53f06aa1af5e5d44b9c68e6f464fba1abf02e3d41fe',
137
+ publicKey: '024108b96e53795cc28fb8b64532e61f17aa3c149e06815958361c5dddba1e7ec0',
138
+ privateKey: '08ae5a08aa6a464619c177a551488c868010b4d2b2249892712be9a4990f9fc3',
135
139
  WIF: 'KwWavecys1Qskgzwsyv6CNeTospWkvMeLzx3dLqeV4xAJEMXF8Qq'
136
140
  }
137
141
  ```
138
142
 
143
+ ## Convert a public key into a Neurai address
144
+
145
+ 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:
146
+
147
+ ```javascript
148
+ import NeuraiKey from "@neuraiproject/neurai-key";
149
+
150
+ const mnemonic = "result pact model attract result puzzle final boss private educate luggage era";
151
+ const pair = NeuraiKey.getAddressPair("xna", mnemonic, 0, 1);
152
+
153
+ // `publicKey` is a hex string, but Buffers are also accepted
154
+ const reconstructed = NeuraiKey.publicKeyToAddress("xna", pair.external.publicKey);
155
+
156
+ console.log(reconstructed); // NLdcSXGQvCVf2RTKhx7GZom34f1JADhBTp
157
+
158
+ // Works the same way for testnet
159
+ const testPair = NeuraiKey.getAddressPair("xna-test", mnemonic, 0, 1);
160
+ const testAddress = NeuraiKey.publicKeyToAddress("xna-test", testPair.external.publicKey);
161
+ console.log(testAddress); // tPXGaMRNwZuV1UKSrD9gABPscrJWUmedQ9
162
+ ```
163
+
164
+ `publicKeyToAddress` throws if the key length is not 33 or 65 bytes so invalid inputs are surfaced immediately.
165
+
139
166
  ## How to import into your project
140
167
 
141
168
  ### ES6 module