diff --git a/.sonarlint/modules/cnc/issues/3/8/3893e371f649cb23d5f6428b3ca5eeae3bd4979f b/.sonarlint/modules/bfclient/issues/4/b/4b8d4ad995cb3950cece8de680eb57ef0fe2921f similarity index 100% rename from .sonarlint/modules/cnc/issues/3/8/3893e371f649cb23d5f6428b3ca5eeae3bd4979f rename to .sonarlint/modules/bfclient/issues/4/b/4b8d4ad995cb3950cece8de680eb57ef0fe2921f diff --git a/.sonarlint/modules/cnc/issues/b/a/ba1dbf788a980366658d348281a337f09d5317fc b/.sonarlint/modules/bfclient/issues/5/9/5995e3430cea453ad68838818ad7fc05c86b119f similarity index 100% rename from .sonarlint/modules/cnc/issues/b/a/ba1dbf788a980366658d348281a337f09d5317fc rename to .sonarlint/modules/bfclient/issues/5/9/5995e3430cea453ad68838818ad7fc05c86b119f diff --git a/.sonarlint/modules/bfclient/issues/b/8/b817598f47e1a616f47ebab74651021b819feb94 b/.sonarlint/modules/bfclient/issues/b/8/b817598f47e1a616f47ebab74651021b819feb94 new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/bfclient/issues/index.pb b/.sonarlint/modules/bfclient/issues/index.pb index 3c08fb3..4066ff5 100644 --- a/.sonarlint/modules/bfclient/issues/index.pb +++ b/.sonarlint/modules/bfclient/issues/index.pb @@ -1,3 +1,9 @@ @ -src/bfclient.cpp,4/6/4680e865da2ad46d274693738207d7b9d80f04ae \ No newline at end of file +src/bfclient.cpp,4/6/4680e865da2ad46d274693738207d7b9d80f04ae +D +src/util/bytestr.cpp,b/8/b817598f47e1a616f47ebab74651021b819feb94 +L +src/bf/libs/ec_pubkey_fast.c,5/9/5995e3430cea453ad68838818ad7fc05c86b119f +K +src/bf/libs/ripemd160_256.c,4/b/4b8d4ad995cb3950cece8de680eb57ef0fe2921f \ No newline at end of file diff --git a/.sonarlint/modules/client/issues/0/7/076b8b4ed34c4da61a1e1eb67e679a86c3a4c0aa b/.sonarlint/modules/client/issues/0/7/076b8b4ed34c4da61a1e1eb67e679a86c3a4c0aa new file mode 100644 index 0000000..677b386 --- /dev/null +++ b/.sonarlint/modules/client/issues/0/7/076b8b4ed34c4da61a1e1eb67e679a86c3a4c0aa @@ -0,0 +1,4 @@ + +f +squid:S106"9Replace this use of System.out or System.err by a logger.(ĿH˜RMAJORZ +CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/client/issues/e/8/e89fbbe78eeb6cfd06a4c707d5f06b23c5422e0e b/.sonarlint/modules/client/issues/e/8/e89fbbe78eeb6cfd06a4c707d5f06b23c5422e0e new file mode 100644 index 0000000..cb5b344 --- /dev/null +++ b/.sonarlint/modules/client/issues/e/8/e89fbbe78eeb6cfd06a4c707d5f06b23c5422e0e @@ -0,0 +1,11 @@ + +m squid:S2095&"DUse try-with-resources or close this "Socket" in a "finally" clause.(HØRBLOCKERZBUG +m squid:S2095"DUse try-with-resources or close this "Socket" in a "finally" clause.(HĘRBLOCKERZBUG +f +squid:S106 "9Replace this use of System.out or System.err by a logger.(ϻHŘRMAJORZ +CODE_SMELL +k +squid:S1061"9Replace this use of System.out or System.err by a logger.(HƘRMAJORZ +CODE_SMELL +i squid:S1854("6Remove this useless assignment to local variable "in".(HǘRMAJORZ +CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/client/issues/index.pb b/.sonarlint/modules/client/issues/index.pb new file mode 100644 index 0000000..b562e53 --- /dev/null +++ b/.sonarlint/modules/client/issues/index.pb @@ -0,0 +1,5 @@ + +J +src/client/CommClient.java,0/7/076b8b4ed34c4da61a1e1eb67e679a86c3a4c0aa +L +src/client/ClientRunner.java,e/8/e89fbbe78eeb6cfd06a4c707d5f06b23c5422e0e \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/1/1/11f0bf66557a5b2474c03cfac7df8258ad7bfab9 b/.sonarlint/modules/cnc/issues/1/1/11f0bf66557a5b2474c03cfac7df8258ad7bfab9 new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/1/3/136c36f2bf1690ff10397e07c3d82baa9b298770 b/.sonarlint/modules/cnc/issues/1/3/136c36f2bf1690ff10397e07c3d82baa9b298770 index e54b106..e69de29 100644 --- a/.sonarlint/modules/cnc/issues/1/3/136c36f2bf1690ff10397e07c3d82baa9b298770 +++ b/.sonarlint/modules/cnc/issues/1/3/136c36f2bf1690ff10397e07c3d82baa9b298770 @@ -1,3 +0,0 @@ - -m squid:S1118":Add a private constructor to hide the implicit public one.(HӕRMAJORZ -CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/3/4/347ab1154aedc2a70c73f64bd3051987dae1332a b/.sonarlint/modules/cnc/issues/3/4/347ab1154aedc2a70c73f64bd3051987dae1332a new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/6/b/6bd08b7785854103940143964721a29b585a0574 b/.sonarlint/modules/cnc/issues/6/b/6bd08b7785854103940143964721a29b585a0574 new file mode 100644 index 0000000..f6b8a96 --- /dev/null +++ b/.sonarlint/modules/cnc/issues/6/b/6bd08b7785854103940143964721a29b585a0574 @@ -0,0 +1,3 @@ + + squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(HӘRCRITICALZ +CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/7/c/7c3c3c10537a28026398df21221528f81672fc33 b/.sonarlint/modules/cnc/issues/7/c/7c3c3c10537a28026398df21221528f81672fc33 deleted file mode 100644 index af235a6..0000000 --- a/.sonarlint/modules/cnc/issues/7/c/7c3c3c10537a28026398df21221528f81672fc33 +++ /dev/null @@ -1,23 +0,0 @@ - - -squid:S135"YReduce the total number of break and continue statements in this loop to use at most one.(рHȕRMINORZ -CODE_SMELL - -squid:S135"YReduce the total number of break and continue statements in this loop to use at most one.(рHɕRMINORZ -CODE_SMELL - squid:S14885"ZImmediately return this expression instead of assigning it to the temporary variable "kr".(HʕRMINORZ -CODE_SMELL -wsquid:HiddenFieldCheck"8Rename "root" which hides the field declared at line 20.(˷H˕RMAJORZ -CODE_SMELL - squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed.(H̕RCRITICALZ -CODE_SMELL - squid:S1149Q"_Replace the synchronized class "StringBuffer" by an unsynchronized one such as "StringBuilder".(H͕RMAJORZ -CODE_SMELL -S squid:S3457#"%String contains no format specifiers.(ϷHΕRMAJORZ -CODE_SMELL -S squid:S3457'"%String contains no format specifiers.(HϕRMAJORZ -CODE_SMELL -Y squid:S3457"%String contains no format specifiers.(HЕRMAJORZ -CODE_SMELL -T squid:S3457"%String contains no format specifiers.(̉HѕRMAJORZ -CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/8/f/8fe1dc8959c76b2c26853ccd55ee1f4bcebcbcfe b/.sonarlint/modules/cnc/issues/8/f/8fe1dc8959c76b2c26853ccd55ee1f4bcebcbcfe new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/9/6/96b215a1323591b6d4c32541aebd0f6c1683b246 b/.sonarlint/modules/cnc/issues/9/6/96b215a1323591b6d4c32541aebd0f6c1683b246 new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/a/b/ab959dedca57b39487a2217383b67b8e1da032f3 b/.sonarlint/modules/cnc/issues/a/b/ab959dedca57b39487a2217383b67b8e1da032f3 new file mode 100644 index 0000000..b47c342 --- /dev/null +++ b/.sonarlint/modules/cnc/issues/a/b/ab959dedca57b39487a2217383b67b8e1da032f3 @@ -0,0 +1,11 @@ + + +squid:S135"YReduce the total number of break and continue statements in this loop to use at most one.(рHRMINORZ +CODE_SMELL + squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed.(HRCRITICALZ +CODE_SMELL + +squid:S135"YReduce the total number of break and continue statements in this loop to use at most one.(рHRMINORZ +CODE_SMELL + squid:S1186"Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(Ԓ8͒,HRCRITICALZ +CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/e/a/ea924abe8ec04d27d8f3757b1f98ec3cf6cf6ff8 b/.sonarlint/modules/cnc/issues/e/a/ea924abe8ec04d27d8f3757b1f98ec3cf6cf6ff8 new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/e/c/ecc7f16c71ca2f68bf6a65ea47837815c0ff6322 b/.sonarlint/modules/cnc/issues/e/c/ecc7f16c71ca2f68bf6a65ea47837815c0ff6322 index fc66e0b..e69de29 100644 --- a/.sonarlint/modules/cnc/issues/e/c/ecc7f16c71ca2f68bf6a65ea47837815c0ff6322 +++ b/.sonarlint/modules/cnc/issues/e/c/ecc7f16c71ca2f68bf6a65ea47837815c0ff6322 @@ -1,3 +0,0 @@ - -squid:UselessImportCheck "QRemove this unused import 'org.btcollider.cnc.keysrv.impl.keytree.KeyTreeServer'.(ֆHRMINORZ -CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/f/4/f451192f21df1ab47fd31c41183e2593ae2a2d27 b/.sonarlint/modules/cnc/issues/f/4/f451192f21df1ab47fd31c41183e2593ae2a2d27 new file mode 100644 index 0000000..e69de29 diff --git a/.sonarlint/modules/cnc/issues/f/b/fb0de740b71d2edb598c4f3deb39da1c59c1ec4f b/.sonarlint/modules/cnc/issues/f/b/fb0de740b71d2edb598c4f3deb39da1c59c1ec4f index 3ab314d..e69de29 100644 --- a/.sonarlint/modules/cnc/issues/f/b/fb0de740b71d2edb598c4f3deb39da1c59c1ec4f +++ b/.sonarlint/modules/cnc/issues/f/b/fb0de740b71d2edb598c4f3deb39da1c59c1ec4f @@ -1,8 +0,0 @@ - -j"squid:SwitchLastCaseIsDefaultChecky""Add a default case to this switch.(HݕRCRITICALZ -CODE_SMELL -X squid:S3457."%String contains no format specifiers.(HߕRMAJORZ -CODE_SMELL -o squid:S2259y"AA "NullPointerException" could be thrown; "suc" is nullable here.(8,HRMAJORZBUG -y squid:S1301y"KReplace this "switch" statement by "if" statements to increase readability.(HޕRMINORZ -CODE_SMELL \ No newline at end of file diff --git a/.sonarlint/modules/cnc/issues/index.pb b/.sonarlint/modules/cnc/issues/index.pb index 1ed4c1b..f705faa 100644 --- a/.sonarlint/modules/cnc/issues/index.pb +++ b/.sonarlint/modules/cnc/issues/index.pb @@ -1,13 +1,15 @@ -g -7src/main/java/org/btcollider/cnc/comm/ClientWorker.java,f/b/fb0de740b71d2edb598c4f3deb39da1c59c1ec4f +l + #include #include +#include #include #include "bf/Brainflyer.h" @@ -17,11 +18,16 @@ using namespace std; #define BATCH_MAX 4096 -#define WIN_SIZE 16 +#define WIN_SIZE 21 -int main() { +int main(int argc, char** argv) { util::bytestr key("db53d9bbd1f3a83b094eeca7dd970bd85b492fa2"); + if (argc < 3) { + cout << "Invalid argument count" << endl; + return (EXIT_FAILURE); + } + cout << "Initializing precomputation table" << endl; // init with window size 16, not reading from file if (secp256k1_ec_pubkey_precomp_table(WIN_SIZE, nullptr) != 0) { @@ -37,7 +43,7 @@ int main() { //numThreads = 1; for (unsigned int i = 0; i < numThreads; i++) { - threads[i] = thread{bf::Brainflyer(i, "127.0.0.1", 26765, key)}; + threads[i] = thread{bf::Brainflyer(i, argv[1], stoi(argv[2]), key)}; } for (unsigned int i = 0; i < numThreads; i++) threads[i].join(); diff --git a/cnc/src/main/java/org/btcollider/cnc/CnC.java b/cnc/src/main/java/org/btcollider/cnc/CnC.java index 66c6ae4..ed1bebc 100644 --- a/cnc/src/main/java/org/btcollider/cnc/CnC.java +++ b/cnc/src/main/java/org/btcollider/cnc/CnC.java @@ -20,7 +20,7 @@ public class CnC { public static final int MAX_BITS = 62; public static void main(String[] args) { - KeyServer kts = KSFactory.build(50, 26, 1, TimeUnit.MINUTES, 0.62f); + KeyServer kts = KSFactory.build(54, 30, 90, TimeUnit.MINUTES, 0.62f); CommServer server = new CommServer(PORT, kts); try { server.listen(); diff --git a/cnc/src/main/java/org/btcollider/cnc/comm/ClientWorker.java b/cnc/src/main/java/org/btcollider/cnc/comm/ClientWorker.java index a56ff1d..ed0a9e3 100644 --- a/cnc/src/main/java/org/btcollider/cnc/comm/ClientWorker.java +++ b/cnc/src/main/java/org/btcollider/cnc/comm/ClientWorker.java @@ -147,7 +147,7 @@ public class ClientWorker implements Runnable { } private void writeKey(String key) { - try (BufferedWriter writer = new BufferedWriter(new FileWriter("/home/armin/Desktop/cwkey"))) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter("~/cwkey"))) { writer.write(key); } catch (IOException e) { log.error("Couldn't write key {} to keyfile", key, e); diff --git a/cnc/src/main/java/org/btcollider/cnc/keysrv/KeyServer.java b/cnc/src/main/java/org/btcollider/cnc/keysrv/KeyServer.java index fb78a7a..ad79762 100644 --- a/cnc/src/main/java/org/btcollider/cnc/keysrv/KeyServer.java +++ b/cnc/src/main/java/org/btcollider/cnc/keysrv/KeyServer.java @@ -1,5 +1,6 @@ package org.btcollider.cnc.keysrv; +import java.io.File; import org.btcollider.cnc.dto.KeyRange; public interface KeyServer { @@ -29,4 +30,13 @@ public interface KeyServer { */ void setSearched(KeyRange keyRange); + /** + * Dumps the state of the keys managed by this KeyServer to a file. A KeyServer must be able to + * read back the status of its keys from its dump file, but not necessarily from other KeyServers. + * + * @param file The file to dump the key state to. Path must exist and must be write-able. Not + * null. + */ + void dump(File file); + } diff --git a/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTree.java b/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTree.java index 9ce83e3..178b5ea 100644 --- a/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTree.java +++ b/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTree.java @@ -79,7 +79,7 @@ public class KeyTree { } public boolean inWork() { - return inWorkSince != -1; + return inWorkSince != -1 && !isSearched(); } public long inWorkSince() { diff --git a/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTreeServer.java b/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTreeServer.java index 146b73c..5c6ce1d 100644 --- a/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTreeServer.java +++ b/cnc/src/main/java/org/btcollider/cnc/keysrv/keytree/KeyTreeServer.java @@ -1,5 +1,6 @@ package org.btcollider.cnc.keysrv.keytree; +import java.io.File; import java.util.BitSet; import java.util.LinkedList; import java.util.Queue; @@ -304,4 +305,9 @@ public class KeyTreeServer implements KeyServer { protected KeyTree getKeyTree() { return this.root; } + + @Override + public void dump(File file) { + + } } diff --git a/cnc/src/main/java/org/btcollider/cnc/keysrv/multistage/MultiStagedServer.java b/cnc/src/main/java/org/btcollider/cnc/keysrv/multistage/MultiStagedServer.java index d34986e..14f7140 100644 --- a/cnc/src/main/java/org/btcollider/cnc/keysrv/multistage/MultiStagedServer.java +++ b/cnc/src/main/java/org/btcollider/cnc/keysrv/multistage/MultiStagedServer.java @@ -1,5 +1,6 @@ package org.btcollider.cnc.keysrv.multistage; +import java.io.File; import org.btcollider.cnc.dto.KeyRange; import org.btcollider.cnc.keysrv.KeyServer; import org.btcollider.cnc.keysrv.keytree.KeyTreeServer; @@ -106,4 +107,9 @@ public class MultiStagedServer implements KeyServer { secKTS.setSearched(secKR); } + @Override + public void dump(File file) { + + } + }