Skip to content

Commit 08d38dc

Browse files
committed
Clarify hdkey
1 parent d45622e commit 08d38dc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,26 @@ Note: if you've been using ethereum-cryptography v0.1, it had different API. We'
205205

206206
## BIP32 HD Keygen
207207

208-
This module exports a single class whose type is
208+
This module exports a single class `HDKey`, which should be used like this:
209+
210+
```ts
211+
const { HDKey } = require("ethereum-cryptography/secp256k1");
212+
const hdkey1 = HDKey.fromMasterSeed(seed);
213+
const hdkey2 = HDKey.fromExtendedKey(base58key);
214+
const hdkey3 = HDKey.fromJSON({ xpriv: string });
215+
216+
// props
217+
[hdkey1.depth, hdkey1.index, hdkey1.chainCode];
218+
console.log(hdkey2.privateKey, hdkey2.publicKey);
219+
console.log(hdkey3.derive("m/0/2147483647'/1"));
220+
const sig = hdkey3.sign(hash);
221+
hdkey3.verify(hash, sig);
222+
```
223+
224+
Note: do not set `privateKey` and `publicKey` directly. Use `wipePrivateData()` to
225+
clean-up the instance.
226+
227+
The full API is:
209228

210229
```ts
211230
class HDKey {

0 commit comments

Comments
 (0)