-
Notifications
You must be signed in to change notification settings - Fork 51
Closed
Description
Feature Request: Expose Root Computation from VerifyLeafHashes
Description:
Currently, the VerifyLeafHashes function in the NMT library performs two operations internally:
- Computing the root from provided proof and data.
- Comparing the computed root with an existing root.
To facilitate use cases where root computation alone is required (without immediate comparison), we propose breaking down VerifyLeafHashes into two distinct functions. The main goal is to expose the root computation logic separately.
Proposed Change:
- Extract root computation into a separate, publicly accessible function, e.g.,
ComputeRoot(proof, data). - Update
VerifyLeafHashesto utilize this new function internally:
func ComputeRoot(proof Proof, data []byte) ([]byte, error) {
// Existing logic from VerifyInclusion to compute root
}
func VerifyLeafHashes(proof Proof, data []byte, root []byte) (bool, error) {
computedRoot, err := ComputeRoot(proof, data)
if err != nil {
return false, err
}
return bytes.Equal(root, computedRoot), nil
}Benefits:
- Allows consumers to recompute roots separately from verification, enabling more flexible use-cases and simplifying proofs.
- Minimal change, reusing approximately 99% of existing code.
Impact:
- Non-breaking change, backward-compatible.
- Minor refactor only; no new logic introduced.
Feedback and suggestions are welcome.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels