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


Java KeyCrypter.deriveKey方法代码示例

本文整理汇总了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);
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:11,代码来源:SimpleHDKeyChain.java

示例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);
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:10,代码来源:SimpleHDKeyChain.java

示例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);
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:10,代码来源:NxtFamilyKey.java

示例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);
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:10,代码来源:NxtFamilyKey.java

示例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.");
    }
}
 
开发者ID:rnicoll,项目名称:cate,代码行数:17,代码来源:Network.java

示例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;
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:45,代码来源:MakeTransactionFragment.java

示例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);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:12,代码来源:KeyChainGroup.java


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