Struct akd::append_only_zks::Azks
source · Expand description
An append-only zero knowledge set, the data structure used to efficiently implement a auditable key directory.
Fields§
§latest_epoch: u64
The latest complete epoch
num_nodes: u64
The number of nodes ie the size of this tree
Implementations§
source§impl Azks
impl Azks
sourcepub async fn new<S: Database + Sync + Send>(
storage: &StorageManager<S>
) -> Result<Self, AkdError>
pub async fn new<S: Database + Sync + Send>(
storage: &StorageManager<S>
) -> Result<Self, AkdError>
Creates a new azks
sourcepub async fn batch_insert_leaves<S: Database + Sync + Send>(
&mut self,
storage: &StorageManager<S>,
insertion_set: Vec<Node>
) -> Result<(), AkdError>
pub async fn batch_insert_leaves<S: Database + Sync + Send>(
&mut self,
storage: &StorageManager<S>,
insertion_set: Vec<Node>
) -> Result<(), AkdError>
Insert a batch of new leaves
sourcepub async fn bfs_preload_nodes<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
nodes_to_load: HashSet<NodeLabel>
) -> Result<u64, AkdError>
pub async fn bfs_preload_nodes<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
nodes_to_load: HashSet<NodeLabel>
) -> Result<u64, AkdError>
Preloads given nodes using breadth-first search.
sourcepub async fn batch_insert_leaves_helper<S: Database + Sync + Send>(
&mut self,
storage: &StorageManager<S>,
insertion_set: Vec<Node>,
append_only_exclude_usage: bool
) -> Result<(), AkdError>
pub async fn batch_insert_leaves_helper<S: Database + Sync + Send>(
&mut self,
storage: &StorageManager<S>,
insertion_set: Vec<Node>,
append_only_exclude_usage: bool
) -> Result<(), AkdError>
An azks is built both by the crate::directory::Directory and the auditor. However, both constructions have very minor differences, and the append_only_usage bool keeps track of this.
sourcepub async fn get_membership_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel,
_epoch: u64
) -> Result<MembershipProof, AkdError>
pub async fn get_membership_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel,
_epoch: u64
) -> Result<MembershipProof, AkdError>
Returns the Merkle membership proof for the trie as it stood at epoch
sourcepub async fn get_non_membership_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel
) -> Result<NonMembershipProof, AkdError>
pub async fn get_non_membership_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel
) -> Result<NonMembershipProof, AkdError>
In a compressed trie, the proof consists of the longest prefix of the label that is included in the trie, as well as its children, to show that none of the children is equal to the given label.
sourcepub async fn get_append_only_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
start_epoch: u64,
end_epoch: u64
) -> Result<AppendOnlyProof, AkdError>
pub async fn get_append_only_proof<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
start_epoch: u64,
end_epoch: u64
) -> Result<AppendOnlyProof, AkdError>
An append-only proof for going from start_epoch
to end_epoch
consists of roots of subtrees
the azks tree that remain unchanged from start_epoch
to end_epoch
and the leaves inserted into the
tree after start_epoch
and up until end_epoch
.
If there is no errors, this function returns an Ok
result, containing the
append-only proof and otherwise, it returns a [errors::AkdError].
RESTRICTIONS: Note that start_epoch
and end_epoch
are valid only when the following are true
start_epoch
<=end_epoch
start_epoch
andend_epoch
are both existing epochs of this AZKS
sourcepub async fn get_root_hash<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>
) -> Result<Digest, AkdError>
pub async fn get_root_hash<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>
) -> Result<Digest, AkdError>
Gets the root hash for this azks
sourcepub async fn get_root_hash_safe<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
epoch: u64
) -> Result<Digest, AkdError>
pub async fn get_root_hash_safe<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
epoch: u64
) -> Result<Digest, AkdError>
Gets the root hash of the tree at the latest epoch if the passed epoch is equal to the latest epoch. Will return an error otherwise.
sourcepub fn get_latest_epoch(&self) -> u64
pub fn get_latest_epoch(&self) -> u64
Gets the latest epoch of this azks. If an update aka epoch transition is in progress, this should return the most recent completed epoch.
sourcepub async fn get_membership_proof_and_node<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel
) -> Result<(MembershipProof, NodeLabel), AkdError>
pub async fn get_membership_proof_and_node<S: Database + Sync + Send>(
&self,
storage: &StorageManager<S>,
label: NodeLabel
) -> Result<(MembershipProof, NodeLabel), AkdError>
This function returns the node label for the node whose label is the longest common prefix for the queried label. It also returns a membership proof for said label. This is meant to be used in both getting membership proofs and getting non-membership proofs.
Trait Implementations§
source§impl Storable for Azks
impl Storable for Azks
§type StorageKey = u8
type StorageKey = u8
source§fn data_type() -> StorageType
fn data_type() -> StorageType
source§fn get_id(&self) -> u8
fn get_id(&self) -> u8
source§fn get_full_binary_key_id(key: &u8) -> Vec<u8> ⓘ
fn get_full_binary_key_id(key: &u8) -> Vec<u8> ⓘ
impl Eq for Azks
impl StructuralEq for Azks
impl StructuralPartialEq for Azks
impl Sync for Azks
Auto Trait Implementations§
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.