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


Java KeyCrypterScrypt.SALT_LENGTH属性代码示例

本文整理汇总了Java中com.google.bitcoin.crypto.KeyCrypterScrypt.SALT_LENGTH属性的典型用法代码示例。如果您正苦于以下问题:Java KeyCrypterScrypt.SALT_LENGTH属性的具体用法?Java KeyCrypterScrypt.SALT_LENGTH怎么用?Java KeyCrypterScrypt.SALT_LENGTH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.bitcoin.crypto.KeyCrypterScrypt的用法示例。


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

示例1: setUp

@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,代码行数:17,代码来源:WalletTest.java

示例2: setUp

@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:praus,项目名称:multicoinj,代码行数:22,代码来源:WalletTest.java

示例3: setUp

@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,代码行数:12,代码来源:ECKeyTest.java

示例4: encryptionDecryptionHomogenousKeys

@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,代码行数:37,代码来源:WalletTest.java

示例5: setPasscode

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,代码行数:39,代码来源:WalletUtil.java

示例6: setUp

@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,代码行数:12,代码来源:MainPrivKeyShareTest.java


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