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


Java ECKey.isEncrypted方法代码示例

本文整理汇总了Java中org.bitcoinj.core.ECKey.isEncrypted方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.isEncrypted方法的具体用法?Java ECKey.isEncrypted怎么用?Java ECKey.isEncrypted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bitcoinj.core.ECKey的用法示例。


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

示例1: maybeDecrypt

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
@Nullable
private ECKey maybeDecrypt(ECKey key) {
    if (key == null)
        return null;
    else if (key.isEncrypted()) {
        if (aesKey == null)
            throw new ECKey.KeyIsEncryptedException();
        return key.decrypt(aesKey);
    } else {
        return key;
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:13,代码来源:DecryptingKeyBag.java

示例2: checkKeyEncryptionStateMatches

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
private void checkKeyEncryptionStateMatches(ECKey key) {
    if (keyCrypter == null && key.isEncrypted())
        throw new KeyCrypterException("Key is encrypted but chain is not");
    else if (keyCrypter != null && !key.isEncrypted())
        throw new KeyCrypterException("Key is not encrypted but chain is");
    else if (keyCrypter != null && key.getKeyCrypter() != null && !key.getKeyCrypter().equals(keyCrypter))
        throw new KeyCrypterException("Key encrypted under different parameters to chain");
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:9,代码来源:BasicKeyChain.java

示例3: checkAESKey

import org.bitcoinj.core.ECKey; //导入方法依赖的package包/类
/**
 * Check whether the AES key can decrypt the first encrypted key in the wallet.
 *
 * @return true if AES key supplied can decrypt the first encrypted private key in the wallet, false otherwise.
 */
@Override
public boolean checkAESKey(KeyParameter aesKey) {
    lock.lock();
    try {
        // If no keys then cannot decrypt.
        if (hashToKeys.isEmpty()) return false;
        checkState(keyCrypter != null, "Key chain is not encrypted");

        // Find the first encrypted key in the wallet.
        ECKey first = null;
        for (ECKey key : hashToKeys.values()) {
            if (key.isEncrypted()) {
                first = key;
                break;
            }
        }
        checkState(first != null, "No encrypted keys in the wallet");

        try {
            ECKey rebornKey = first.decrypt(aesKey);
            return Arrays.equals(first.getPubKey(), rebornKey.getPubKey());
        } catch (KeyCrypterException e) {
            // The AES key supplied is incorrect.
            return false;
        }
    } finally {
        lock.unlock();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:35,代码来源:BasicKeyChain.java


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