You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phase 1 of the ProvableSumTree feature — the missing parallel to
ProvableCountTree that bakes the per-node sum into the node hash, making
aggregate-sum range queries cryptographically verifiable. This commit adds
the types-only foundation (no hash divergence yet — Phase 2 will introduce
node_hash_with_sum and the new proof Node variants).
DISCRIMINANTS
- Element::ProvableSumTree at variant index 17 / bincode discriminant 17
(next free after the NotSummed wrapper byte at 16). This will renumber
to 19 when PR #657 (CountIndexedTree) lands and reclaims 17/18.
- NonCountedProvableSumTree = 0x80 | 17 = 145.
- The NonCounted twin range widened from 0x80..=0x8F (4-bit base) to
0x80..=0x9F (5-bit base) — is_non_counted() now checks the top 3 bits
(& 0xe0 == 0x80) instead of the top 4. Existing twins 128..=142 stay put.
- The NotSummed twin scheme rebases analogously: prefix 0xb0 -> 0xa0,
base mask 0x0F -> 0x1F, family range 0xA0..=0xBF. Existing twins move:
NotSummedSumTree 180 -> 164
NotSummedBigSumTree 181 -> 165
NotSummedCountSumTree 183 -> 167
NotSummedProvableCountSumTree 186 -> 170
Plus the new NotSummedProvableSumTree = 0xa0 | 17 = 177.
Safe because V1 is pre-shipping. is_not_summed() now uses & 0xe0 == 0xa0.
NEW APIS
- ElementType::ProvableSumTree, ElementType::NonCountedProvableSumTree,
ElementType::NotSummedProvableSumTree.
- TreeType::ProvableSumTree (discriminant 11, is_sum_bearing = true,
allows_sum_item = true, inner_node_type = ProvableSumNode).
- NodeType::ProvableSumNode and TreeFeatureType::ProvableSummedMerkNode(i64)
with encode tag byte 7 and a parallel zero_sum() helper alongside
zero_count().
- Element::new_provable_sum_tree*, empty_provable_sum_tree*, plus helpers
(as_provable_sum_tree_value, is_provable_sum_tree).
- Element::NotSummed now accepts ProvableSumTree as a sum-tree inner type
(constructor, serialize, deserialize).
PROOF DISPATCH
ProvableSumTree joins the "provable aggregate parent" family alongside
ProvableCountTree / ProvableCountSumTree in ElementType::proof_node_type:
subtree children use KvValueHashFeatureType and item children use KvCount.
PHASE-1 SCOPE BOUNDARIES
ProvableSumTree behaves identically to SumTree for storage, aggregation,
and hashing in Phase 1. The divergent node_hash_with_sum and the new
proof Node variants (KVSum, KVHashSum, etc.) land in Phase 2.
TreeFeatureType::ProvableSummedMerkNode maps to AggregateData::Sum at the
Element/aggregate level for now; Phase 2 may introduce a dedicated variant
once the hash diverges.
Workspace cargo test --all-features green (1497+ tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments