55#include " ccf/crypto/ec_public_key.h"
66#include " ccf/node_subsystem_interface.h"
77
8+ #include < map>
89#include < optional>
910#include < string>
1011#include < vector>
@@ -13,16 +14,25 @@ namespace ccf
1314{
1415 struct NetworkIdentity ;
1516
17+ // / A single raw COSE endorsement, stored as an opaque byte vector.
1618 using RawCoseEndorsement = std::vector<uint8_t >;
19+ // / An ordered chain of raw COSE endorsements.
1720 using CoseEndorsementsChain = std::vector<RawCoseEndorsement>;
1821
22+ // / Status of the network identity endorsement fetching process.
1923 enum class FetchStatus : uint8_t
2024 {
21- Retry,
22- Done,
23- Failed
25+ Retry, // /< Fetching should be retried
26+ Done, // /< Fetching completed successfully
27+ Failed // /< Fetching failed
2428 };
2529
30+ // / Map from sequence number to EC public key, representing the trusted
31+ // / network identity keys over the history of the service.
32+ using TrustedKeys = std::map<ccf::SeqNo, ccf::crypto::ECPublicKeyPtr>;
33+
34+ // / Interface for accessing the network identity subsystem, which manages
35+ // / the service's cryptographic identity and its historical trusted keys.
2636 class NetworkIdentitySubsystemInterface : public ccf ::AbstractNodeSubSystem
2737 {
2838 public:
@@ -33,14 +43,33 @@ namespace ccf
3343 return " NetworkIdentity" ;
3444 }
3545
46+ // / Returns a reference to the current network identity.
3647 virtual const std::unique_ptr<NetworkIdentity>& get () = 0;
3748
49+ // / Returns the current status of endorsement fetching.
3850 [[nodiscard]] virtual FetchStatus endorsements_fetching_status () const = 0;
3951
52+ // / Returns the COSE endorsements chain for the given sequence number,
53+ // / or std::nullopt if endorsement fetching has not completed or the
54+ // / chain is not available for the given sequence number.
4055 [[nodiscard]] virtual std::optional<CoseEndorsementsChain>
4156 get_cose_endorsements_chain (ccf::SeqNo seqno) const = 0 ;
4257
58+ // / Returns the trusted EC public key that was active at the given
59+ // / sequence number, or nullptr if the sequence number precedes the
60+ // / earliest known trusted key.
61+ // /
62+ // / @throws std::logic_error if endorsement fetching has not completed
63+ // / (i.e. endorsements_fetching_status() != FetchStatus::Done), or if
64+ // / no trusted keys have been fetched.
4365 [[nodiscard]] virtual ccf::crypto::ECPublicKeyPtr get_trusted_identity_for (
4466 ccf::SeqNo seqno) const = 0;
67+
68+ // / Returns all trusted network identity keys as a map from sequence
69+ // / number to EC public key.
70+ // /
71+ // / @throws std::logic_error if endorsement fetching has not completed
72+ // / (i.e. endorsements_fetching_status() != FetchStatus::Done).
73+ [[nodiscard]] virtual TrustedKeys get_trusted_keys () const = 0;
4574 };
4675}
0 commit comments