Repository:
repositories {
maven {
url 'https://dl.bintray.com/novacrypto/BIP/'
}
}
Add dependency:
dependencies {
compile 'io.github.novacrypto:BIP44:2018.10.06'
}
AddressIndex addressIndex = BIP44
.m()
.purpose44()
.coinType(2)
.account(1)
.external()
.address(5);
String path = m().purpose44()
.coinType(2)
.account(1)
.external()
.address(5)
.toString(); //"m/44'/2'/1'/0/5"
Using NovaCrypto/BIP32Derivation keys.
Derive<YourKeyType> derive = new CkdFunctionDerive<>((parent, childIndex) -> {/*your CKD function*/}, yourRootKey);
YourKeyType ketAtPath = derive.derive(addressIndex, AddressIndex.DERIVATION);
Account account = m().purpose44()
.coinType(2)
.account(1);
YourKeyType addressKey = derive
.derive(account, Account.DERIVATION);
Derive<YourKeyType> derive = new CkdFunctionDerive<>((parent, childIndex) -> {/*your CKD function*/}, accountPrivateKey);
YourKeyType addressKey = derive
.derive(addressIndex, AddressIndex.DERIVATION_FROM_ACCOUNT);
Derive<YourKeyType> derive = new CkdFunctionDerive<>((parent, childIndex) -> {/*your CKD function*/}, accountPublicKey);
YourKeyType addressKey = derive
.derive(addressIndex, AddressIndex.DERIVATION_FROM_ACCOUNT);
Using NovaCrypto/BIP32 keys, which implement Derive<>
directly:
!!! Note that BIP32 is a work in progress and you shouldn't use this just yet for any main net transactions. !!!
PrivateKey addressKey = rootPrivateKey
.derive(addressIndex, AddressIndex.DERIVATION);
Account account = m().purpose44()
.coinType(2)
.account(1);
PrivateKey addressKey = rootPrivateKey
.derive(account, Account.DERIVATION);
PrivateKey addressKey = accountPrivateKey
.derive(addressIndex, AddressIndex.DERIVATION_FROM_ACCOUNT);
PublicKey addressKey = accountPublicKey
.derive(addressIndex, AddressIndex.DERIVATION_FROM_ACCOUNT);