Browse Source

Merge pull request #72 from acetoneRu/master

many bit corrections
pull/78/head
orignal 3 years ago committed by GitHub
parent
commit
644df5b4ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      README.md
  2. 2
      keygen.cpp
  3. 35
      vanitygen.cpp

21
README.md

@ -47,7 +47,7 @@ print iptables firewall rules to allow 1 nodes in netdb through firewall includi
### keygen ### keygen
Generate an i2p private key Generate an I2P private key
#### Usage #### Usage
@ -76,6 +76,9 @@ or
| EDDSA-SHA512-ED25519 | 7 | | EDDSA-SHA512-ED25519 | 7 |
| GOSTR3410_CRYPTO_PRO_A-GOSTR3411-256 | 9 | | GOSTR3410_CRYPTO_PRO_A-GOSTR3411-256 | 9 |
| GOSTR3410_TC26_A_512-GOSTR3411-512 | 10 | | GOSTR3410_TC26_A_512-GOSTR3411-512 | 10 |
| RED25519-SHA512 | 11 |
For more information on the types of signatures, see the [documentation](https://i2pd.readthedocs.io/en/latest/user-guide/tunnels/#signature-types).
### vain ### vain
@ -88,17 +91,17 @@ Vanity generation address.
#### Time to Generate on a 2.70GHz Processor #### Time to Generate on a 2.70GHz Processor
| characters| time to generate (approx.) | | characters| time to generate (approx.) |
| -------------------- | --------------- | | -------------------- | --------------- |
| 1 | ~0.082s | | 1 | ~0.082s |
| 2 | ~0.075s | | 2 | ~0.075s |
| 3 | ~0.100s | | 3 | ~0.100s |
| 4 | ~0.394s | | 4 | ~0.394s |
| 5 | ~6.343s | | 5 | ~6.343s |
| 6 | ~1m-5m | | 6 | ~1m-5m |
| 7 | ~30m | | 7 | ~30m |
### keyinfo ### keyinfo
Prints information about an i2p private key Prints information about an I2P private key
#### Usage #### Usage

2
keygen.cpp

@ -17,6 +17,7 @@ int main (int argc, char * argv[])
if (argc > 2) { if (argc > 2) {
std::string str(argv[2]); std::string str(argv[2]);
type = NameToSigType(str); type = NameToSigType(str);
if (SigTypeToName(type).find("unknown") != std::string::npos) { std::cerr << "Incorrect signature type" << std::endl; return -2; }
} }
auto keys = i2p::data::PrivateKeys::CreateRandomKeys (type); auto keys = i2p::data::PrivateKeys::CreateRandomKeys (type);
std::ofstream f (argv[1], std::ofstream::binary | std::ofstream::out); std::ofstream f (argv[1], std::ofstream::binary | std::ofstream::out);
@ -28,6 +29,7 @@ int main (int argc, char * argv[])
f.write ((char *)buf, len); f.write ((char *)buf, len);
delete[] buf; delete[] buf;
std::cout << "Destination " << keys.GetPublic ()->GetIdentHash ().ToBase32 () << " created" << std::endl; std::cout << "Destination " << keys.GetPublic ()->GetIdentHash ().ToBase32 () << " created" << std::endl;
std::cout << "Signature type: " << SigTypeToName(type) << " (" << type << ")" << std::endl;
} }
else else
std::cout << "Can't create file " << argv[1] << std::endl; std::cout << "Can't create file " << argv[1] << std::endl;

35
vanitygen.cpp

@ -1,6 +1,7 @@
#include "vanity.hpp" #include "vanity.hpp"
#include<regex> #include <regex>
#include<getopt.h> #include <mutex>
#include <getopt.h>
static struct static struct
@ -10,8 +11,17 @@ static struct
i2p::data::SigningKeyType signature; i2p::data::SigningKeyType signature;
std::string outputpath=""; std::string outputpath="";
std::regex regex; std::regex regex;
bool sig_type = true;
} options; } options;
void check_sig_type()
{
if (SigTypeToName(options.signature).find("unknown") != std::string::npos)
{
std::cerr << "Incorrect signature type" << std::endl;
options.sig_type = false;
}
}
static void inline CalculateW (const uint8_t block[64], uint32_t W[64]) static void inline CalculateW (const uint8_t block[64], uint32_t W[64])
{ {
@ -124,6 +134,7 @@ static inline bool NotThat(const char * a, const char *b)
return false; return false;
} }
std::mutex mtx;
static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread, unsigned long long throughput) static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread, unsigned long long throughput)
{ {
/** /**
@ -131,7 +142,9 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
* For idea and example ^-^ * For idea and example ^-^
* Orignal is sensei of crypto ;) * Orignal is sensei of crypto ;)
*/ */
mtx.lock();
std::cout << "Thread " << id_thread << " binded" << std::endl; std::cout << "Thread " << id_thread << " binded" << std::endl;
mtx.unlock();
/* /*
union union
{ {
@ -187,7 +200,7 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
// if(result) // if(result)
{ {
ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52); ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52);
std::cout << "Address found " << addr << " in " << id_thread << std::endl; std::cout << "Address found " << addr << std::endl;
found=true; found=true;
FoundNonce=*nonce; FoundNonce=*nonce;
// free(hash); // free(hash);
@ -210,13 +223,11 @@ static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread
void usage(void){ void usage(void){
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n" const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n"
"-h --help, help menu\n" "-h --help help menu\n"
"-r --reg, regexp instead just text pattern (e.g. '(one|two).*')\n" "-r --reg regexp instead just text pattern (e.g. '(one|two).*')\n"
"--threads -t, (default count of system)\n" "-t --threads (default count of system)\n"
"--signature -s, (signature type)\n" // "--signature -s, (signature type)\n" NOT IMPLEMENTED FUCKING PLAZ!
"-o --output output file (default private.dat)\n" "-o --output output file (default private.dat)\n"
"--usage usage\n"
// "--prefix -p\n"
""; "";
puts(help); puts(help);
} }
@ -253,6 +264,7 @@ void parsing(int argc, char ** args){
break; break;
case 's': case 's':
options.signature = NameToSigType(std::string(optarg)); options.signature = NameToSigType(std::string(optarg));
check_sig_type();
break; break;
case 'o': case 'o':
options.outputpath=optarg; options.outputpath=optarg;
@ -302,6 +314,7 @@ int main (int argc, char * argv[])
/////////////// ///////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!options.sig_type) return -2;
auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature); auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature);
switch(options.signature) switch(options.signature)
{ {
@ -311,7 +324,7 @@ int main (int argc, char * argv[])
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096: case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512: case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
std::cout << "Sorry, i don't can generate address for this signature type" << std::endl; std::cout << "Sorry, I don't can generate address for this signature type" << std::endl;
return 0; return 0;
break; break;
} }

Loading…
Cancel
Save