diff --git a/examples/example_13.conf b/examples/example_13.conf
index 4d52827..4c67dd2 100644
--- a/examples/example_13.conf
+++ b/examples/example_13.conf
@@ -1,10 +1,11 @@
POOL
-bc1q0v5q36eaculyrykjnjsyuey6ctd3802ft4jdcc
+# correct seed: brother canal medal remove pitch hill
+1CEC5GLy2HkCWfNRUECsG3Bh3hTumF5yth
#known position, known candidates
6
brother
window master canal cat
?
black master remove cat
-pitch
-hill
\ No newline at end of file
+remove pitch
+cat hill
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e47204a..ead4a63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.pawelgorny
lostword
- 0.13.2
+ 0.13.3
jar
@@ -23,7 +23,7 @@
com.google.guava
guava
- 25.0-jre
+ 30.0-jre
org.slf4j
diff --git a/src/main/java/com/pawelgorny/lostword/Configuration.java b/src/main/java/com/pawelgorny/lostword/Configuration.java
index 55effd3..5392a5b 100644
--- a/src/main/java/com/pawelgorny/lostword/Configuration.java
+++ b/src/main/java/com/pawelgorny/lostword/Configuration.java
@@ -252,4 +252,8 @@ public List getKeyPath() {
public String getEthereumAddress() {
return ethereumAddress;
}
+
+ public String getDerivationPathFull() {
+ return derivationPathFull;
+ }
}
diff --git a/src/main/java/com/pawelgorny/lostword/Worker.java b/src/main/java/com/pawelgorny/lostword/Worker.java
index d8b47c2..08cb84b 100644
--- a/src/main/java/com/pawelgorny/lostword/Worker.java
+++ b/src/main/java/com/pawelgorny/lostword/Worker.java
@@ -12,6 +12,8 @@
import org.bouncycastle.crypto.params.KeyParameter;
import org.web3j.crypto.Keys;
+import java.io.FileWriter;
+import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -27,7 +29,8 @@ public class Worker {
protected static Result RESULT = null;
protected final Configuration configuration;
protected int THREADS = 2;
- protected final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ protected final SimpleDateFormat SDTF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ protected final SimpleDateFormat SDTCF = new SimpleDateFormat("yyyyMMdd_HHmmss");
protected static final int STATUS_PERIOD = 1000 * 60;
protected final HMac SHA_512_DIGEST;
@@ -36,8 +39,11 @@ public class Worker {
private final byte[] BITCOIN_SEED_BYTES = "Bitcoin seed".getBytes();
private final long CREATION_SECONDS = Utils.currentTimeSeconds();
+ private final int CONCAT_LEN_BITS;
+
public Worker(Configuration configuration) {
this.configuration = configuration;
+ this.CONCAT_LEN_BITS = 11 * configuration.getSIZE();
int procs = Runtime.getRuntime().availableProcessors();
if (procs > 1) {
if (procs % 2 == 1) {
@@ -70,7 +76,7 @@ public void run() throws InterruptedException, MnemonicException {
worker = new WorkerPermutation(configuration);
break;
}
- System.out.println("--- Starting worker --- "+SDF.format(new Date())+" ---");
+ System.out.println("--- Starting worker --- "+ SDTF.format(new Date())+" ---");
if (WORK.PERMUTATION.equals(configuration.getWork())){
worker.run();
System.out.println();
@@ -84,8 +90,26 @@ public void run() throws InterruptedException, MnemonicException {
if (RESULT == null) {
System.out.println("Result not found!");
} else {
- System.out.println("Found result!");
+ System.out.println("Result found!");
System.out.println(RESULT.toString());
+ resultToFile();
+ }
+ }
+
+ private void resultToFile() {
+ try {
+ FileWriter fileWriter = new FileWriter(this.configuration.getWork().name() + "_result_" + SDTCF.format(new Date()) + ".txt", false);
+ fileWriter.write(RESULT.toStringFile());
+ if (!configuration.getTargetAddress().isEmpty()){
+ fileWriter.write("\r\n");
+ fileWriter.write(configuration.getTargetAddress());
+ fileWriter.write("\r\n");
+ fileWriter.write(configuration.getDerivationPathFull());
+ }
+ fileWriter.write("\r\n");
+ fileWriter.close();
+ } catch (IOException e) {
+ System.out.println("Cannot write to file: " + e.getLocalizedMessage());
}
}
@@ -163,8 +187,7 @@ protected boolean checksumCheck(final List mnemonic, MessageDigest sha25
}
public boolean checksumCheckBcJ(List words, MessageDigest sha256){
- int concatLenBits = words.size() * 11;
- boolean[] concatBits = new boolean[concatLenBits];
+ boolean[] concatBits = new boolean[CONCAT_LEN_BITS];
int wordindex = 0;
int hash;
@@ -179,8 +202,8 @@ public boolean checksumCheckBcJ(List words, MessageDigest sha256){
}
}
- int var11 = concatLenBits / 33;
- int var12 = concatLenBits - var11;
+ int var11 = CONCAT_LEN_BITS / 33;
+ int var12 = CONCAT_LEN_BITS - var11;
byte[] var13 = new byte[var12 / 8];
for(hash = 0; hash < var13.length; ++hash) {
@@ -287,7 +310,7 @@ protected void processPosition(int position) throws InterruptedException {
for (int bipPosition = 0; RESULT == null && bipPosition < WORDS_TO_WORK.size(); bipPosition++) {
SEED.set(WORKING_POSITION, WORDS_TO_WORK.get(bipPosition));
if (check(SEED, LOCAL_SHA_512_DIGEST, LOCAL_SHA_256_DIGEST)) {
- RESULT = new Result(1 + WORKING_POSITION, WORDS_TO_WORK.get(bipPosition));
+ RESULT = new Result(1 + WORKING_POSITION, WORDS_TO_WORK.get(bipPosition), SEED);
}
}
} catch (Exception e) {
@@ -310,18 +333,31 @@ public Result(List seed){
this.seed = seed;
}
- public Result(int position, String word) {
+ public Result(int position, String word, List seed) {
this.position = position;
this.word = word;
+ this.seed = seed;
}
@Override
public String toString() {
- if (seed==null){
+ if (word!=null && !word.isEmpty()){
return "position=" + position + ", word='" + word + '\'';
}else {
return Utils.SPACE_JOINER.join(seed);
}
}
+
+ public String toStringFile(){
+ if (seed==null){
+ return "position=" + position + ", word='" + word + '\'';
+ }else {
+ String out = Utils.SPACE_JOINER.join(seed);
+ if (word!=null && !word.isEmpty()){
+ out = "position=" + position + ", word='" + word + '\'' + "\r\n" + out;
+ }
+ return out;
+ }
+ }
}
}
diff --git a/src/main/java/com/pawelgorny/lostword/WorkerKnownPosition.java b/src/main/java/com/pawelgorny/lostword/WorkerKnownPosition.java
index 88a1673..9b07a0f 100644
--- a/src/main/java/com/pawelgorny/lostword/WorkerKnownPosition.java
+++ b/src/main/java/com/pawelgorny/lostword/WorkerKnownPosition.java
@@ -72,7 +72,7 @@ private void checkUnknown(int position) throws InterruptedException {
for (int w0=configuration.getKnownStart(); RESULT==null && w0 seed, int depth, int positionStartSe
return;
}
if (reporter && (System.currentTimeMillis()-start > STATUS_PERIOD)){
- System.out.println(SDF.format(new Date())+ " Alive!");
+ System.out.println(SDTF.format(new Date())+ " Alive!");
start = System.currentTimeMillis();
}
}else{
diff --git a/src/main/java/com/pawelgorny/lostword/WorkerPermutation.java b/src/main/java/com/pawelgorny/lostword/WorkerPermutation.java
index d64d5be..cfe7f62 100644
--- a/src/main/java/com/pawelgorny/lostword/WorkerPermutation.java
+++ b/src/main/java/com/pawelgorny/lostword/WorkerPermutation.java
@@ -24,7 +24,7 @@ public WorkerPermutation(Configuration configuration) {
}catch (Exception e){
System.out.println(e.getLocalizedMessage());
}
- fileName = "PERMUTATATIONS_"+(System.currentTimeMillis())+".txt";
+ fileName = "PERMUTATIONS_"+(System.currentTimeMillis())+".txt";
System.out.println("Saving to file: "+fileName);
}
diff --git a/src/main/java/com/pawelgorny/lostword/WorkerPermutationCheck.java b/src/main/java/com/pawelgorny/lostword/WorkerPermutationCheck.java
index f2413c7..42415e3 100644
--- a/src/main/java/com/pawelgorny/lostword/WorkerPermutationCheck.java
+++ b/src/main/java/com/pawelgorny/lostword/WorkerPermutationCheck.java
@@ -63,7 +63,7 @@ private boolean checkElements(String[] input) {
System.out.println(e.getLocalizedMessage());
}
if (System.currentTimeMillis()-start > STATUS_PERIOD){
- System.out.println(SDF.format(new Date())+ " Alive!");
+ System.out.println(SDTF.format(new Date())+ " Alive!");
start = System.currentTimeMillis();
}
return (RESULT!=null);
diff --git a/src/main/java/com/pawelgorny/lostword/WorkerPool.java b/src/main/java/com/pawelgorny/lostword/WorkerPool.java
index 8458038..6a6ac67 100644
--- a/src/main/java/com/pawelgorny/lostword/WorkerPool.java
+++ b/src/main/java/com/pawelgorny/lostword/WorkerPool.java
@@ -46,6 +46,9 @@ private void check() throws MnemonicException, InterruptedException {
private void checkUnknown(int position) throws InterruptedException {
List mnemonic = new ArrayList<>(configuration.getWORDS());
int nextPosition = getNextUnknown(1+position, configuration.getWORDS());
+ if (nextPosition == -1){
+ nextPosition = position;
+ }
List> DICTIONARY = split(configuration.getWORDS_POOL().get(nextPosition));
final List SHA_256_DIGESTS= new ArrayList<>(THREADS);
@@ -60,7 +63,7 @@ private void checkUnknown(int position) throws InterruptedException {
int DIC_SIZE = configuration.getWORDS_POOL().get(position).size();
for (int w0=0; RESULT==null && w0 seed, int depth, int positionStartSe
return;
}
if (reporter && (System.currentTimeMillis()-start > STATUS_PERIOD)){
- System.out.println(SDF.format(new Date())+ " Alive!");
+ System.out.println(SDTF.format(new Date())+ " Alive!");
start = System.currentTimeMillis();
}
}else{