Serialize the attestation to bytes. Format: `[MAGIC: 4 bytes][postcard payload]` The hash is computed over the entire serialized output.
(&self)
| 191 | /// |
| 192 | /// The hash is computed over the entire serialized output. |
| 193 | pub fn serialize(&self) -> Result<Vec<u8>, AttestationError> { |
| 194 | let payload = postcard::to_allocvec(self).map_err(|e| AttestationError::Codec { |
| 195 | reason: format!("postcard serialize failed: {}", e), |
| 196 | })?; |
| 197 | |
| 198 | let mut buf = Vec::with_capacity(MAGIC.len() + payload.len()); |
| 199 | buf.extend_from_slice(MAGIC); |
| 200 | buf.extend_from_slice(&payload); |
| 201 | Ok(buf) |
| 202 | } |
| 203 | |
| 204 | /// Deserialize an attestation from bytes, returning the attestation and its hash. |
| 205 | /// |
no test coverage detected