2018-07-09 19:32:11 +02:00
|
|
|
#ifndef LLARP_SERVICE_IDENTITY_HPP
|
|
|
|
#define LLARP_SERVICE_IDENTITY_HPP
|
|
|
|
#include <llarp/bencode.hpp>
|
|
|
|
#include <llarp/crypto.hpp>
|
|
|
|
#include <llarp/service/Info.hpp>
|
|
|
|
#include <llarp/service/IntroSet.hpp>
|
|
|
|
#include <llarp/service/types.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
// private keys
|
|
|
|
struct Identity : public llarp::IBEncodeMessage
|
|
|
|
{
|
|
|
|
llarp::SecretKey enckey;
|
|
|
|
llarp::SecretKey signkey;
|
2018-08-14 01:22:31 +02:00
|
|
|
llarp::PQKeyPair pq;
|
2018-07-09 19:32:11 +02:00
|
|
|
uint64_t version = 0;
|
|
|
|
VanityNonce vanity;
|
|
|
|
|
|
|
|
// public service info
|
|
|
|
ServiceInfo pub;
|
|
|
|
|
|
|
|
~Identity();
|
|
|
|
|
|
|
|
// regenerate secret keys
|
|
|
|
void
|
|
|
|
RegenerateKeys(llarp_crypto* c);
|
|
|
|
|
|
|
|
// load from file
|
|
|
|
bool
|
|
|
|
LoadFromFile(const std::string& fpath);
|
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
EnsureKeys(const std::string& fpath, llarp_crypto* c);
|
|
|
|
|
2018-08-14 01:22:31 +02:00
|
|
|
bool
|
|
|
|
KeyExchange(llarp_path_dh_func dh, byte_t* sharedkey,
|
|
|
|
const ServiceInfo& other, const byte_t* N) const;
|
|
|
|
|
2018-07-09 19:32:11 +02:00
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
|
|
|
|
|
|
|
bool
|
2018-10-29 17:48:36 +01:00
|
|
|
SignIntroSet(IntroSet& i, llarp_crypto* c, llarp_time_t now) const;
|
2018-08-14 01:22:31 +02:00
|
|
|
|
|
|
|
bool
|
|
|
|
Sign(llarp_crypto*, byte_t* sig, llarp_buffer_t buf) const;
|
2018-07-09 19:32:11 +02:00
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|