static byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; secureRandom().nextBytes(bytes); return bytes; } }
@Test public void testIsNotAndroidRuntime() { assertFalse(isAndroidRuntime()); } }
/** * Create a keypair using SECP-256k1 curve. * * <p>Private keypairs are encoded using PKCS8 * * <p>Private keys are encoded using X.509 */ static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { return createSecp256k1KeyPair(secureRandom()); }
public static ECKeyPair createEcKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { return createEcKeyPair(secureRandom()); }
@Test public void testSecureRandom() { secureRandom().nextInt(); }
/** * Generates a BIP-44 compatible Ethereum wallet on top of BIP-39 generated seed. * * @param password Will be used for both wallet encryption and passphrase for BIP-39 seed * @param destinationDirectory The directory containing the wallet * @param testNet should use the testNet derive path * @return A BIP-39 compatible Ethereum wallet * @throws CipherException if the underlying cipher is not available * @throws IOException if the destination cannot be written to */ public static Bip39Wallet generateBip44Wallet(String password, File destinationDirectory, boolean testNet) throws CipherException, IOException { byte[] initialEntropy = new byte[16]; SecureRandomUtils.secureRandom().nextBytes(initialEntropy); String mnemonic = MnemonicUtils.generateMnemonic(initialEntropy); byte[] seed = MnemonicUtils.generateSeed(mnemonic, null); Bip32ECKeyPair masterKeypair = Bip32ECKeyPair.generateKeyPair(seed); Bip32ECKeyPair bip44Keypair = generateBip44KeyPair(masterKeypair, testNet); String walletFile = generateWalletFile(password, bip44Keypair, destinationDirectory, false); return new Bip39Wallet(walletFile, mnemonic); }
/** * Create a keypair using SECP-256k1 curve. * * <p>Private keypairs are encoded using PKCS8 * * <p>Private keys are encoded using X.509 */ static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { return createSecp256k1KeyPair(secureRandom()); }
public static ECKeyPair createEcKeyPair() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { return createEcKeyPair(secureRandom()); }