Java Code Examples for net.bither.bitherj.crypto.mnemonic.MnemonicCode#instance()
The following examples show how to use
net.bither.bitherj.crypto.mnemonic.MnemonicCode#instance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean checkPassword(String keysString, CharSequence password) throws MnemonicException.MnemonicLengthException { String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keysString); String address = Base58.hexToBase58WithAddress(passwordSeeds[0]); String encreyptString = Utils.joinString(new String[]{passwordSeeds[1], passwordSeeds[2], passwordSeeds[3]}, QRCodeUtil.QR_CODE_SPLIT); byte[] seed = new EncryptedData(encreyptString).decrypt(password); MnemonicCode mnemonic = MnemonicCode.instance(); byte[] s = mnemonic.toSeed(mnemonic.toMnemonic(seed), ""); DeterministicKey master = HDKeyDerivation.createMasterPrivateKey(s); DeterministicKey purpose = master.deriveHardened(44); DeterministicKey coinType = purpose.deriveHardened(0); DeterministicKey account = coinType.deriveHardened(0); DeterministicKey external = account.deriveSoftened(0); external.clearPrivateKey(); DeterministicKey key = external.deriveSoftened(0); boolean result = Utils.compareString(address, Utils.toAddress(key.getPubKeyHash())); key.wipe(); return result; }
Example 2
Source File: HDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean checkPassword(String keysString, CharSequence password) throws MnemonicException.MnemonicLengthException { String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keysString); String address = Base58.hexToBase58WithAddress(passwordSeeds[0]); String encreyptString = Utils.joinString(new String[]{passwordSeeds[1], passwordSeeds[2], passwordSeeds[3]}, QRCodeUtil.QR_CODE_SPLIT); byte[] seed = new EncryptedData(encreyptString).decrypt(password); MnemonicCode mnemonic = MnemonicCode.instance(); byte[] s = mnemonic.toSeed(mnemonic.toMnemonic(seed), ""); DeterministicKey master = HDKeyDerivation.createMasterPrivateKey(s); DeterministicKey purpose = master.deriveHardened(44); DeterministicKey coinType = purpose.deriveHardened(0); DeterministicKey account = coinType.deriveHardened(0); DeterministicKey external = account.deriveSoftened(0); external.clearPrivateKey(); DeterministicKey key = external.deriveSoftened(0); boolean result = Utils.compareString(address, Utils.toAddress(key.getPubKeyHash())); key.wipe(); return result; }
Example 3
Source File: HDAccountColdUEntropyActivity.java From bither-android with Apache License 2.0 | 4 votes |
@Override public void runWithService(BlockchainService service) { boolean success = false; onProgress(startProgress); try { if (service != null) { service.stopAndUnregister(); } entropyCollector.start(); XRandom xRandom = new XRandom(entropyCollector); if (cancelRunnable != null) { finishGenerate(service); runOnUiThread(cancelRunnable); return; } HDAccountCold hdAccount = new HDAccountCold(MnemonicCode.instance(), xRandom, password); if (cancelRunnable != null) { finishGenerate(service); runOnUiThread(cancelRunnable); return; } words = hdAccount.getSeedWords(password); BackupUtil.backupColdKey(false); onProgress(1); entropyCollector.stop(); success = true; } catch (Exception e) { e.printStackTrace(); } finishGenerate(service); if (success) { while (System.currentTimeMillis() - startGeneratingTime < MinGeneratingTime) { } onProgress(1); onSuccess(HDAccount.HDAccountPlaceHolder); } else { onFailed(); } }
Example 4
Source File: BitpieHDAccountColdUEntropyActivity.java From bither-android with Apache License 2.0 | 4 votes |
@Override public void runWithService(BlockchainService service) { boolean success = false; onProgress(startProgress); try { if (service != null) { service.stopAndUnregister(); } entropyCollector.start(); XRandom xRandom = new XRandom(entropyCollector); if (cancelRunnable != null) { finishGenerate(service); runOnUiThread(cancelRunnable); return; } BitpieHDAccountCold hdAccount = new BitpieHDAccountCold(MnemonicCode.instance(), xRandom, password); if (cancelRunnable != null) { finishGenerate(service); runOnUiThread(cancelRunnable); return; } words = hdAccount.getSeedWords(password); BackupUtil.backupColdKey(false); onProgress(1); entropyCollector.stop(); success = true; } catch (Exception e) { e.printStackTrace(); } finishGenerate(service); if (success) { while (System.currentTimeMillis() - startGeneratingTime < MinGeneratingTime) { } onProgress(1); onSuccess(BitpieHDAccountCold.BitpieHDAccountPlaceHolder); } else { onFailed(); } }
Example 5
Source File: AbstractHD.java From bitherj with Apache License 2.0 | 4 votes |
public static final byte[] seedFromMnemonic(byte[] mnemonicSeed) throws MnemonicException .MnemonicLengthException { MnemonicCode mnemonic = MnemonicCode.instance(); return mnemonic.toSeed(mnemonic.toMnemonic(mnemonicSeed), ""); }
Example 6
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public static final byte[] seedFromMnemonic(byte[] mnemonicSeed) throws MnemonicException .MnemonicLengthException { MnemonicCode mnemonic = MnemonicCode.instance(); return mnemonic.toSeed(mnemonic.toMnemonic(mnemonicSeed), ""); }