本文整理汇总了Java中org.bitcoinj.crypto.KeyCrypter.deriveKey方法的典型用法代码示例。如果您正苦于以下问题:Java KeyCrypter.deriveKey方法的具体用法?Java KeyCrypter.deriveKey怎么用?Java KeyCrypter.deriveKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.crypto.KeyCrypter
的用法示例。
在下文中一共展示了KeyCrypter.deriveKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toEncrypted
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
@Override
public SimpleHDKeyChain toEncrypted(CharSequence password) {
checkNotNull(password, "Attempt to encrypt with a null password.");
checkArgument(password.length() > 0, "Attempt to encrypt with an empty password.");
checkState(!rootKey.isEncrypted(), "Attempt to encrypt a root key that is already encrypted.");
checkState(!rootKey.isPubKeyOnly(), "Attempt to encrypt a watching chain.");
KeyCrypter scrypt = new KeyCrypterScrypt();
KeyParameter derivedKey = scrypt.deriveKey(password);
return toEncrypted(scrypt, derivedKey);
}
示例2: toDecrypted
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
@Override
public SimpleHDKeyChain toDecrypted(CharSequence password) {
checkNotNull(password, "Attempt to decrypt with a null password.");
checkArgument(password.length() > 0, "Attempt to decrypt with an empty password.");
KeyCrypter crypter = getKeyCrypter();
checkState(crypter != null, "Chain not encrypted");
KeyParameter derivedKey = crypter.deriveKey(password);
return toDecrypted(derivedKey);
}
示例3: toEncrypted
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
@Override
public NxtFamilyKey toEncrypted(CharSequence password) {
checkNotNull(password, "Attempt to encrypt with a null password.");
checkArgument(password.length() > 0, "Attempt to encrypt with an empty password.");
checkState(!entropy.isEncrypted(), "Attempt to encrypt a key that is already encrypted.");
KeyCrypter scrypt = new KeyCrypterScrypt();
KeyParameter derivedKey = scrypt.deriveKey(password);
return toEncrypted(scrypt, derivedKey);
}
示例4: toDecrypted
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
@Override
public NxtFamilyKey toDecrypted(CharSequence password) {
checkNotNull(password, "Attempt to decrypt with a null password.");
checkArgument(password.length() > 0, "Attempt to decrypt with an empty password.");
KeyCrypter crypter = getKeyCrypter();
checkState(crypter != null, "Chain not encrypted");
KeyParameter derivedKey = crypter.deriveKey(password);
return toDecrypted(derivedKey);
}
示例5: getKeyFromPassword
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
/**
* Get a key parameter derived from the given password. This only works if
* the wallet is, or previously has been, encrypted.
*
* @param password the password to derive an AES key from.
* @return the derived AES key.
* @throws IllegalStateException if the wallet is not encrypted
*/
public KeyParameter getKeyFromPassword(String password) throws IllegalStateException {
final KeyCrypter keyCrypter = wallet().getKeyCrypter();
if (keyCrypter != null) {
return keyCrypter.deriveKey(password);
} else {
throw new IllegalStateException("Wallet does not have a key crypter.");
}
}
示例6: doInBackground
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
@Override
protected Exception doInBackground(Void... params) {
Wallet wallet = application.getWallet();
if (wallet == null) return new NoSuchPocketException("No wallet found.");
try {
if (sourceAccount != null) {
if (wallet.isEncrypted()) {
KeyCrypter crypter = Preconditions.checkNotNull(wallet.getKeyCrypter());
request.aesKey = crypter.deriveKey(password);
}
request.signTransaction = true;
sourceAccount.completeAndSignTx(request);
}
// Before broadcasting, check if there is an error, like the trade expiration
if (error != null) throw error;
if (sourceAccount != null) {
if (!sourceAccount.broadcastTxSync(request.tx)) {
throw new Exception("Error broadcasting transaction: " + request.tx.getHashAsString());
}
} else {
// TODO handle better
WalletAccount account =
wallet.getAccounts(request.tx.getSentTo().get(0).getAddress()).get(0);
if (!account.broadcastTxSync(request.tx)) {
throw new Exception("Error broadcasting transaction: " + request.tx.getHashAsString());
}
}
transactionBroadcast = true;
if (isExchangeNeeded() && tradeDepositAddress != null && tradeDepositAmount != null) {
exchangeEntry = new ExchangeHistoryProvider.ExchangeEntry(tradeDepositAddress,
tradeDepositAmount, request.tx.getHashAsString());
Uri uri = ExchangeHistoryProvider.contentUri(application.getPackageName(),
tradeDepositAddress);
contentResolver.insert(uri, exchangeEntry.getContentValues());
}
handler.sendEmptyMessage(STOP_TRADE_TIMEOUT);
}
catch (Exception e) { error = e; }
return error;
}
示例7: KeyChainGroup
import org.bitcoinj.crypto.KeyCrypter; //导入方法依赖的package包/类
/**
* ALICE
* Creates a keychain group with no basic chain, and an HD chain initialized from the given seed and rootNodeList
* The KeyChainGroup is encrypted sing the crypter and password
*
* */
public KeyChainGroup(NetworkParameters params, DeterministicSeed seed, ImmutableList<ChildNumber> rootNodeList, CharSequence password, KeyCrypter crypter) {
this(params, null, ImmutableList.of(new DeterministicKeyChain(seed, rootNodeList)), null, null, 1, null);
KeyParameter aesKey = crypter.deriveKey(password);
this.encrypt(crypter, aesKey, rootNodeList);
}