vanity.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <iostream>
  3. #include <fstream>
  4. #include <stdlib.h>
  5. #include <openssl/rand.h>
  6. #include "Crypto.h"
  7. #include "Identity.h"
  8. #include "I2PEndian.h"
  9. #include "common/key.hpp"
  10. #include <thread>
  11. #include <unistd.h>
  12. #include <vector>
  13. #ifdef _WIN32
  14. #include <windows.h>
  15. #endif
  16. // sha256
  17. #define Ch(x, y, z) ((x & (y ^ z)) ^ z)
  18. #define Maj(x, y, z) ((x & (y | z)) | (y & z))
  19. #define SHR(x, n) (x >> n)
  20. #define ROTR(x, n) ((x >> n) | (x << (32 - n)))
  21. #define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  22. #define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  23. #define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
  24. #define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
  25. #define RND(a, b, c, d, e, f, g, h, k) \
  26. t0 = h + S1(e) + Ch(e, f, g) + k; \
  27. t1 = S0(a) + Maj(a, b, c); \
  28. d += t0; \
  29. h = t0 + t1;
  30. #define RNDr(S, W, i, k) \
  31. RND(S[(64 - i) % 8], S[(65 - i) % 8], \
  32. S[(66 - i) % 8], S[(67 - i) % 8], \
  33. S[(68 - i) % 8], S[(69 - i) % 8], \
  34. S[(70 - i) % 8], S[(71 - i) % 8], \
  35. W[i] + k)
  36. #define DEF_OUTNAME "private.dat"
  37. //static i2p::data::SigningKeyType type;
  38. //static i2p::data::PrivateKeys keys;
  39. static bool found=false;
  40. static size_t MutateByte;
  41. static uint32_t FoundNonce=0;
  42. static uint8_t * KeyBuf;
  43. //static uint8_t * PaddingBuf;
  44. static unsigned long long hashescounter;
  45. unsigned int count_cpu;
  46. const uint8_t lastBlock[64] =
  47. {
  48. 0x05, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x80, // 7 bytes EdDSA certificate
  49. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  50. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  51. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  52. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  53. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  54. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  55. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x38 // 3128 bits (391 bytes)
  56. };