pub struct Directory<TC, S: Database, V> { /* private fields */ }
Expand description
The representation of a auditable key directory
Implementations§
source§impl<TC, S, V> Directory<TC, S, V>where
TC: Configuration,
S: Database + 'static,
V: VRFKeyStorage,
impl<TC, S, V> Directory<TC, S, V>where TC: Configuration, S: Database + 'static, V: VRFKeyStorage,
sourcepub async fn new(storage: StorageManager<S>, vrf: V) -> Result<Self, AkdError>
pub async fn new(storage: StorageManager<S>, vrf: V) -> Result<Self, AkdError>
Creates a new (stateless) instance of a auditable key directory. Takes as input a pointer to the storage being used for this instance. The state is stored in the storage.
sourcepub async fn publish(
&self,
updates: Vec<(AkdLabel, AkdValue)>
) -> Result<EpochHash, AkdError>
pub async fn publish( &self, updates: Vec<(AkdLabel, AkdValue)> ) -> Result<EpochHash, AkdError>
Updates the directory to include the input label-value pairs.
Note that the vector of label-value pairs should not contain any entries with duplicate labels. This condition is explicitly checked, and an error will be returned if this is the case.
sourcepub async fn lookup(
&self,
akd_label: AkdLabel
) -> Result<(LookupProof, EpochHash), AkdError>
pub async fn lookup( &self, akd_label: AkdLabel ) -> Result<(LookupProof, EpochHash), AkdError>
Provides proof for correctness of latest version
akd_label
: The target label to generate a lookup proof for
Returns [Ok((LookupProof, EpochHash))] upon successful generation for the latest version of the target label’s state. [Err(_)] otherwise
sourcepub async fn batch_lookup(
&self,
akd_labels: &[AkdLabel]
) -> Result<(Vec<LookupProof>, EpochHash), AkdError>
pub async fn batch_lookup( &self, akd_labels: &[AkdLabel] ) -> Result<(Vec<LookupProof>, EpochHash), AkdError>
Allows efficient batch lookups by preloading necessary nodes for the lookups.
sourcepub async fn key_history(
&self,
akd_label: &AkdLabel,
params: HistoryParams
) -> Result<(HistoryProof, EpochHash), AkdError>
pub async fn key_history( &self, akd_label: &AkdLabel, params: HistoryParams ) -> Result<(HistoryProof, EpochHash), AkdError>
Takes in the current state of the server and a label. If the label is present in the current state, this function returns all the values ever associated with it, and the epoch at which each value was first committed to the server state. It also returns the proof of the latest version being served at all times.
sourcepub async fn poll_for_azks_changes(
&self,
period: Duration,
change_detected: Option<Sender<()>>
) -> Result<(), AkdError>
pub async fn poll_for_azks_changes( &self, period: Duration, change_detected: Option<Sender<()>> ) -> Result<(), AkdError>
Poll for changes in the epoch number of the AZKS struct stored in the storage layer. If an epoch change is detected, the object cache (if present) is flushed immediately so that new objects are retrieved from the storage layer against the “latest” epoch. There is a “special” flow in the storage layer to do a storage-layer retrieval which ignores the cache
sourcepub async fn audit(
&self,
audit_start_ep: u64,
audit_end_ep: u64
) -> Result<AppendOnlyProof, AkdError>
pub async fn audit( &self, audit_start_ep: u64, audit_end_ep: u64 ) -> Result<AppendOnlyProof, AkdError>
Returns an AppendOnlyProof for the leaves inserted into the underlying tree between
the epochs audit_start_ep
and audit_end_ep
.
sourcepub async fn get_public_key(&self) -> Result<VRFPublicKey, AkdError>
pub async fn get_public_key(&self) -> Result<VRFPublicKey, AkdError>
HELPERS /// Use this function to retrieve the VRFPublicKey for this AKD.
sourcepub async fn get_epoch_hash(&self) -> Result<EpochHash, AkdError>
pub async fn get_epoch_hash(&self) -> Result<EpochHash, AkdError>
Gets the root hash at the current epoch.