28 lines
650 B
Rust
Raw Normal View History

2025-08-12 13:10:46 -03:00
use std::io::{Cursor, Read};
2025-08-12 22:35:07 -03:00
use crate::{PublicKey, Signature, error::NssaError};
2025-08-12 13:10:46 -03:00
impl PublicKey {
2025-08-12 22:35:07 -03:00
pub(crate) fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaError> {
2025-08-12 13:10:46 -03:00
let mut value = [0u8; 32];
2025-08-12 22:35:07 -03:00
cursor.read_exact(&mut value)?;
Ok(Self(value))
2025-08-12 13:10:46 -03:00
}
pub(crate) fn to_bytes(&self) -> &[u8] {
&self.0
}
2025-08-12 13:10:46 -03:00
}
impl Signature {
2025-08-12 22:35:07 -03:00
pub(crate) fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaError> {
2025-08-12 13:10:46 -03:00
let mut value = [0u8; 64];
2025-08-12 22:35:07 -03:00
cursor.read_exact(&mut value)?;
Ok(Self { value })
2025-08-12 13:10:46 -03:00
}
pub(crate) fn to_bytes(&self) -> &[u8] {
&self.value
}
2025-08-12 13:10:46 -03:00
}