Java Code Examples for net.bither.bitherj.utils.PrivateKeyUtil#getECKeyFromSingleString()
The following examples show how to use
net.bither.bitherj.utils.PrivateKeyUtil#getECKeyFromSingleString() .
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: BackupUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) { File file = FileUtil.getBackupFile(); String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr.substring(strArray[0] .length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } return null; }
Example 2
Source File: BackupUtil.java From bither-android with Apache License 2.0 | 6 votes |
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) { File file = FileUtil.getBackupKeyOfHot(); String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr.substring(strArray[0] .length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } return null; }
Example 3
Source File: ImportPrivateKey.java From bitherj with Apache License 2.0 | 6 votes |
private ECKey getEckey() { ECKey ecKey = null; DumpedPrivateKey dumpedPrivateKey = null; try { switch (this.importPrivateKeyType) { case Text: dumpedPrivateKey = new DumpedPrivateKey(this.content); ecKey = dumpedPrivateKey.getKey(); break; case BitherQrcode: ecKey = PrivateKeyUtil.getECKeyFromSingleString(content, password); break; case Bip38: dumpedPrivateKey = new DumpedPrivateKey(this.content); ecKey = dumpedPrivateKey.getKey(); break; } } catch (Exception e) { e.printStackTrace(); } finally { if (dumpedPrivateKey != null) { dumpedPrivateKey.clearPrivateKey(); } } return ecKey; }
Example 4
Source File: Address.java From bitherj with Apache License 2.0 | 6 votes |
public List<byte[]> signHashes(List<byte[]> unsignedInHashes, CharSequence passphrase) throws PasswordException { ECKey key = PrivateKeyUtil.getECKeyFromSingleString(this.getFullEncryptPrivKey(), passphrase); if (key == null) { throw new PasswordException("do not decrypt eckey"); } KeyParameter assKey = key.getKeyCrypter().deriveKey(passphrase); List<byte[]> result = new ArrayList<byte[]>(); for (byte[] unsignedInHash : unsignedInHashes) { TransactionSignature signature = new TransactionSignature(key.sign(unsignedInHash, assKey), TransactionSignature.SigHash.ALL, false); result.add(ScriptBuilder.createInputScript(signature, key).getProgram()); } key.clearPrivateKey(); return result; }
Example 5
Source File: BackupUtil.java From bither-desktop-java with Apache License 2.0 | 6 votes |
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) { File file = FileUtil.getBackupFile(); String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr.substring(strArray[0] .length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } return null; }
Example 6
Source File: BackupUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) { try { File[] files = FileUtil.getBackupDir().listFiles(); if (files == null) { return null; } files = FileUtil.orderByDateDesc(files); for (int i = files.length - 1; i >= 0; i++) { File file = files[i]; String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr .substring(strArray[0].length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 7
Source File: BackupUtil.java From bither-android with Apache License 2.0 | 5 votes |
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) { if (!FileUtil.existSdCardMounted()) { return null; } try { File[] files = FileUtil.getBackupSdCardDir().listFiles(); if (files == null) { return null; } files = FileUtil.orderByDateDesc(files); for (int i = files.length - 1; i >= 0; i++) { File file = files[i]; String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr .substring(strArray[0].length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 8
Source File: PasswordSeed.java From bitherj with Apache License 2.0 | 5 votes |
public boolean checkPassword(CharSequence password) { ECKey ecKey = PrivateKeyUtil.getECKeyFromSingleString(keyStr, password); String ecKeyAddress; if (ecKey == null) { return false; } else { ecKeyAddress = ecKey.toAddress(); ecKey.clearPrivateKey(); } return Utils.compareString(this.address, ecKeyAddress); }
Example 9
Source File: BackupUtil.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private static ECKey getEckeyFormBackupCold(String address, CharSequence password) { try { File[] files = FileUtil.getBackupDir().listFiles(); if (files == null) { return null; } files = FileUtil.orderByDateDesc(files); for (int i = files.length - 1; i >= 0; i++) { File file = files[i]; String str = Utils.readFile(file); if (str.contains(address)) { String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING); for (String backupStr : backupStrArray) { if (backupStr.contains(address)) { String[] strArray = QRCodeUtil.splitString(backupStr); if (strArray.length > 3) { String keyString = backupStr .substring(strArray[0].length() + 1); return PrivateKeyUtil.getECKeyFromSingleString( keyString, password); } } } } } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 10
Source File: PasswordSeed.java From bitherj with Apache License 2.0 | 4 votes |
public ECKey getECKey(CharSequence password) { return PrivateKeyUtil.getECKeyFromSingleString(keyStr, password); }
Example 11
Source File: Address.java From bitherj with Apache License 2.0 | 4 votes |
public String signMessage(String msg, CharSequence passphrase) { ECKey key = PrivateKeyUtil.getECKeyFromSingleString(this.getFullEncryptPrivKey(), passphrase); if (key == null) { throw new PasswordException("do not decrypt eckey"); } KeyParameter assKey = key.getKeyCrypter().deriveKey(passphrase); String result = key.signMessage(msg, assKey); key.clearPrivateKey(); return result; }