pub async fn verify_append_only<H: Hasher + Send + Sync>(
    proof: AppendOnlyProof<H>,
    start_hash: H::Digest,
    end_hash: H::Digest,
) -> Result<(), AkdError> {
    let unchanged_nodes = proof.unchanged_nodes;
    let inserted = proof.inserted;

    let db = AsyncInMemoryDatabase::new();
    let mut azks = Azks::new::<_, H>(&db).await?;
    azks.batch_insert_leaves_helper::<_, H>(&db, unchanged_nodes, true)
        .await?;
    let computed_start_root_hash: H::Digest = azks.get_root_hash::<_, H>(&db).await?;
    let mut verified = computed_start_root_hash == start_hash;
    azks.batch_insert_leaves_helper::<_, H>(&db, inserted, true)
        .await?;
    let computed_end_root_hash: H::Digest = azks.get_root_hash::<_, H>(&db).await?;
    verified = verified && (computed_end_root_hash == end_hash);
    if !verified {
        return Err(AkdError::AzksErr(AzksError::VerifyAppendOnlyProof));
    }
    Ok(())
}
/// Helper for audit, verifies an append-only proof
Helper for audit, verifies an append-only proof
Helper for audit verifies an append - only proof
pub async fn verify_append_only<H: Hasher + Send + Sync>(
    proof: AppendOnlyProof<H>,
    start_hash: H::Digest,
    end_hash: H::Digest,
) -> Result<(), AkdError> {
    let unchanged_nodes = proof.unchanged_nodes;
    let inserted = proof.inserted;
    let db = AsyncInMemoryDatabase::new();
    let mut azks = Azks::new::<_, H>(&db).await?;
    azks.batch_insert_leaves_helper::<_, H>(&db, unchanged_nodes, true)
        .await?;
    let computed_start_root_hash: H::Digest = azks.get_root_hash::<_, H>(&db).await?;
    let mut verified = computed_start_root_hash == start_hash;
    azks.batch_insert_leaves_helper::<_, H>(&db, inserted, true)
        .await?;
    let computed_end_root_hash: H::Digest = azks.get_root_hash::<_, H>(&db).await?;
    verified = verified && (computed_end_root_hash == end_hash);
    if !verified {
        return Err(AkdError::AzksErr(AzksError::VerifyAppendOnlyProof));
    }
    Ok(())
}
pub async fn verify_append_only < H : Hasher + Send + Sync > ( proof : AppendOnlyProof < H > , start_hash : H :: Digest , end_hash : H :: Digest , ) -> Result < ( ) , AkdError > { let unchanged_nodes = proof . unchanged_nodes ; let inserted = proof . inserted ; let db = AsyncInMemoryDatabase :: new ( ) ; let mut azks = Azks :: new :: < _ , H > ( & db ) . await ? ; azks . batch_insert_leaves_helper :: < _ , H > ( & db , unchanged_nodes , true ) . await ? ; let computed_start_root_hash : H :: Digest = azks . get_root_hash :: < _ , H > ( & db ) . await ? ; let mut verified = computed_start_root_hash == start_hash ; azks . batch_insert_leaves_helper :: < _ , H > ( & db , inserted , true ) . await ? ; let computed_end_root_hash : H :: Digest = azks . get_root_hash :: < _ , H > ( & db ) . await ? ; verified = verified && ( computed_end_root_hash == end_hash ) ; if ! verified { return Err ( AkdError :: AzksErr ( AzksError :: VerifyAppendOnlyProof ) ) ; } Ok ( ( ) ) }
Helper for audit, verifies an append-only proof
Helper for audit verifies an append - only proof
proof
AppendOnlyProof<H>
start_hash
H::Digest
end_hash
H::Digest
proof
AppendOnlyProof<H>
start_hash
H::Digest
end_hash
H::Digest