本文整理汇总了Java中org.bitcoinj.core.ECKey.decrypt方法的典型用法代码示例。如果您正苦于以下问题:Java ECKey.decrypt方法的具体用法?Java ECKey.decrypt怎么用?Java ECKey.decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.ECKey
的用法示例。
在下文中一共展示了ECKey.decrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: 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();
}
}