lokinet/llarp/service/Identity.hpp

61 lines
1.3 KiB
C++
Raw Normal View History

2018-07-09 17:32:11 +00:00
#ifndef LLARP_SERVICE_IDENTITY_HPP
#define LLARP_SERVICE_IDENTITY_HPP
2018-12-12 02:15:08 +00:00
#include <crypto/types.hpp>
2018-12-12 02:15:08 +00:00
#include <service/Info.hpp>
#include <service/IntroSet.hpp>
#include <service/types.hpp>
#include <util/bencode.hpp>
2018-07-09 17:32:11 +00:00
namespace llarp
{
struct Crypto;
2018-07-09 17:32:11 +00:00
namespace service
{
// private keys
struct Identity final : public llarp::IBEncodeMessage
2018-07-09 17:32:11 +00:00
{
llarp::SecretKey enckey;
llarp::SecretKey signkey;
llarp::PQKeyPair pq;
2018-07-09 17:32:11 +00:00
uint64_t version = 0;
VanityNonce vanity;
// public service info
ServiceInfo pub;
~Identity();
// regenerate secret keys
void
RegenerateKeys(llarp::Crypto* c);
2018-07-09 17:32:11 +00:00
// load from file
bool
LoadFromFile(const std::string& fpath);
bool
BEncode(llarp_buffer_t* buf) const override;
2018-07-09 17:32:11 +00:00
bool
EnsureKeys(const std::string& fpath, llarp::Crypto* c);
2018-07-09 17:32:11 +00:00
bool
KeyExchange(llarp::path_dh_func dh, SharedSecret& sharedkey,
const ServiceInfo& other, const KeyExchangeNonce& N) const;
2018-07-09 17:32:11 +00:00
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
2018-07-09 17:32:11 +00:00
bool
SignIntroSet(IntroSet& i, llarp::Crypto* c, llarp_time_t now) const;
bool
Sign(llarp::Crypto*, Signature& sig, llarp_buffer_t buf) const;
2018-07-09 17:32:11 +00:00
};
} // namespace service
} // namespace llarp
#endif