bitcoin-ibe icon indicating copy to clipboard operation
bitcoin-ibe copied to clipboard

How to derive child from ParentPublicKey?

Open ghost opened this issue 5 years ago • 2 comments

Here is my code:

    /**
     * Derive a child from an Xpub using a string for derivation
     *
     * See: https://github.com/monkeylord/bitcoin-ibe#derive-public-key-with-parent-public-key
     *
     * @param xpub Xpub string (ex: xpub123....
     * @param derive arbitrary derivation string (ex: "some string")
     */
    public deriveChildFromXpub(xpub: string, derive: string): string {
        const pubKey = new bsv.HDPublicKey(xpub);
        const childPublicKey = ibe.CKDpub(pubKey, derive); // ERROR HERE!
        const bsvAddres = new bsv.Address(childPublicKey.publicKey);
        return bsvAddres.toString();
    }

Here is the error I get with the latest version of bsv.js

First argument is an unrecognized data format.\n
at PublicKey._classifyArgs (/Users/user/git/me/api/node_modules/bsv/lib/publickey.js:86:11) 

ghost avatar Apr 12 '19 00:04 ghost