use of org.bitcoinj.crypto.ChildNumber in project bitrafael_public by GENERALBYTESCOM.
the class MasterPrivateKeyBTC method serializePUB.
public static String serializePUB(DeterministicKey masterKey, int standard, int accountIndex, String cryptoCurrency) {
final DeterministicKey purposeKey = HDKeyDerivation.deriveChildKey(masterKey, new ChildNumber(standard, true));
final DeterministicKey coinKey = HDKeyDerivation.deriveChildKey(purposeKey, new ChildNumber(WalletTools.getCoinTypeByCryptoCurrency(cryptoCurrency), true));
final DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinKey, new ChildNumber(accountIndex, true));
int header = 0x0488b21e;
switch(standard) {
case IWalletTools.STANDARD_BIP44:
// xpub
header = XPUB;
break;
case IWalletTools.STANDARD_BIP49:
// ypub
header = YPUB;
break;
case IWalletTools.STANDARD_BIP84:
// zpub
header = ZPUB;
break;
}
ByteBuffer ser = ByteBuffer.allocate(78);
ser.putInt(header);
ser.put((byte) accountKey.getDepth());
ser.putInt(accountKey.getParentFingerprint());
ser.putInt(accountKey.getChildNumber().i());
ser.put(accountKey.getChainCode());
ser.put(accountKey.getPubKey());
checkState(ser.position() == 78);
return Base58.encode(addChecksum(ser.array()));
}
use of org.bitcoinj.crypto.ChildNumber in project bitcoinj by bitcoinj.
the class KeyChainTransactionSigner method getSignature.
@Override
protected SignatureAndKey getSignature(Sha256Hash sighash, List<ChildNumber> derivationPath) {
List<ChildNumber> keyPath = ImmutableList.copyOf(derivationPath);
DeterministicKey key = keyChain.getKeyByPath(keyPath, true);
return new SignatureAndKey(key.sign(sighash), key.dropPrivateBytes().dropParent());
}
use of org.bitcoinj.crypto.ChildNumber in project cosmostation-android by cosmostation.
the class WKey method getKeyWithPathfromEntropy.
// singer
public static DeterministicKey getKeyWithPathfromEntropy(Account account, String entropy) {
BaseChain chain = getChain(account.baseChain);
if (!chain.equals(FETCHAI_MAIN)) {
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
return new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
} else {
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
if (account.customPath != 2) {
DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
return targetKey;
} else {
DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path), true));
DeterministicKey targetKey2 = new DeterministicHierarchy(targetKey).deriveChild(WKey.getFetchParentPath2(), true, true, ChildNumber.ZERO);
return targetKey2;
}
}
}
use of org.bitcoinj.crypto.ChildNumber in project haveno by haveno-dex.
the class HavenoKeyChainFactory method makeKeyChain.
@Override
public DeterministicKeyChain makeKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicSeed seed, KeyCrypter crypter, boolean isMarried, Script.ScriptType outputScriptType, ImmutableList<ChildNumber> accountPath) {
ImmutableList<ChildNumber> maybeUpdatedAccountPath = accountPath;
if (DeterministicKeyChain.ACCOUNT_ZERO_PATH.equals(accountPath)) {
// This is a bitcoinj 0.14 wallet that has no account path in the serialized mnemonic
KeyChainGroupStructure structure = new HavenoKeyChainGroupStructure();
maybeUpdatedAccountPath = structure.accountPathFor(outputScriptType);
}
return super.makeKeyChain(key, firstSubKey, seed, crypter, isMarried, outputScriptType, maybeUpdatedAccountPath);
}
use of org.bitcoinj.crypto.ChildNumber in project Elastos.DID.Java.SDK by elastos.
the class HDKey method derive.
public HDKey derive(String path) {
HDPath derivePath = HDPath.parsePath(path);
DeterministicKey child = key;
for (ChildNumber childNumber : derivePath) child = HDKeyDerivation.deriveChildKey(child, childNumber);
return new HDKey(child);
}
Aggregations