Skip to content

sgns::trustedpeer::TrustedPeerRegistry

Genesis-seeded, in-memory-cached, quorum-updatable trusted-peer set. Delegates ALL signature/quorum logic to SecureCrdt / SecureCrdtRegistry – no bespoke signature/quorum logic exists here (TPR-03). More...

#include <TrustedPeerRegistry.hpp>

Inherits from sgns::peerregistry::PeerRegistry, std::enable_shared_from_this< TrustedPeerRegistry >

Public Types

Name
enum class uint8_t Error
using std::function< std::vector< uint8_t >(const std::vector< uint8_t > &)> SignCallback

Public Functions

Name
TrustedPeerRegistry(std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt, std::vector< std::string > genesis_peers, std::string bootstrapper_address, uint64_t quorum_threshold, sgns::crdt::HierarchicalKey base_key)
Constructs a TrustedPeerRegistry. The genesis peer list is cached immediately (D-05) –GetCurrentPeers() reflects it even before SeedGenesis/TryConfirm are called.
~TrustedPeerRegistry()
outcome::result< sgns::securecrdt::CandidateId > SubmitReviewedGenesisApproval()
outcome::result< bool > TryActivateReviewedGenesisCandidate(const sgns::securecrdt::CandidateId & candidate_id)
outcome::result< std::vector< sgns::securecrdt::CandidateId > > ListPendingPolicyCandidates() const
outcome::result< sgns::securecrdt::CandidateId > ProposePolicyCandidate(const QuorumPolicyState & candidate)
outcome::result< sgns::securecrdt::CandidateId > ApprovePolicyCandidate(const sgns::securecrdt::CandidateId & candidate_id)
outcome::result< bool > TryActivatePolicyCandidate(const sgns::securecrdt::CandidateId & candidate_id)
outcome::result< ConfirmedTrustSnapshot > GetConfirmedSnapshot() const
outcome::result< void > SeedGenesis(const std::vector< std::string > & genesis_peers, const std::vector< uint8_t > & ephemeral_signature)
Seeds the genesis trusted-peer list: proposes the genesis payload then adds exactly one ephemeral-bootstrapper signature. The signature is PRECOMPUTED – this method never signs live (D-02).
outcome::result< void > ProposeMembershipChange(const std::vector< std::string > & new_peers)
Proposes a membership-change value (new full peer list).
outcome::result< void > SignMembershipChange(const std::string & signer_address, const std::vector< uint8_t > & signature)
Adds a signature over the currently-proposed value.
outcome::result< bool > TryConfirm()
Attempts to confirm the currently-proposed value against quorum. On confirmation, decodes/verifies/applies the payload and overwrites the cached peer set – never speculatively before quorum is independently confirmed.
virtual outcome::result< sgns::securecrdt::SignerSetSnapshot > CurrentSignerSet() const override
PeerRegistry override: resolves the current authorized signer set via the existing cached-only ResolveSignerSet() (D-05: pure forwarding, no logic change).
virtual std::vector< std::string > GetCurrentPeers() const override
Returns a copy of the current cached trusted-peer set.
virtual sgns::crdt::HierarchicalKey BaseKey() const override
PeerRegistry override: returns this registry's CRDT base key (D-05: pure forwarding, no logic change).
bool IsGenesisConfirmed() const
Reports whether genesis has been confirmed.
void Unregister()
Unregisters this instance's signer-set-source from SecureCrdtRegistry (test-fixture teardown helper).
outcome::result< std::shared_ptr< TrustedPeerRegistry > > New(std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt, std::vector< std::string > genesis_peers, std::string bootstrapper_address, uint64_t quorum_threshold, sgns::crdt::HierarchicalKey base_key =sgns::crdt::HierarchicalKey("trusted-peer-registry"))
Constructs a TrustedPeerRegistry and registers its signer-set-source with SecureCrdtRegistry.
outcome::result< std::shared_ptr< TrustedPeerRegistry > > NewProduction(std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt, std::shared_ptr< TrustStateStore > trust_store, GenesisManifest reviewed_manifest, std::vector< uint8_t > bootstrap_manifest_signature, std::string local_signer_address, SignCallback sign_callback, std::string policy_domain ="trusted-peer")
Builds the durable production registry. Fresh stores expose no peers until SubmitReviewedGenesisApproval commits the reviewed manifest. Existing stores restore only independently verified state.
std::optional< sgns::securecrdt::CandidateCore > PolicyCandidateCore(const QuorumPolicyState & candidate, const std::string & domain ="trusted-peer")

Additional inherited members

Public Functions inherited from sgns::peerregistry::PeerRegistry

Name
virtual ~PeerRegistry() =default

Detailed Description

class sgns::trustedpeer::TrustedPeerRegistry;

Genesis-seeded, in-memory-cached, quorum-updatable trusted-peer set. Delegates ALL signature/quorum logic to SecureCrdt / SecureCrdtRegistry – no bespoke signature/quorum logic exists here (TPR-03).

Implements sgns::peerregistry::PeerRegistry (D-05): the ONE global root trust domain – forwarding-only overrides, no logic changes, and no per-network instances are ever created.

Public Types Documentation

enum Error

Enumerator Value Description
NOT_CONFIRMED 0
INVALID_CANDIDATE
SIGNING_UNAVAILABLE

using SignCallback

using sgns::trustedpeer::TrustedPeerRegistry::SignCallback =  std::function<std::vector<uint8_t>( const std::vector<uint8_t> & )>;

Public Functions Documentation

function TrustedPeerRegistry

TrustedPeerRegistry(
    std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt,
    std::vector< std::string > genesis_peers,
    std::string bootstrapper_address,
    uint64_t quorum_threshold,
    sgns::crdt::HierarchicalKey base_key
)

Constructs a TrustedPeerRegistry. The genesis peer list is cached immediately (D-05) –GetCurrentPeers() reflects it even before SeedGenesis/TryConfirm are called.

Parameters:

  • secure_crdt SecureCrdt wrapper to delegate propose/sign/ quorum operations to.
  • genesis_peers Genesis trusted-peer address list (non-empty).
  • bootstrapper_address Sole ephemeral genesis signer address.
  • quorum_threshold Quorum threshold applied once genesis is confirmed (i.e. for membership-change proposals).
  • base_key Registered CRDT key this instance owns.

function ~TrustedPeerRegistry

~TrustedPeerRegistry()

function SubmitReviewedGenesisApproval

outcome::result< sgns::securecrdt::CandidateId > SubmitReviewedGenesisApproval()

function TryActivateReviewedGenesisCandidate

outcome::result< bool > TryActivateReviewedGenesisCandidate(
    const sgns::securecrdt::CandidateId & candidate_id
)

function ListPendingPolicyCandidates

outcome::result< std::vector< sgns::securecrdt::CandidateId > > ListPendingPolicyCandidates() const

function ProposePolicyCandidate

outcome::result< sgns::securecrdt::CandidateId > ProposePolicyCandidate(
    const QuorumPolicyState & candidate
)

function ApprovePolicyCandidate

outcome::result< sgns::securecrdt::CandidateId > ApprovePolicyCandidate(
    const sgns::securecrdt::CandidateId & candidate_id
)

function TryActivatePolicyCandidate

outcome::result< bool > TryActivatePolicyCandidate(
    const sgns::securecrdt::CandidateId & candidate_id
)

function GetConfirmedSnapshot

outcome::result< ConfirmedTrustSnapshot > GetConfirmedSnapshot() const

function SeedGenesis

outcome::result< void > SeedGenesis(
    const std::vector< std::string > & genesis_peers,
    const std::vector< uint8_t > & ephemeral_signature
)

Seeds the genesis trusted-peer list: proposes the genesis payload then adds exactly one ephemeral-bootstrapper signature. The signature is PRECOMPUTED – this method never signs live (D-02).

Parameters:

  • genesis_peers Genesis trusted-peer address list.
  • ephemeral_signature Precomputed bootstrapper signature over the genesis payload.

Return: outcome::success on success, or the first failing SecureCrdt call's error.

function ProposeMembershipChange

outcome::result< void > ProposeMembershipChange(
    const std::vector< std::string > & new_peers
)

Proposes a membership-change value (new full peer list).

Parameters:

  • new_peers Proposed new full trusted-peer address list.

Return: outcome::success on success, or the failing SecureCrdt call's error.

function SignMembershipChange

outcome::result< void > SignMembershipChange(
    const std::string & signer_address,
    const std::vector< uint8_t > & signature
)

Adds a signature over the currently-proposed value.

Parameters:

  • signer_address Address claimed to have produced signature.
  • signature Raw signature bytes.

Return: outcome::success on success, or the failing SecureCrdt call's error.

function TryConfirm

outcome::result< bool > TryConfirm()

Attempts to confirm the currently-proposed value against quorum. On confirmation, decodes/verifies/applies the payload and overwrites the cached peer set – never speculatively before quorum is independently confirmed.

Return: outcome::success(true) if this call newly confirmed a value, outcome::success(false) if quorum is not yet met, or a failure if the confirmed payload is malformed/invalid.

function CurrentSignerSet

virtual outcome::result< sgns::securecrdt::SignerSetSnapshot > CurrentSignerSet() const override

PeerRegistry override: resolves the current authorized signer set via the existing cached-only ResolveSignerSet() (D-05: pure forwarding, no logic change).

Return: Signer set snapshot for the current state.

Reimplements: sgns::peerregistry::PeerRegistry::CurrentSignerSet

function GetCurrentPeers

virtual std::vector< std::string > GetCurrentPeers() const override

Returns a copy of the current cached trusted-peer set.

Return: Current trusted-peer address list.

Reimplements: sgns::peerregistry::PeerRegistry::GetCurrentPeers

function BaseKey

inline virtual sgns::crdt::HierarchicalKey BaseKey() const override

PeerRegistry override: returns this registry's CRDT base key (D-05: pure forwarding, no logic change).

Return: HierarchicalKey of the "trusted-peer-registry" branch.

Reimplements: sgns::peerregistry::PeerRegistry::BaseKey

function IsGenesisConfirmed

bool IsGenesisConfirmed() const

Reports whether genesis has been confirmed.

Return: true once TryConfirm has confirmed the genesis value.

function Unregister

void Unregister()

Unregisters this instance's signer-set-source from SecureCrdtRegistry (test-fixture teardown helper).

function New

static outcome::result< std::shared_ptr< TrustedPeerRegistry > > New(
    std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt,
    std::vector< std::string > genesis_peers,
    std::string bootstrapper_address,
    uint64_t quorum_threshold,
    sgns::crdt::HierarchicalKey base_key =sgns::crdt::HierarchicalKey("trusted-peer-registry")
)

Constructs a TrustedPeerRegistry and registers its signer-set-source with SecureCrdtRegistry.

Parameters:

  • secure_crdt SecureCrdt wrapper to delegate propose/sign/ quorum operations to.
  • genesis_peers Genesis trusted-peer address list (non-empty).
  • bootstrapper_address Sole ephemeral genesis signer address.
  • quorum_threshold Quorum threshold applied once genesis is confirmed.
  • base_key Registered CRDT key this instance owns.

Return: outcome::success(instance) with the newly-constructed, registered TrustedPeerRegistry instance, or outcome::failure(SecureCrdt::Error::QUORUM_THRESHOLD_BELOW_FLOOR) if quorum_threshold is below the majority-safety floor for genesis_peers.size() (D-07) – construction fails, no instance is produced.

function NewProduction

static outcome::result< std::shared_ptr< TrustedPeerRegistry > > NewProduction(
    std::shared_ptr< sgns::securecrdt::SecureCrdt > secure_crdt,
    std::shared_ptr< TrustStateStore > trust_store,
    GenesisManifest reviewed_manifest,
    std::vector< uint8_t > bootstrap_manifest_signature,
    std::string local_signer_address,
    SignCallback sign_callback,
    std::string policy_domain ="trusted-peer"
)

Builds the durable production registry. Fresh stores expose no peers until SubmitReviewedGenesisApproval commits the reviewed manifest. Existing stores restore only independently verified state.

function PolicyCandidateCore

static std::optional< sgns::securecrdt::CandidateCore > PolicyCandidateCore(
    const QuorumPolicyState & candidate,
    const std::string & domain ="trusted-peer"
)

Updated on 2026-10-10 at 04:54:21 +0000