CCF
Loading...
Searching...
No Matches
network_identity_interface.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
7#include "ccf/tx_id.h"
8
9#include <exception>
10#include <map>
11#include <optional>
12#include <string>
13#include <vector>
14
15namespace ccf
16{
17 struct NetworkIdentity;
18
20 using RawCoseEndorsement = std::vector<uint8_t>;
22 using CoseEndorsementsChain = std::vector<RawCoseEndorsement>;
23
25 enum class FetchStatus : uint8_t
26 {
27 Retry,
28 Done,
29 Failed
30 };
31
34 using TrustedKeys = std::map<ccf::SeqNo, ccf::crypto::ECPublicKeyPtr>;
35
38 struct IdentityHistoryNotFetched : public std::exception
39 {
40 std::string msg;
41
42 IdentityHistoryNotFetched(std::string msg) : msg(std::move(msg)) {}
43
44 [[nodiscard]] const char* what() const noexcept override
45 {
46 return msg.c_str();
47 }
48 };
49
53 {
54 public:
56
57 static char const* get_subsystem_name()
58 {
59 return "NetworkIdentity";
60 }
61
63 virtual const std::unique_ptr<NetworkIdentity>& get() = 0;
64
66 [[nodiscard]] virtual FetchStatus endorsements_fetching_status() const = 0;
67
74 [[nodiscard]] virtual std::optional<CoseEndorsementsChain>
76
86 ccf::SeqNo seqno) const = 0;
87
93 [[nodiscard]] virtual TrustedKeys get_trusted_keys() const = 0;
94 };
95}
Definition node_subsystem_interface.h:8
Definition network_identity_interface.h:53
virtual const std::unique_ptr< NetworkIdentity > & get()=0
Returns a reference to the current network identity.
virtual FetchStatus endorsements_fetching_status() const =0
Returns the current status of endorsement fetching.
virtual ccf::crypto::ECPublicKeyPtr get_trusted_identity_for(ccf::SeqNo seqno) const =0
virtual TrustedKeys get_trusted_keys() const =0
static char const * get_subsystem_name()
Definition network_identity_interface.h:57
virtual std::optional< CoseEndorsementsChain > get_cose_endorsements_chain(ccf::SeqNo seqno) const =0
~NetworkIdentitySubsystemInterface() override=default
std::shared_ptr< ECPublicKey > ECPublicKeyPtr
Definition ec_public_key.h:158
Definition app_interface.h:13
FetchStatus
Status of the network identity endorsement fetching process.
Definition network_identity_interface.h:26
@ Retry
Fetching should be retried.
@ Failed
Fetching failed.
@ Done
Fetching completed successfully.
std::map< ccf::SeqNo, ccf::crypto::ECPublicKeyPtr > TrustedKeys
Definition network_identity_interface.h:34
std::vector< RawCoseEndorsement > CoseEndorsementsChain
An ordered chain of raw COSE endorsements.
Definition network_identity_interface.h:22
uint64_t SeqNo
Definition tx_id.h:36
std::vector< uint8_t > RawCoseEndorsement
A single raw COSE endorsement, stored as an opaque byte vector.
Definition network_identity_interface.h:20
STL namespace.
Definition network_identity_interface.h:39
IdentityHistoryNotFetched(std::string msg)
Definition network_identity_interface.h:42
const char * what() const noexcept override
Definition network_identity_interface.h:44
std::string msg
Definition network_identity_interface.h:40