Java Code Examples for jota.utils.SeedRandomGenerator#generateNewSeed()

The following examples show how to use jota.utils.SeedRandomGenerator#generateNewSeed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public void createWallet2(String passphrase, Runnable callback) {
    final String generatedSeed = SeedRandomGenerator.generateNewSeed();
    String addr = generateFirstAddress(generatedSeed);
    sharedManager.setLastSyncedBlock(Coders.encodeBase64(generatedSeed));
    mnemonicKey = generatedSeed;
    walletFriendlyAddress = addr;
    callback.run();
}
 
Example 2
Source File: SeedLoginFragment.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
@OnClick(R.id.seed_login_generate_seed)
public void onSeedLoginGenerateSeedClick() {
    final String generatedSeed = SeedRandomGenerator.generateNewSeed();
    seedEditText.setText(generatedSeed);
    Bundle bundle = new Bundle();
    bundle.putString("generatedSeed", generatedSeed);
    CopySeedDialog dialog = new CopySeedDialog();
    dialog.setArguments(bundle);
    dialog.show(getFragmentManager(), null);
}
 
Example 3
Source File: KeyfileBuilder.java    From private-iota-testnet with MIT License 4 votes vote down vote up
public static void main(String[] args) throws Exception {
	if (args.length < 4) {
		System.out.println("Usage: KeyfileBuilder <keyfile> <security> <algorithm> <pubkeyDepth> [[<firstIndex>] <pubkeyCount>]");
		return;
	}
	final String filename = args[0];
	final int security = Integer.parseInt(args[1]);
	SpongeFactory.Mode algorithm = SpongeFactory.Mode.valueOf(args[2]);
	final int pubkeyDepth = Integer.parseInt(args[3]);
	final int firstIndex, pubkeyCount;
	if (args.length == 4) {
		firstIndex = 0;
		pubkeyCount = 1 << pubkeyDepth;
	} else if (args.length == 5) {
		firstIndex = 0;
		pubkeyCount = Integer.parseInt(args[4]);
	} else {
		firstIndex = Integer.parseInt(args[4]);
		pubkeyCount = Integer.parseInt(args[5]);
	}
	final String seed = SeedRandomGenerator.generateNewSeed();
	System.out.println("Seed: " + seed);
	ICurl curl = SpongeFactory.create(algorithm);
	try (BufferedWriter bw = new BufferedWriter(new FileWriter(filename))) {
		bw.write(pubkeyDepth + " " + seed);
		bw.newLine();
		String[] keys = new String[1 << pubkeyDepth];
		for (int i = 0; i < pubkeyCount; i++) {
			int idx = firstIndex + i;
			System.out.println("Generating subkey " + idx);
			keys[idx] = CurlSigning.newAddress(seed, security, idx, false, curl);
		}
		writeKeys(bw, keys);
		int[] trits = new int[243];
		while (keys.length > 1) {
			String[] nextKeys = new String[keys.length / 2];
			for (int i = 0; i < nextKeys.length; i++) {
				if (keys[i * 2] == null && keys[i * 2 + 1] == null) {
					// leave the combined key null as well
					continue;
				}
				curl.reset();
				String k1 = keys[i * 2], k2 = keys[i * 2 + 1];
				Converter.copyTrits(k1 == null ? NULL_ADDRESS : k1, trits);
				curl.absorb(trits);
				Converter.copyTrits(k2 == null ? NULL_ADDRESS : k2, trits);
				curl.absorb(trits);
				curl.squeeze(trits, 0, trits.length);
				nextKeys[i] = Converter.trytes(trits);
			}
			keys = nextKeys;
			writeKeys(bw, keys);
		}
		System.out.println("Public key: " + keys[0]);
		System.out.println("Keyfile created.");
	}
}