SimpleYggGen.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <openssl/bn.h>
  2. #include <openssl/evp.h>
  3. #include <openssl/sha.h>
  4. #include <string.h>
  5. #ifdef __linux__
  6. #include <arpa/inet.h>
  7. #include <sys/socket.h>
  8. #include <sys/types.h>
  9. #else
  10. #include <winsock2.h>
  11. #endif
  12. #include <fstream>
  13. #include <getopt.h>
  14. #include <iomanip>
  15. #include <iostream>
  16. #include <random>
  17. #include <regex>
  18. #include <sstream>
  19. #include <thread>
  20. #include <vector>
  21. #include <bitset>
  22. #define KEYSIZE 32
  23. #define NAMEPROGRAM "SimpleYggGen"
  24. #define COAUTHORS "lialh4, orignal, i2pd-project."
  25. //to inline?
  26. #define ADDKEYS(to, from, ipv6){ \
  27. memcpy(to.sk, from.PrivateKey, sizeof(from.PrivateKey)); \
  28. memcpy(to.pk, from.PublicKey, sizeof(from.PublicKey));\
  29. to.ip =std::string(ipv6);}
  30. constexpr auto defaultHighSearchFileName = "syg-highsearch.txt";
  31. constexpr auto defaultSearchFileName = "syg-search.txt"; //(reg)
  32. typedef struct {
  33. uint8_t PublicKey[KEYSIZE];
  34. uint8_t PrivateKey[KEYSIZE];
  35. // unsigned char PublicKey[crypto_box_PUBLICKEYBYTES];
  36. // unsigned char PrivateKey[crypto_box_SECRETKEYBYTES];
  37. } BoxKeys;
  38. enum class ProgramMode { high, search };
  39. struct dataKey {
  40. uint8_t pk[KEYSIZE];
  41. uint8_t sk[KEYSIZE];
  42. std::string ip;
  43. };
  44. BoxKeys getKeyPair(void);
  45. void getSHA512(void *data, unsigned char *hash);
  46. void convertSHA512ToSum(unsigned char hash[SHA512_DIGEST_LENGTH],
  47. char outputBuffer[128]);
  48. char *convertSHA512ToIPv6(unsigned char hash[SHA512_DIGEST_LENGTH],
  49. BoxKeys keys);
  50. int miner(void);