当前位置: 首页>>代码示例>>Java>>正文


Java PrivateKeyUtil类代码示例

本文整理汇总了Java中net.bither.bitherj.utils.PrivateKeyUtil的典型用法代码示例。如果您正苦于以下问题:Java PrivateKeyUtil类的具体用法?Java PrivateKeyUtil怎么用?Java PrivateKeyUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrivateKeyUtil类属于net.bither.bitherj.utils包,在下文中一共展示了PrivateKeyUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEckeyFormBackupHot

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
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;
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:20,代码来源:BackupUtil.java

示例2: backupPrivateKey

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
private void backupPrivateKey() {
    File file = FileUtil.getBackupFile();

    String backupString = PrivateKeyUtil.getBackupPrivateKeyStr();


    if (!Utils.isEmpty(backupString)) {

        try {
            Utils.writeFile(backupString.getBytes(), file);
            UserPreference.getInstance().setLastBackupKeyTime(
                    new Date(System.currentTimeMillis()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:19,代码来源:BackupUtil.java

示例3: addPrivateKeyByRandomWithPassphras

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
public static List<Address> addPrivateKeyByRandomWithPassphras(IUEntropy iuEntropy, CharSequence password, int count) {
    PeerUtil.stopPeer();
    List<Address> addressList = new ArrayList<Address>();
    for (int i = 0; i < count; i++) {
        XRandom xRandom = new XRandom(iuEntropy);
        ECKey ecKey = ECKey.generateECKey(xRandom);
        ecKey = PrivateKeyUtil.encrypt(ecKey, password);
        Address address = new Address(ecKey.toAddress(),
                ecKey.getPubKey(), PrivateKeyUtil.getEncryptedString(ecKey), ecKey.isFromXRandom());
        ecKey.clearPrivateKey();
        addressList.add(address);
        AddressManager.getInstance().addAddress(address);

    }
    PeerUtil.startPeer();
    if (UserPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) {
        BackupUtil.backupColdKey(false);
    } else {
        BackupUtil.backupHotKey();
    }

    return addressList;

}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:25,代码来源:KeyUtil.java

示例4: verifyMessage

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
/**
 * Verify the message text against the address specified and update UI
 */
private void verifyMessage() {
    String addressText = WhitespaceTrimmer.trim(verifyingAddress.getText().trim());
    String messageText = messageTextArea.getText().trim();
    String signatureText = signatureTextArea.getText().trim();
    if (Utils.isEmpty(addressText) || Utils.isEmpty(messageText) || Utils.isEmpty(signatureText)) {
        new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_failed")).showMsg();
    } else {
        boolean isVerify = PrivateKeyUtil.verifyMessage(addressText, messageText, signatureText);
        if (isVerify) {
            new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_success")).showMsg();
        } else {
            new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_failed")).showMsg();
        }
    }
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:19,代码来源:VerifyMessagePanel.java

示例5: getEckeyFormBackupHot

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
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;
}
 
开发者ID:bither,项目名称:bither-android,代码行数:20,代码来源:BackupUtil.java

示例6: backupPrivateKey

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
private void backupPrivateKey() {
    File file;
    if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.HOT) {
        file = FileUtil.getBackupKeyOfHot();
    } else {
        file = FileUtil.getBackupFileOfCold();
    }
    String backupString = PrivateKeyUtil.getBackupPrivateKeyStr();

    if (!Utils.isEmpty(backupString)) {
        try {
            Utils.writeFile(backupString.getBytes(), file);
            AppSharedPreference.getInstance().setLastBackupKeyTime(
                    new Date(System.currentTimeMillis()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
 
开发者ID:bither,项目名称:bither-android,代码行数:21,代码来源:BackupUtil.java

示例7: getEckey

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
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;
}
 
开发者ID:bither,项目名称:bitherj,代码行数:27,代码来源:ImportPrivateKey.java

示例8: signHashes

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
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;
}
 
开发者ID:bither,项目名称:bitherj,代码行数:17,代码来源:Address.java

示例9: getEckeyFormBackupCold

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
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;

    }
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:35,代码来源:BackupUtil.java

示例10: getBackupKeyStrList

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
public static String[] getBackupKeyStrList(File file) {
    String keyStrs = Utils.readFile(file);
    String[] result = null;
    if (!Utils.isEmpty(keyStrs)) {
        result = keyStrs.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
    }
    return result;
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:9,代码来源:BackupUtil.java

示例11: initCheckForPrivateKey

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
public static Check initCheckForPrivateKey(
        final Address address, final SecureCharSequence password) {
    String title = String.format(LocaliserUtils.getString("check_address_private_key_title"), address
            .getShortAddress());
    Check check = new Check(title, new ICheckAction() {

        @Override
        public boolean check() {
            boolean result = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKey()).checkPassword(password);
            if (!result) {
                try {
                    ECKey eckeyFromBackup = BackupUtil.getEckeyFromBackup(
                            address.getAddress(), password);
                    if (eckeyFromBackup != null) {
                        String encryptPrivateKey = PrivateKeyUtil.getEncryptedString(eckeyFromBackup);
                        if (!Utils.isEmpty(encryptPrivateKey)) {
                            address.recoverFromBackup(encryptPrivateKey);
                            result = true;
                        }
                        eckeyFromBackup.clearPrivateKey();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    password.wipe();
                }


            }
            return result;
        }
    });
    return check;
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:35,代码来源:CheckUtil.java

示例12: run

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
public void run() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {

        }
    });
    List<Address> addressList = PrivateKeyUtil.getECKeysFromBackupString(content, password);
    HDMKeychain hdmKeychain = PrivateKeyUtil.getHDMKeychain(content, password);

    if ((addressList == null || addressList.size() == 0) && (hdmKeychain == null)) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                dp.dispose();
                new MessageDialog(LocaliserUtils.getString("clone_from_failed")).showMsg();
            }
        });
        return;
    }

    KeyUtil.addAddressListByDesc(addressList);
    if (hdmKeychain != null) {
        KeyUtil.setHDKeyChain(hdmKeychain);
    }
    password.wipe();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            dp.dispose();
            new MessageDialog(LocaliserUtils.getString("clone_from_success")).showMsg();
            closePanel();
            Bither.refreshFrame();
        }
    });
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:38,代码来源:ImportPrivateKeyPanel.java

示例13: showPrivateKeyQRCode

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
private void showPrivateKeyQRCode(SecureCharSequence password) {
    final SecureCharSequence str = PrivateKeyUtil.getDecryptPrivateKeyString(Bither.getActionAddress().getFullEncryptPrivKey(), password);
    password.wipe();
    DisplayQRCodePanle displayQRCodePanle = new DisplayQRCodePanle(str.toString());
    displayQRCodePanle.showPanel();


}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:9,代码来源:ExportPrivateKeyPanel.java

示例14: showPrivateText

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
private void showPrivateText(SecureCharSequence password) {

        final SecureCharSequence str = PrivateKeyUtil.getDecryptPrivateKeyString(Bither.getActionAddress().getFullEncryptPrivKey(), password);
        password.wipe();
        PrivateTextPanel privateTextPanel = new PrivateTextPanel(str);
        privateTextPanel.showPanel();

    }
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:9,代码来源:ExportPrivateKeyPanel.java

示例15: onClick

import net.bither.bitherj.utils.PrivateKeyUtil; //导入依赖的package包/类
@Override
public void onClick(View v) {
    new DialogPassword(getActivity(), new IDialogPasswordListener() {
        @Override
        public void onPasswordEntered(SecureCharSequence password) {
            password.wipe();
            String content = PrivateKeyUtil.getEncryptPrivateKeyStringFromAllAddresses();
            Intent intent = new Intent(getActivity(), BitherQRCodeActivity.class);
            intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING,
                    getString(R.string.clone_to_title));
            intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING, content);
            startActivity(intent);
        }
    }).show();
}
 
开发者ID:bither,项目名称:bither-android,代码行数:16,代码来源:OptionColdFragment.java


注:本文中的net.bither.bitherj.utils.PrivateKeyUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。