Skip to main content

drive/verify/document_having/verify_having_range_proof/
mod.rs

1mod v0;
2
3use crate::error::drive::DriveError;
4use crate::error::Error;
5use crate::query::DriveDocumentHavingQuery;
6use crate::verify::RootHash;
7use dpp::version::PlatformVersion;
8
9impl DriveDocumentHavingQuery<'_> {
10    /// Verifies a grovedb indexed-axis range proof and returns
11    /// `(root_hash, entries)`.
12    ///
13    /// Counterpart to the prover-side
14    /// [`execute_range_with_proof`](Self::execute_range_with_proof).
15    /// Both sides derive the proved subtree from
16    /// [`indexed_property_name_tree_path`](Self::indexed_property_name_tree_path)
17    /// and the same bounded axis `PathQuery` from
18    /// [`AxisRangeBounds::i128_bounds`](crate::query::drive_document_having_query::AxisRangeBounds::i128_bounds),
19    /// so the verifier cannot drift from the prover on *which* bound over
20    /// *which* tree it is checking.
21    ///
22    /// The returned entries are in axis order in the walk direction,
23    /// exactly as the unproven
24    /// [`execute_range_no_proof`](Self::execute_range_no_proof) would
25    /// return them. The caller combines `root_hash` with the surrounding
26    /// tenderdash signature — see `rs-drive-proof-verifier` for the
27    /// canonical composition.
28    ///
29    /// # Arguments
30    /// * `proof` — raw grovedb proof bytes.
31    /// * `platform_version` — selects the method version.
32    pub fn verify_having_range_proof(
33        &self,
34        proof: &[u8],
35        platform_version: &PlatformVersion,
36    ) -> Result<(RootHash, Vec<crate::query::RankedEntry>), Error> {
37        match platform_version
38            .drive
39            .methods
40            .verify
41            .document_ranked
42            .verify_having_range_proof
43        {
44            0 => self.verify_having_range_proof_v0(proof, platform_version),
45            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
46                method: "DriveDocumentHavingQuery::verify_having_range_proof".to_string(),
47                known_versions: vec![0],
48                received: version,
49            })),
50        }
51    }
52}