pub fn deserialize_32_bytes<'de, D>(
deserializer: D,
) -> Result<[u8; 32], D::Error>where
D: Deserializer<'de>,Expand description
Custom serialization for 32-byte arrays (challenge params, public keys)
Deserializes a byte sequence back into a fixed-size 32-byte array, with strict length validation to ensure cryptographic correctness.
§Arguments
deserializer: The serde deserializer instance that will handle the actual deserialization from the source format.
§Returns
Result<[u8; 32], D::Error>: A 32-byte array on success, or a deserialization error if the operation fails or the byte length is incorrect.
§Type Parameters
D: The deserializer type that implements theDeserializertrait.
§Errors
- Returns a custom error if the deserialized byte sequence is not exactly 32 bytes long, (Requirement of the cryptographic primitive in use.)
§Example
use ironshield_types::deserialize_32_bytes;
#[derive(serde::Deserialize)]
struct CryptoKey {
#[serde(deserialize_with = "deserialize_32_bytes")]
public_key: [u8; 32],
}