2018-06-23 00:00:44 +00:00
|
|
|
#ifndef LLARP_SERVICE_HPP
|
|
|
|
#define LLARP_SERVICE_HPP
|
|
|
|
#include <llarp/aligned.hpp>
|
|
|
|
#include <llarp/bencode.hpp>
|
|
|
|
#include <llarp/crypto.hpp>
|
2018-06-29 14:25:09 +00:00
|
|
|
#include <llarp/path_types.hpp>
|
|
|
|
|
|
|
|
#include <set>
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
/// hidden service address
|
|
|
|
typedef llarp::AlignedBuffer< 32 > Address;
|
|
|
|
|
|
|
|
typedef llarp::AlignedBuffer< 16 > VanityNonce;
|
|
|
|
|
2018-07-05 15:44:06 +00:00
|
|
|
struct ServiceInfo : public llarp::IBEncodeMessage
|
2018-06-23 00:00:44 +00:00
|
|
|
{
|
|
|
|
llarp::PubKey enckey;
|
|
|
|
llarp::PubKey signkey;
|
|
|
|
uint64_t version = 0;
|
|
|
|
VanityNonce vanity;
|
|
|
|
|
2018-07-05 15:44:06 +00:00
|
|
|
~ServiceInfo();
|
|
|
|
|
2018-06-23 00:00:44 +00:00
|
|
|
/// calculate our address
|
|
|
|
void
|
2018-06-29 14:25:09 +00:00
|
|
|
CalculateAddress(Address& addr) const;
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
|
|
|
};
|
|
|
|
|
|
|
|
// private keys
|
|
|
|
struct Identity : public llarp::IBEncodeMessage
|
|
|
|
{
|
|
|
|
llarp::SecretKey enckey;
|
|
|
|
llarp::SecretKey signkey;
|
|
|
|
uint64_t version = 0;
|
|
|
|
VanityNonce vanity;
|
|
|
|
|
|
|
|
// public service info
|
2018-07-05 15:44:06 +00:00
|
|
|
ServiceInfo pub;
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
// regenerate secret keys
|
|
|
|
void
|
|
|
|
RegenerateKeys(llarp_crypto* c);
|
|
|
|
|
|
|
|
// load from file
|
|
|
|
bool
|
|
|
|
LoadFromFile(const std::string& fpath);
|
2018-06-29 14:25:09 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Introduction : public llarp::IBEncodeMessage
|
|
|
|
{
|
|
|
|
llarp::PubKey router;
|
|
|
|
llarp::PathID_t pathID;
|
|
|
|
uint64_t version = 0;
|
|
|
|
uint64_t expiresAt;
|
|
|
|
|
2018-07-05 15:44:06 +00:00
|
|
|
~Introduction()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-06-29 14:25:09 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IntroSet : public llarp::IBEncodeMessage
|
|
|
|
{
|
2018-07-05 15:44:06 +00:00
|
|
|
ServiceInfo A;
|
2018-06-29 14:25:09 +00:00
|
|
|
std::set< Introduction > I;
|
|
|
|
llarp::Signature Z;
|
2018-07-05 15:44:06 +00:00
|
|
|
|
|
|
|
~IntroSet();
|
|
|
|
|
|
|
|
bool
|
|
|
|
BDecode(llarp_buffer_t* buf);
|
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
2018-06-23 00:00:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|