Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derivation Path #41

Closed
Robco87 opened this issue Apr 23, 2019 · 4 comments
Closed

Derivation Path #41

Robco87 opened this issue Apr 23, 2019 · 4 comments

Comments

@Robco87
Copy link

Robco87 commented Apr 23, 2019

Is is possible to modify the derivation path and if so would that be done in BRBIP32sequence.c?

@EBGToo
Copy link
Contributor

EBGToo commented Apr 23, 2019

You are looking to generate keys for non-bitcoin currencies?

For our latest 'Ethereum' release we define the following:

extern BRKey
derivePrivateKeyFromSeed (UInt512 seed, uint32_t index) {
    BRKey privateKey;
    
    // The BIP32 privateKey for m/44'/60'/0'/0/index
    BRBIP32PrivKeyPath(&privateKey, &seed, sizeof(UInt512), 5,
                       44 | BIP32_HARD,          // purpose  : BIP-44
                       60 | BIP32_HARD,          // coin_type: Ethereum
                       0  | BIP32_HARD,          // account  : <n/a>
                       0,                        // change   : not change
                       index);                   // index    :
    
    privateKey.compressed = 0;
    
    return privateKey;
}

You can define an analogous function for something besides 'Ethereum'. Or call BRBIP32PrivKeyPath() with the arguments you need.

@Robco87
Copy link
Author

Robco87 commented Apr 24, 2019

It would be for bitcoin.
I have a use case that needs to support some legacy addresses that were created using Bip49.
Would using the above method be a simple as updated to:
BRBIP32PrivKeyPath(&privateKey, &seed, sizeof(UInt512), 5,
49 | BIP32_HARD,
0 | BIP32_HARD, //1 for testnet
0 | BIP32_HARD,
0,
index);

@EBGToo
Copy link
Contributor

EBGToo commented Apr 24, 2019

Yes, it may very well be. Certainly worth a try.

@EBGToo EBGToo closed this as completed Apr 25, 2019
@Robco87
Copy link
Author

Robco87 commented Apr 25, 2019

This could work for the private key path, but when restoring wallets its setting up the master public key. Do I also need to modify the path when a master public key is generated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants