@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.
- package/.vscode/settings.json +3 -0
- package/README.md +31 -4
- package/dist/NeuraiKey.js +32279 -32111
- package/dist/main.js +26 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +27 -6
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/index.ts +33 -6
- package/package.json +3 -2
- package/test-html/NeuraiKey.js +32279 -32111
- package/test-html/index.html +12 -1
- package/test.js +18 -0
- package/types.ts +1 -0
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|