lokinet/llarp/service/identity.hpp
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00

71 lines
1.6 KiB
C++

#pragma once
#include <llarp/config/key_manager.hpp>
#include <llarp/constants/proto.hpp>
#include <llarp/crypto/types.hpp>
#include <memory>
#include "info.hpp"
#include "intro_set.hpp"
#include "vanity.hpp"
#include <llarp/util/buffer.hpp>
#include <tuple>
namespace llarp
{
namespace service
{
// private keys
struct Identity
{
SecretKey enckey;
SecretKey signkey;
PrivateKey derivedSignKey;
PQKeyPair pq;
uint64_t version = LLARP_PROTO_VERSION;
VanityNonce vanity;
// public service info
ServiceInfo pub;
// regenerate secret keys
void
RegenerateKeys();
bool
BEncode(llarp_buffer_t* buf) const;
/// @param needBackup determines whether existing keys will be cycled
void
EnsureKeys(fs::path fpath, bool needBackup);
bool
KeyExchange(
path_dh_func dh,
SharedSecret& sharedkey,
const ServiceInfo& other,
const KeyExchangeNonce& N) const;
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf);
std::optional<EncryptedIntroSet>
EncryptAndSignIntroSet(const IntroSet& i, llarp_time_t now) const;
bool
Sign(Signature& sig, const llarp_buffer_t& buf) const;
/// zero out all secret key members
void
Clear();
};
inline bool
operator==(const Identity& lhs, const Identity& rhs)
{
return std::tie(lhs.enckey, lhs.signkey, lhs.pq, lhs.version, lhs.vanity)
== std::tie(rhs.enckey, rhs.signkey, rhs.pq, rhs.version, rhs.vanity);
}
} // namespace service
} // namespace llarp