diff --git a/.gitignore b/.gitignore index 264051e..458e1c3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ i2pbase64 regaddr routerinfo vain +b33address +offlinekeys +regaddr_3ld # private key files *.dat diff --git a/Makefile b/Makefile index 75ee3f4..84743bf 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ OBJECTS = $(SOURCES:.cpp=.o) I2PD_LIB = libi2pd.a -all: keygen keyinfo famtool routerinfo regaddr regaddr_3ld vain i2pbase64 offlinekeys +all: keygen keyinfo famtool routerinfo regaddr regaddr_3ld vain i2pbase64 offlinekeys b33address routerinfo: $(OBJECTS) $(CXX) -o routerinfo routerinfo.o $(LDFLAGS) $(LIBS) @@ -73,6 +73,9 @@ i2pbase64: $(OBJECTS) offlinekeys: $(OBJECTS) $(CXX) -o offlinekeys offlinekeys.o $(LDFLAGS) $(LIBS) +b33address: $(OBJECTS) + $(CXX) -o b33address b33address.o $(LDFLAGS) $(LIBS) + $(OBJECTS): libi2pd.a .SUFFIXES: @@ -94,7 +97,7 @@ clean-obj: rm -f $(OBJECTS) clean-bin: - rm -f keyinfo keygen famtool regaddr regaddr_3ld routerinfo i2pbase64 vain offlinekeys + rm -f keyinfo keygen famtool regaddr regaddr_3ld routerinfo i2pbase64 vain offlinekeys b33address clean: clean-i2pd clean-obj clean-bin diff --git a/b33address.cpp b/b33address.cpp new file mode 100644 index 0000000..554b793 --- /dev/null +++ b/b33address.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include "Identity.h" +#include "LeaseSet.h" +#include "common/key.hpp" + +int main(int argc, char * argv[]) +{ + // base64 input, b33 and store key output, 11->11 only + std::string base64; + std::getline (std::cin, base64); + auto ident = std::make_shared(); + if (ident->FromBase64 (base64)) + { + if (ident->GetSigningKeyType () == i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519) + { + i2p::data::BlindedPublicKey blindedKey (ident, i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519); + std::cout << "b33 address: " << blindedKey.ToB33 () << ".b32.i2p" << std::endl; + std::cout << "Today's store hash: " << blindedKey.GetStoreHash ().ToBase64 () << std::endl; + } + else + std::cout << "Invalid signature type " << SigTypeToName (ident->GetSigningKeyType ()) << std::endl; + } + else + std::cout << "Invalid base64 address" << std::endl; + + return 0; +} + diff --git a/common/key.hpp b/common/key.hpp index bc49fa3..53f77a1 100644 --- a/common/key.hpp +++ b/common/key.hpp @@ -50,7 +50,7 @@ static void ToUpper(std::string & str) /** @brief returns the signing key number given its name or -1 if there is no key of that type */ uint16_t NameToSigType(const std::string & keyname) { - if(keyname.size() == 1) return atoi(keyname.c_str()); + if(keyname.size() <= 2) return atoi(keyname.c_str()); std::string name = keyname; ToUpper(name); diff --git a/i2pd b/i2pd index ff44bcc..c4c896a 160000 --- a/i2pd +++ b/i2pd @@ -1 +1 @@ -Subproject commit ff44bcc489f8a881214a1dfe522231372a0a970b +Subproject commit c4c896a833d006f308f35d31ed006e82a3b769f2