-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMasterKeys.java
More file actions
43 lines (30 loc) · 1.04 KB
/
MasterKeys.java
File metadata and controls
43 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main;
public class MasterKeys {
public MasterKeys()
{
} // end func
static private String normalizeText(String mytext) {
// Clean up extra whitespace.
// regex delimiter here is anything that's not a word
String[] words = mytext.split("\\W+");
String delimiter = " ";
mytext = String.join(delimiter, words);
return mytext.toLowerCase();
}
static public byte[] get_seed_from_mnemonic(String mnemonic) {
// Gets a byte array of the bip32 root "seed"
// from the electrum mnemonic phrase.
String salt = "electrum";
int iterations = 2048;
mnemonic = normalizeText(mnemonic);
byte[] saltBytes = salt.getBytes();
byte[] mnemonicBytes = mnemonic.getBytes();
byte[] seedBytes = PBKDF2.hmac("SHA512", mnemonicBytes, saltBytes, iterations);
return seedBytes;
}
// -------------------DEBUGGING MOSTLY OR DISPLAY READABLE TO
// USER-----------------------
public static String get_hex_version_of_seed(byte[] seedBytes) {
return Util.bytesToHex(seedBytes);
}
} // end class