summaryrefslogtreecommitdiff
path: root/src/identity.h
blob: 98db80aa28c0e1fe839ecbf0ac9f158a2842b28f (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
#pragma once

#include <erebos/identity.h>
#include "pubkey.h"

using std::function;
using std::optional;
using std::string;
using std::vector;

namespace erebos {

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 Identity::Priv
{
	vector<Stored<Signed<IdentityData>>> data;
	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);
};

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;
};

}