summaryrefslogtreecommitdiff
path: root/src/identity.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-10-29 21:51:17 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-11-28 21:53:03 +0100
commit648ca7febe4f09c663386ee2ea610d8ab150e053 (patch)
tree9df441afa677ea678fb200f6f2ee93fc07d51814 /src/identity.h
parent9ae77b5a3accd7bd4fd3c529a1567279fda95004 (diff)
Identity extension data
Diffstat (limited to 'src/identity.h')
-rw-r--r--src/identity.h58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/identity.h b/src/identity.h
index 4b61c66..c3d9e2c 100644
--- a/src/identity.h
+++ b/src/identity.h
@@ -4,15 +4,48 @@
#include "pubkey.h"
#include <future>
+#include <variant>
using std::function;
using std::optional;
using std::shared_future;
using std::string;
+using std::variant;
using std::vector;
namespace erebos {
+struct IdentityData;
+struct IdentityExtension;
+
+struct StoredIdentityPart
+{
+ using Part = variant<
+ Stored<Signed<IdentityData>>,
+ Stored<Signed<IdentityExtension>>>;
+
+ StoredIdentityPart(Part p): part(move(p)) {}
+
+ static StoredIdentityPart load(const Ref &);
+ Ref store(const Storage & st) const;
+
+ bool operator==(const StoredIdentityPart & other) const
+ { return part == other.part; }
+ bool operator<(const StoredIdentityPart & other) const
+ { return part < other.part; }
+
+ const Ref & ref() const;
+ const Stored<Signed<IdentityData>> & base() const;
+
+ vector<StoredIdentityPart> previous() const;
+ vector<Digest> roots() const;
+ optional<string> name() const;
+ optional<StoredIdentityPart> owner() const;
+ bool isSignedBy(const Stored<PublicKey> &) const;
+
+ Part part;
+};
+
struct IdentityData
{
static IdentityData load(const Ref &);
@@ -25,19 +58,30 @@ struct IdentityData
const optional<Stored<PublicKey>> keyMessage;
};
+struct IdentityExtension
+{
+ static IdentityExtension load(const Ref &);
+ Ref store(const Storage & st) const;
+
+ const Stored<Signed<IdentityData>> base;
+ const vector<StoredIdentityPart> prev;
+ const optional<string> name;
+ const optional<StoredIdentityPart> owner;
+};
+
struct Identity::Priv
{
- vector<Stored<Signed<IdentityData>>> data;
- vector<Stored<Signed<IdentityData>>> updates;
+ vector<StoredIdentityPart> data;
+ vector<StoredIdentityPart> updates;
shared_future<optional<string>> name;
optional<Identity> owner;
Stored<PublicKey> keyMessage;
- static bool verifySignatures(const Stored<Signed<IdentityData>> & sdata);
- static shared_ptr<Priv> validate(const vector<Stored<Signed<IdentityData>>> & sdata);
- static optional<Stored<IdentityData>> lookupProperty(
- const vector<Stored<Signed<IdentityData>>> & data,
- function<bool(const IdentityData &)> sel);
+ static bool verifySignatures(const StoredIdentityPart & sdata);
+ static shared_ptr<Priv> validate(const vector<StoredIdentityPart> & sdata);
+ static optional<StoredIdentityPart> lookupProperty(
+ const vector<StoredIdentityPart> & data,
+ function<bool(const StoredIdentityPart &)> sel);
};
struct Identity::Builder::Priv