From ab86a1f0c3b86050e65fc5b7ac1e88a00f0d228c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 27 Jan 2020 21:25:39 +0100 Subject: Encrypted channels --- src/channel.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/channel.h (limited to 'src/channel.h') diff --git a/src/channel.h b/src/channel.h new file mode 100644 index 0000000..100003c --- /dev/null +++ b/src/channel.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +#include "identity.h" + +namespace erebos { + +struct ChannelRequestData +{ + Ref store(const Storage & st) const; + static optional load(const Ref &); + + const vector>> peers; + const Stored key; +}; + +typedef Signed ChannelRequest; + +struct ChannelAcceptData +{ + Ref store(const Storage & st) const; + static optional load(const Ref &); + + Stored channel() const; + + const Stored request; + const Stored key; +}; + +typedef Signed ChannelAccept; + +class Channel +{ +public: + Channel(const vector>> & peers, + vector && key): + peers(peers), + key(std::move(key)) + {} + + Ref store(const Storage & st) const; + static optional load(const Ref &); + + static Stored generateRequest(const Storage &, + const Identity & self, const Identity & peer); + static optional> acceptRequest(const Identity & self, + const Identity & peer, const Stored & request); + + vector encrypt(const vector &) const; + optional> decrypt(const vector &) const; + +private: + const vector>> peers; + const vector key; +}; + +} -- cgit v1.2.3