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
sourceimpl Azks
impl Azks
sourcepub async fn new<S: Storage + Sync + Send, H: Hasher>(
storage: &S
) -> Result<Self, AkdError>
pub async fn new<S: Storage + Sync + Send, H: Hasher>(
storage: &S
) -> Result<Self, AkdError>
Creates a new azks
sourcepub async fn insert_leaf<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
node: Node<H>
) -> Result<(), AkdError>
pub async fn insert_leaf<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
node: Node<H>
) -> Result<(), AkdError>
Inserts a single leaf and is only used for testing, since batching is more efficient. We just want to make sure batch insertions work correctly and this function is useful for that.
sourcepub async fn batch_insert_leaves<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
insertion_set: Vec<Node<H>>
) -> Result<(), AkdError>
pub async fn batch_insert_leaves<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
insertion_set: Vec<Node<H>>
) -> Result<(), AkdError>
Insert a batch of new leaves
sourcepub async fn bfs_preload_nodes<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
nodes_to_load: HashSet<NodeLabel>
) -> Result<u64, AkdError>
pub async fn bfs_preload_nodes<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
nodes_to_load: HashSet<NodeLabel>
) -> Result<u64, AkdError>
Preloads given nodes using breadth-first search.
sourcepub async fn batch_insert_leaves_helper<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
insertion_set: Vec<Node<H>>,
append_only_usage: bool
) -> Result<(), AkdError>
pub async fn batch_insert_leaves_helper<S: Storage + Sync + Send, H: Hasher>(
&mut self,
storage: &S,
insertion_set: Vec<Node<H>>,
append_only_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: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<MembershipProof<H>, AkdError>
pub async fn get_membership_proof<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<MembershipProof<H>, AkdError>
Returns the Merkle membership proof for the trie as it stood at epoch
sourcepub async fn get_non_membership_proof<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<NonMembershipProof<H>, AkdError>
pub async fn get_non_membership_proof<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<NonMembershipProof<H>, 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: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
start_epoch: u64,
end_epoch: u64
) -> Result<AppendOnlyProof<H>, AkdError>
pub async fn get_append_only_proof<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
start_epoch: u64,
end_epoch: u64
) -> Result<AppendOnlyProof<H>, 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: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S
) -> Result<H::Digest, AkdError>
pub async fn get_root_hash<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S
) -> Result<H::Digest, AkdError>
Gets the root hash for this azks
sourcepub async fn get_root_hash_at_epoch<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
epoch: u64
) -> Result<H::Digest, AkdError>
pub async fn get_root_hash_at_epoch<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
epoch: u64
) -> Result<H::Digest, AkdError>
Gets the root hash of the tree at a epoch. Since this is accessing the root node and the root node exists at all epochs that the azks does, this would never be called at an epoch before the birth of the root node.
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: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<(MembershipProof<H>, NodeLabel), AkdError>
pub async fn get_membership_proof_and_node<S: Storage + Sync + Send, H: Hasher>(
&self,
storage: &S,
label: NodeLabel,
epoch: u64
) -> Result<(MembershipProof<H>, 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
sourceimpl Storable for Azks
impl Storable for Azks
sourcefn data_type() -> StorageType
fn data_type() -> StorageType
Must return a valid storage type
sourcefn get_id(&self) -> u8
fn get_id(&self) -> u8
Retrieve an instance of the id of this storable. The combination of the storable’s StorageType and this id are globally unique Read more
sourcefn get_full_binary_key_id(key: &u8) -> Vec<u8>
fn get_full_binary_key_id(key: &u8) -> Vec<u8>
Retrieve the full binary version of a key (for comparisons)
sourcefn key_from_full_binary(bin: &[u8]) -> Result<u8, String>
fn key_from_full_binary(bin: &[u8]) -> Result<u8, String>
Reformat a key from the full-binary specification
sourcefn get_full_binary_id(&self) -> Vec<u8>
fn get_full_binary_id(&self) -> Vec<u8>
Retrieve the full binary version of a key (for comparisons)
impl Eq for Azks
impl StructuralEq for Azks
impl StructuralPartialEq for Azks
impl Sync for Azks
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.