pub struct TrustGraph<S>where
S: Storage,{ /* private fields */ }
Expand description
Graph to efficiently calculate weights of certificates and get chains of certificates. TODO serialization/deserialization TODO export a certificate from graph
Implementations§
Source§impl<S> TrustGraph<S>where
S: Storage,
impl<S> TrustGraph<S>where
S: Storage,
pub fn new(storage: S) -> Self
Sourcepub fn set_root(
&mut self,
pk: PublicKey,
max_chain_len: u32,
) -> Result<(), TrustGraphError>
pub fn set_root( &mut self, pk: PublicKey, max_chain_len: u32, ) -> Result<(), TrustGraphError>
Insert new root weight
pub fn add_trust<T, P>( &mut self, trust: T, issued_by: P, cur_time: Duration, ) -> Result<u32, TrustGraphError>
Sourcepub fn add<C>(
&mut self,
cert: C,
cur_time: Duration,
) -> Result<(), TrustGraphError>where
C: Borrow<Certificate>,
pub fn add<C>(
&mut self,
cert: C,
cur_time: Duration,
) -> Result<(), TrustGraphError>where
C: Borrow<Certificate>,
Certificate is a chain of trusts, add this chain to graph
Sourcepub fn weight<P>(
&mut self,
pk: P,
cur_time: Duration,
) -> Result<u32, TrustGraphError>
pub fn weight<P>( &mut self, pk: P, cur_time: Duration, ) -> Result<u32, TrustGraphError>
Get the maximum weight of trust for one public key.
Sourcepub fn weight_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration,
) -> Result<u32, TrustGraphError>
pub fn weight_from<P>( &mut self, issued_for: P, issuer: P, cur_time: Duration, ) -> Result<u32, TrustGraphError>
Get the maximum weight of trust for one public key.
for all chains which contain issuer
Sourcepub fn certificates_weight_factor<C, I>(
&self,
certs: I,
) -> Result<Option<WeightFactor>, TrustGraphError>
pub fn certificates_weight_factor<C, I>( &self, certs: I, ) -> Result<Option<WeightFactor>, TrustGraphError>
Calculate weight from given certificates Returns None if there is no such public key or some trust between this key and a root key is revoked.
Sourcepub fn get_all_certs_from<P>(
&mut self,
issued_for: P,
issuer: P,
cur_time: Duration,
) -> Result<Vec<Certificate>, TrustGraphError>
pub fn get_all_certs_from<P>( &mut self, issued_for: P, issuer: P, cur_time: Duration, ) -> Result<Vec<Certificate>, TrustGraphError>
Get all possible certificates where issued_for
will be the last element of the chain,
all certificates contain issuer
and one of the destinations is the root of this chain.
Sourcepub fn get_all_certs<P>(
&mut self,
issued_for: P,
cur_time: Duration,
) -> Result<Vec<Certificate>, TrustGraphError>
pub fn get_all_certs<P>( &mut self, issued_for: P, cur_time: Duration, ) -> Result<Vec<Certificate>, TrustGraphError>
Get all possible certificates where issued_for
will be the last element of the chain
and one of the destinations is the root of this chain.
Sourcepub fn revoke(&mut self, revocation: Revocation) -> Result<(), TrustGraphError>
pub fn revoke(&mut self, revocation: Revocation) -> Result<(), TrustGraphError>
Mark public key as revoked.
Every chain that contains path from revoked_by
to revoked pk
will be excluded from valid certificates until revocation canceled by giving trust