blob: c3d9e2cb5d30801a9c8381fcdc00d32a3e015e1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#pragma once
#include <erebos/identity.h>
#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 &);
Ref store(const Storage & st) const;
const vector<Stored<Signed<IdentityData>>> prev;
const optional<string> name;
const optional<Stored<Signed<IdentityData>>> owner;
const Stored<PublicKey> keyIdentity;
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<StoredIdentityPart> data;
vector<StoredIdentityPart> updates;
shared_future<optional<string>> name;
optional<Identity> owner;
Stored<PublicKey> keyMessage;
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
{
Storage storage;
vector<Stored<Signed<IdentityData>>> prev = {};
optional<string> name = nullopt;
optional<Identity> owner = nullopt;
Stored<PublicKey> keyIdentity;
optional<Stored<PublicKey>> keyMessage;
};
}
|