Serialize the attestation to bytes. Format: `[MAGIC: 4 bytes][postcard payload]` The hash is computed over the entire serialized output.
(&self)
| 392 | /// |
| 393 | /// The hash is computed over the entire serialized output. |
| 394 | pub fn serialize(&self) -> Result<Vec<u8>, AttestationError> { |
| 395 | let payload = postcard::to_allocvec(self).map_err(|e| AttestationError::Codec { |
| 396 | reason: format!("postcard serialize failed: {}", e), |
| 397 | })?; |
| 398 | |
| 399 | let mut buf = Vec::with_capacity(MAGIC.len() + payload.len()); |
| 400 | buf.extend_from_slice(MAGIC); |
| 401 | buf.extend_from_slice(&payload); |
| 402 | Ok(buf) |
| 403 | } |
| 404 | |
| 405 | /// Deserialize an attestation from bytes, returning the attestation and its hash. |
| 406 | /// |
no test coverage detected