Create a signature from a byte slice.
(bytes: &[u8])
| 55 | |
| 56 | /// Create a signature from a byte slice. |
| 57 | pub fn from_slice(bytes: &[u8]) -> Result<Self, IdentityError> { |
| 58 | if bytes.len() != SIGNATURE_SIZE { |
| 59 | return Err(IdentityError::InvalidSignature); |
| 60 | } |
| 61 | |
| 62 | let mut arr = [0u8; SIGNATURE_SIZE]; |
| 63 | arr.copy_from_slice(bytes); |
| 64 | Ok(Signature(arr)) |
| 65 | } |
| 66 | |
| 67 | /// Get the raw bytes of the signature. |
| 68 | pub fn as_bytes(&self) -> &[u8; SIGNATURE_SIZE] { |