pub enum Threshold {
Simple(u64),
Weighted(Vec<Vec<Fraction>>),
}Expand description
KERI signing/backer threshold.
Simple thresholds are hex-encoded integers ("1", "2", "a").
Weighted thresholds are clause lists of fractions ([["1/2","1/2"]]).
Clauses are ANDed; each is satisfied when the sum of verified weights >= 1.
Usage:
use auths_keri::Threshold;
let t: Threshold = serde_json::from_str("\"2\"").unwrap();
assert_eq!(t.simple_value(), Some(2));Variants§
Simple(u64)
M-of-N threshold (hex-encoded integer in JSON).
Weighted(Vec<Vec<Fraction>>)
Fractionally weighted threshold (list of clause lists in JSON). Clauses are ANDed; each is satisfied when sum of verified weights >= 1.
Implementations§
Source§impl Threshold
impl Threshold
Sourcepub fn simple_value(&self) -> Option<u64>
pub fn simple_value(&self) -> Option<u64>
Get the simple threshold value, if this is a simple threshold.
Sourcepub fn validate_satisfiable(&self, count: usize) -> Result<(), KeriTypeError>
pub fn validate_satisfiable(&self, count: usize) -> Result<(), KeriTypeError>
Check that this threshold is structurally satisfiable against a key
(or commitment / backer) list of length count.
This is a structural guard run at validation entry — it rejects events
whose threshold can never be met regardless of which signatures arrive:
a Simple(n) with n > count, a non-zero Simple over an empty list,
or a Weighted clause whose length doesn’t match count.
Args:
count- Length of the list the threshold governs (k,n, orb).
Usage:
use auths_keri::Threshold;
assert!(Threshold::Simple(2).validate_satisfiable(3).is_ok());
assert!(Threshold::Simple(5).validate_satisfiable(1).is_err());Sourcepub fn is_satisfied(&self, verified_indices: &[u32], key_count: usize) -> bool
pub fn is_satisfied(&self, verified_indices: &[u32], key_count: usize) -> bool
Check if the threshold is satisfied by the given set of verified key indices.
For Simple(n): at least n unique indices must be verified.
For Weighted(clauses): ALL clauses must be independently satisfied.
A clause is satisfied when the sum of weights at verified indices >= 1.
Args:
verified_indices- Indices of keys whose signatures have been verified.key_count- Total number of keys in the key list (for bounds checking).
Usage:
use auths_keri::Threshold;
let t = Threshold::Simple(2);
assert!(t.is_satisfied(&[0, 1], 3));
assert!(!t.is_satisfied(&[0], 3));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Threshold
impl<'de> Deserialize<'de> for Threshold
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Threshold
impl StructuralPartialEq for Threshold
Auto Trait Implementations§
impl Freeze for Threshold
impl RefUnwindSafe for Threshold
impl Send for Threshold
impl Sync for Threshold
impl Unpin for Threshold
impl UnsafeUnpin for Threshold
impl UnwindSafe for Threshold
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.