drive/verify/document_sum/mod.rs
1//! Verifies grovedb proofs produced by the `GetDocumentsSum` endpoint.
2//!
3//! Mirror of [`crate::verify::document_count`] for the sum surface.
4//! Pure grovedb-level verifiers as methods on
5//! [`crate::query::DriveDocumentSumQuery`] that take raw `proof: &[u8]`
6//! and return `(RootHash, T)`. The tenderdash signature composition
7//! layer that wraps these calls lives in
8//! `packages/rs-drive-proof-verifier/src/proof/document_sum.rs`.
9//!
10//! Carrier-aggregate verifier bodies call
11//! `GroveDb::verify_aggregate_sum_query_per_key` and
12//! `GroveDb::verify_aggregate_count_and_sum_query_per_key` (grovedb
13//! PR #670 head `e98bab5f`).
14
15/// Single-aggregate-sum proof verification — sum analog of count's
16/// `verify_aggregate_count_proof`. Returns `(root_hash, i64 sum)`
17/// from one `AggregateSumOnRange` merk traversal.
18pub mod verify_aggregate_sum_proof;
19
20/// Carrier-aggregate-sum proof verification — sum-side analog of
21/// count's `verify_carrier_aggregate_count_proof`. Returns one
22/// `(in_key, i64)` per resolved In branch.
23pub mod verify_carrier_aggregate_sum_proof;
24
25/// Combined PCPS carrier-aggregate proof verification — returns one
26/// `(in_key, u64 count, i64 sum)` triple per resolved In branch.
27/// PCPS-only (the terminator's value tree must be a
28/// `ProvableCountProvableSumTree`).
29pub mod verify_carrier_aggregate_count_and_sum_proof;
30
31/// Leaf-PCPS `AggregateCountAndSumOnRange` proof verification —
32/// returns `(root_hash, u64 count, i64 sum)`. PCPS-only (the
33/// terminator's value tree must be a
34/// `ProvableCountProvableSumTree`). The load-bearing primitive for
35/// average-range queries: the client computes
36/// `avg = sum / count` locally, but the proof commits both metrics
37/// from the same in-range set in one root-hash-attested traversal.
38pub mod verify_aggregate_count_and_sum_proof;
39
40/// Direct read of the document type's primary-key `SumTree` element
41/// — sum analog of count's `verify_primary_key_count_tree_proof`.
42/// Returns `(root_hash, i64 sum)`. Used by the `documents_summable`
43/// fast path on empty-where SUM queries.
44pub mod verify_primary_key_sum_tree_proof;
45
46/// Direct read of the document type's primary-key count-sum-bearing
47/// element (CountSumTree / ProvableCountSumTree /
48/// ProvableCountProvableSumTree) — returns `(root_hash, u64 count,
49/// i64 sum)`. Used by the `documentsCountable + documentsSummable`
50/// fast path on empty-where AVG queries.
51pub mod verify_primary_key_count_sum_tree_proof;
52
53/// Point-lookup sum proof verification — sum analog of count's
54/// `verify_point_lookup_count_proof`. Returns one `SumEntry` per
55/// verified branch (Equal-only fully-covered: one entry with empty
56/// `key`; In-bearing: one entry per present In value with `key =
57/// serialized_in_value`). Absent branches are silently omitted
58/// because today's path query does not request absence proofs.
59pub mod verify_point_lookup_sum_proof;
60
61/// Per-distinct-key range-sum proof verification — sum analog of
62/// count's `verify_distinct_count_proof`. Walks the verified
63/// terminator SumTree elements and extracts each
64/// `sum_value_or_default()` as a per-`(in_key, key)` entry. Used
65/// by the prove path's `RangeDistinctProof` mode.
66pub mod verify_distinct_sum_proof;
67
68/// Point-lookup count+sum proof verification — AVG analog of
69/// `verify_point_lookup_sum_proof`. Extracts
70/// `count_sum_value_or_default()` from each verified terminator
71/// element. Used by the prove path's AVG point-lookup shape on a
72/// `documentsCountable + documentsSummable` doctype.
73pub mod verify_point_lookup_count_and_sum_proof;
74
75/// Per-distinct-key range-AVG proof verification — AVG analog of
76/// `verify_distinct_sum_proof`. Walks the verified terminator
77/// count-sum-bearing elements and extracts each
78/// `count_sum_value_or_default()` as a per-`(in_key, key)`
79/// `AverageEntry`. Requires the index to declare BOTH
80/// `rangeCountable: true` AND `rangeSummable: true` (i.e. a
81/// `rangeAverageable: true` index). Used by the prove path's
82/// `RangeDistinctProof` mode on the AVG surface.
83pub mod verify_distinct_count_and_sum_proof;