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