securecrdt/QuorumThresholdValidation.hpp¶
Exact quorum-policy floor and bounds validation helpers. More...
Namespaces¶
| Name |
|---|
| sgns |
| sgns::securecrdt |
Functions¶
| Name | |
|---|---|
| uint64_t | MembershipQuorumFloor(size_t signer_set_size) |
| uint64_t | BurnQuorumFloor(size_t signer_set_size) |
| outcome::result< void > | ValidateThresholdAtFloor(uint64_t threshold, size_t signer_set_size, uint64_t floor) |
| outcome::result< void > | ValidateMembershipQuorumThreshold(uint64_t threshold, size_t signer_set_size) |
| outcome::result< void > | ValidateBurnQuorumThreshold(uint64_t threshold, size_t signer_set_size) |
| uint64_t | StrictMajorityQuorumFloor(size_t signer_set_size) Strict-majority safety floor, ceil(0.51 * signer_set_size): the minimum threshold that can never be met by a signer set alone without cooperation of more than half of its members. Returns 0 for an empty signer set (an empty set can never authorize anything – ValidateThresholdAtFloor rejects it). |
| outcome::result< void > | ValidateQuorumThreshold(uint64_t threshold, size_t signer_set_size) Validates threshold against the strict-majority floor ceil(0.51 * signer_set_size). Used by registries whose bootstrap authority is an external peer set (e.g. NetworkRegistry's TrustedPeerRegistry-majority bootstrap, D-06): the bootstrap record must carry signatures from strictly more than half of the authorizing set. |
Detailed Description¶
Exact quorum-policy floor and bounds validation helpers.
Date: 2026-07-24 Henrique A. Klein ([email protected])
Functions Documentation¶
function MembershipQuorumFloor¶
function BurnQuorumFloor¶
function ValidateThresholdAtFloor¶
inline outcome::result< void > ValidateThresholdAtFloor(
uint64_t threshold,
size_t signer_set_size,
uint64_t floor
)
function ValidateMembershipQuorumThreshold¶
inline outcome::result< void > ValidateMembershipQuorumThreshold(
uint64_t threshold,
size_t signer_set_size
)
function ValidateBurnQuorumThreshold¶
inline outcome::result< void > ValidateBurnQuorumThreshold(
uint64_t threshold,
size_t signer_set_size
)
function StrictMajorityQuorumFloor¶
Strict-majority safety floor, ceil(0.51 * signer_set_size): the minimum threshold that can never be met by a signer set alone without cooperation of more than half of its members. Returns 0 for an empty signer set (an empty set can never authorize anything – ValidateThresholdAtFloor rejects it).
function ValidateQuorumThreshold¶
inline outcome::result< void > ValidateQuorumThreshold(
uint64_t threshold,
size_t signer_set_size
)
Validates threshold against the strict-majority floor ceil(0.51 * signer_set_size). Used by registries whose bootstrap authority is an external peer set (e.g. NetworkRegistry's TrustedPeerRegistry-majority bootstrap, D-06): the bootstrap record must carry signatures from strictly more than half of the authorizing set.
Parameters:
- threshold Configured required-signature count.
- signer_set_size Size of the authorizing signer set.
Return: success, or SecureCrdt::Error::QUORUM_THRESHOLD_BELOW_FLOOR when the set is empty, the threshold is 0/above the set size, or below the strict-majority floor.
Source code¶
#ifndef SGNS_SECURECRDT_QUORUMTHRESHOLDVALIDATION_HPP
#define SGNS_SECURECRDT_QUORUMTHRESHOLDVALIDATION_HPP
#include <cstddef>
#include <cstdint>
#include "outcome/outcome.hpp"
#include "securecrdt/SecureCrdt.hpp"
namespace sgns::securecrdt
{
inline uint64_t MembershipQuorumFloor( size_t signer_set_size )
{
if ( signer_set_size == 0 )
{
return 0;
}
return static_cast<uint64_t>( signer_set_size ) / 2 + 1;
}
inline uint64_t BurnQuorumFloor( size_t signer_set_size )
{
const auto count = static_cast<uint64_t>( signer_set_size );
return count - count / 3;
}
inline outcome::result<void> ValidateThresholdAtFloor( uint64_t threshold, size_t signer_set_size, uint64_t floor )
{
const auto count = static_cast<uint64_t>( signer_set_size );
if ( count == 0 || threshold == 0 || threshold > count || threshold < floor )
{
return outcome::failure( SecureCrdt::Error::QUORUM_THRESHOLD_BELOW_FLOOR );
}
return outcome::success();
}
inline outcome::result<void> ValidateMembershipQuorumThreshold( uint64_t threshold, size_t signer_set_size )
{
return ValidateThresholdAtFloor( threshold, signer_set_size, MembershipQuorumFloor( signer_set_size ) );
}
inline outcome::result<void> ValidateBurnQuorumThreshold( uint64_t threshold, size_t signer_set_size )
{
return ValidateThresholdAtFloor( threshold, signer_set_size, BurnQuorumFloor( signer_set_size ) );
}
inline uint64_t StrictMajorityQuorumFloor( size_t signer_set_size )
{
return ( static_cast<uint64_t>( signer_set_size ) * 51 + 99 ) / 100;
}
inline outcome::result<void> ValidateQuorumThreshold( uint64_t threshold, size_t signer_set_size )
{
return ValidateThresholdAtFloor( threshold, signer_set_size, StrictMajorityQuorumFloor( signer_set_size ) );
}
} // namespace sgns::securecrdt
#endif // SGNS_SECURECRDT_QUORUMTHRESHOLDVALIDATION_HPP
Updated on 2026-10-10 at 04:54:24 +0000