mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 23:33:10 +00:00
28 lines
660 B
Rust
28 lines
660 B
Rust
use std::io::{Cursor, Read};
|
|
|
|
use crate::{PublicKey, Signature, error::NssaError};
|
|
|
|
impl PublicKey {
|
|
pub(crate) fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaError> {
|
|
let mut value = [0u8; 32];
|
|
cursor.read_exact(&mut value)?;
|
|
Self::try_new(value)
|
|
}
|
|
|
|
pub(crate) fn to_bytes(&self) -> &[u8] {
|
|
self.value()
|
|
}
|
|
}
|
|
|
|
impl Signature {
|
|
pub(crate) fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaError> {
|
|
let mut value = [0u8; 64];
|
|
cursor.read_exact(&mut value)?;
|
|
Ok(Self { value })
|
|
}
|
|
|
|
pub(crate) fn to_bytes(&self) -> &[u8] {
|
|
&self.value
|
|
}
|
|
}
|