Skip to main content

verify_point_lookup_count_proof

Function verify_point_lookup_count_proof 

Source
pub fn verify_point_lookup_count_proof(
    query: &DriveDocumentCountQuery<'_>,
    proof: &Proof,
    mtd: &ResponseMetadata,
    platform_version: &PlatformVersion,
    provider: &dyn ContextProvider,
) -> Result<Vec<SplitCountEntry>, Error>
Expand description

Verify a grovedb point-lookup count proof against a countable: true index and return the per-branch entries.

Thin tenderdash-composition wrapper over DriveDocumentCountQuery::verify_point_lookup_count_proof in rs-drive (which does the merk-level verification and walks the verified elements to extract count_value).

§Entry shape

The verifier walks grovedb’s (path, key, Option<Element>) triples and emits one SplitCountEntry per present queried key. The current path-query shape does NOT set absence_proofs_for_non_existing_searched_keys: true, so absent branches are silently omitted from grovedb’s elements stream rather than surfaced as (path, key, None) triples.

  • Equal-only, fully covered: zero or one entry. One entry with empty key and count: Some(n) if the covered branch exists; no entries at all if the branch is absent.
  • Equal prefix + In on last property: one entry per present queried In value, with key = <serialized_in_value> and count: Some(n). Absent In values are omitted from the returned list. Callers that need to distinguish “verified with n docs” from “queried but absent” diff their request’s In array against the returned entries by key.

The count: Option<u64> field’s None variant is reserved for a future variant that flips absence_proofs_for_non_existing_searched_keys — see SplitCountEntry::count and DriveDocumentCountQuery::verify_point_lookup_count_proof for the forward-compat path.

§Replaces materialize-and-count

Before this primitive landed, prove count queries with no range clause used DriveDocumentQuery::execute_with_proof to prove every matching document and counted them client-side. That path scaled with matching docs and was capped at u16::MAX. The CountTree element proof is O(k × log n) where k is the number of covered branches — bandwidth and CPU drop by orders of magnitude on counted indexes and the cap disappears.