drive/verify/shielded/verify_shielded_anchors/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use crate::verify::RootHash;
7use dpp::version::PlatformVersion;
8
9impl Drive {
10    /// Verifies a proof for the valid shielded anchors.
11    pub fn verify_shielded_anchors(
12        proof: &[u8],
13        verify_subset_of_proof: bool,
14        platform_version: &PlatformVersion,
15    ) -> Result<(RootHash, Vec<[u8; 32]>), Error> {
16        match platform_version
17            .drive
18            .methods
19            .verify
20            .shielded
21            .verify_shielded_anchors
22        {
23            0 => Self::verify_shielded_anchors_v0(proof, verify_subset_of_proof, platform_version),
24            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
25                method: "verify_shielded_anchors".to_string(),
26                known_versions: vec![0],
27                received: version,
28            })),
29        }
30    }
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36    use dpp::version::PlatformVersion;
37
38    #[test]
39    fn test_verify_shielded_anchors_unknown_version_mismatch() {
40        let mut platform_version = PlatformVersion::latest().clone();
41        platform_version
42            .drive
43            .methods
44            .verify
45            .shielded
46            .verify_shielded_anchors = 255;
47
48        let result = Drive::verify_shielded_anchors(&[], false, &platform_version);
49
50        assert!(
51            matches!(
52                result,
53                Err(Error::Drive(DriveError::UnknownVersionMismatch { .. }))
54            ),
55            "expected UnknownVersionMismatch, got {:?}",
56            result,
57        );
58    }
59}