// SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright (c) VexaHub and contributors. // Copyright (c) Meta Platforms, Inc. and affiliates. //! Includes a series of tests for the group implementations use crate::{Error, Group, Result}; // Test that the deserialization of a group element should throw an error if the // identity element can be deserialized properly #[test] fn test_group_properties() -> Result<()> { use p256::NistP256; use p384::NistP384; use p521::NistP521; #[cfg(feature = "ristretto255")] { use crate::Ristretto255; test_identity_element_error::()?; test_zero_scalar_error::()?; } test_identity_element_error::()?; test_zero_scalar_error::()?; test_identity_element_error::()?; test_zero_scalar_error::()?; test_identity_element_error::()?; test_zero_scalar_error::()?; Ok(()) } // Checks that the identity element cannot be deserialized fn test_identity_element_error() -> Result<()> { let identity = G::identity_elem(); let result = G::deserialize_elem(&G::serialize_elem(identity)); assert!(matches!(result, Err(Error::Deserialization))); Ok(()) } // Checks that the zero scalar cannot be deserialized fn test_zero_scalar_error() -> Result<()> { let zero_scalar = G::zero_scalar(); let result = G::deserialize_scalar(&G::serialize_scalar(zero_scalar)); assert!(matches!(result, Err(Error::Deserialization))); Ok(()) }