本文整理汇总了Java中com.google.bitcoin.crypto.KeyCrypterScrypt类的典型用法代码示例。如果您正苦于以下问题:Java KeyCrypterScrypt类的具体用法?Java KeyCrypterScrypt怎么用?Java KeyCrypterScrypt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyCrypterScrypt类属于com.google.bitcoin.crypto包,在下文中一共展示了KeyCrypterScrypt类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
keyCrypter = new KeyCrypterScrypt(scryptParameters);
encryptedWallet = new Wallet(params, keyCrypter);
aesKey = keyCrypter.deriveKey(PASSWORD1);
wrongAesKey = keyCrypter.deriveKey(WRONG_PASSWORD);
ECKey myEncryptedKey = encryptedWallet.addNewEncryptedKey(keyCrypter, aesKey);
myEncryptedAddress = myEncryptedKey.toAddress(params);
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:18,代码来源:WalletTest.java
示例2: setUp
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
keyCrypter = new KeyCrypterScrypt(scryptParameters);
encryptedWallet = new Wallet(params, keyCrypter);
encryptedMixedWallet = new Wallet(params, keyCrypter);
aesKey = keyCrypter.deriveKey(PASSWORD1);
wrongAesKey = keyCrypter.deriveKey(WRONG_PASSWORD);
ECKey myEncryptedKey = encryptedWallet.addNewEncryptedKey(keyCrypter, aesKey);
myEncryptedAddress = myEncryptedKey.toAddress(params);
encryptedMixedWallet.addKey(new ECKey());
ECKey myEncryptedKey2 = encryptedMixedWallet.addNewEncryptedKey(keyCrypter, aesKey);
myEncryptedAddress2 = myEncryptedKey2.toAddress(params);
}
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:23,代码来源:WalletTest.java
示例3: encrypt
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
/**
* Convenience wrapper around {@link Wallet#encrypt(com.google.bitcoin.crypto.KeyCrypter,
* org.spongycastle.crypto.params.KeyParameter)} which uses the default Scrypt key derivation algorithm and
* parameters, derives a key from the given password and returns the created key.
*/
public KeyParameter encrypt(CharSequence password) {
checkNotNull(password);
checkArgument(password.length() > 0);
KeyCrypter scrypt = new KeyCrypterScrypt();
KeyParameter derivedKey = scrypt.deriveKey(password);
encrypt(scrypt, derivedKey);
return derivedKey;
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:14,代码来源:Wallet.java
示例4: setUp
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
secureRandom = new SecureRandom();
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
keyCrypter = new KeyCrypterScrypt(scryptParameters);
BriefLogFormatter.init();
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:13,代码来源:ECKeyTest.java
示例5: encryptionDecryptionHomogenousKeys
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
@Test
public void encryptionDecryptionHomogenousKeys() throws Exception {
// Check the wallet is currently encrypted
assertTrue("Wallet is not an encrypted wallet", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);
// Try added an ECKey that was encrypted with a differenct ScryptParameters (i.e. a non-homogenous key).
// This is not allowed as the ScryptParameters is stored at the Wallet level.
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
KeyCrypter keyCrypterDifferent = new KeyCrypterScrypt(scryptParameters);
ECKey ecKeyDifferent = new ECKey();
ecKeyDifferent = ecKeyDifferent.encrypt(keyCrypterDifferent, aesKey);
Iterable<ECKey> keys = encryptedWallet.getKeys();
Iterator iterator = keys.iterator();
boolean oneKey = iterator.hasNext();
iterator.next();
assertTrue("Wrong number of keys in wallet before key addition", oneKey && !iterator.hasNext());
try {
encryptedWallet.addKey(ecKeyDifferent);
fail("AddKey should have thrown an EncrypterDecrypterException but did not.");
} catch (KeyCrypterException ede) {
// Expected behaviour.
}
keys = encryptedWallet.getKeys();
iterator = keys.iterator();
oneKey = iterator.hasNext();
iterator.next();
assertTrue("Wrong number of keys in wallet after key addition", oneKey && !iterator.hasNext());
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:38,代码来源:WalletTest.java
示例6: setPasscode
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
public static void setPasscode(Context context,
WalletService walletService,
String passcode,
boolean isChange) {
WalletApplication wallapp =
(WalletApplication) context.getApplicationContext();
KeyParameter oldAesKey = wallapp.mAesKey;
mLogger.info("setPasscode starting");
byte[] salt;
if (isChange) {
// Reuse our salt (better chance of recovering if
// we are between passcode values).
salt = readSalt(context);
} else {
// Create salt and write to file.
SecureRandom secureRandom = new SecureRandom();
salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
writeSalt(context, salt);
}
KeyCrypter keyCrypter = getKeyCrypter(salt);
KeyParameter aesKey = keyCrypter.deriveKey(passcode);
if (isChange) {
walletService.changePasscode(oldAesKey, keyCrypter, aesKey);
}
// Set up the application context with credentials.
wallapp.mPasscode = passcode;
wallapp.mKeyCrypter = keyCrypter;
wallapp.mAesKey = aesKey;
mLogger.info("setPasscode finished");
}
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:40,代码来源:WalletUtil.java
示例7: getKeyCrypter
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
public static KeyCrypter getKeyCrypter(byte[] salt) {
Protos.ScryptParameters.Builder scryptParametersBuilder =
Protos.ScryptParameters.newBuilder()
.setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
return new KeyCrypterScrypt(scryptParameters);
}
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:8,代码来源:WalletUtil.java
示例8: setUp
import com.google.bitcoin.crypto.KeyCrypterScrypt; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
SecureRandom secureRandom = new SecureRandom();
byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
secureRandom.nextBytes(salt);
Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters
.newBuilder().setSalt(ByteString.copyFrom(salt));
ScryptParameters scryptParameters = scryptParametersBuilder.build();
keyCrypter = new KeyCrypterScrypt(scryptParameters);
}
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:13,代码来源:MainPrivKeyShareTest.java
注:本文中的com.google.bitcoin.crypto.KeyCrypterScrypt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论