amebazii::types::header

Struct KeyBlock

Source
pub struct KeyBlock { /* private fields */ }
Expand description

A struct representing the key block with two public keys:

  • an encryption public key and
  • a hash public key.

Implementations§

Source§

impl KeyBlock

Source

pub fn is_enc_pubkey_valid(&self) -> bool

Checks if the encryption public key is valid.

§Returns
  • true if the encryption public key is valid.
  • false if the encryption public key is invalid.
Source

pub fn is_hash_pubkey_valid(&self) -> bool

Checks if the hash public key is valid.

§Returns
  • true if the hash public key is valid.
  • false if the hash public key is invalid.
Source

pub fn get_enc_pubkey(&self) -> &[u8; 32]

Retrieves the encryption public key.

§Returns
  • A reference to the encryption public key (32 bytes).
Source

pub fn get_hash_pubkey(&self) -> &[u8; 32]

Retrieves the hash public key.

§Returns
  • A reference to the hash public key (32 bytes).
Source

pub fn get_enc_pubkey_mut(&mut self) -> &mut [u8; 32]

Retrieves a mutable reference to the encryption public key.

§Returns
  • A mutable reference to the encryption public key (32 bytes).
Source

pub fn get_hash_pubkey_mut(&mut self) -> &mut [u8; 32]

Retrieves a mutable reference to the hash public key.

§Returns
  • A mutable reference to the hash public key (32 bytes).

Trait Implementations§

Source§

impl BinarySize for KeyBlock

Source§

fn binary_size() -> usize

Returns the binary size of the KeyBlock in bytes.

Since the struct contains two 32-byte fields (enc_pubkey and hash_pubkey), the total size is 64 bytes.

§Returns
  • 64: The size in bytes required to serialize a KeyBlock.
Source§

impl Debug for KeyBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KeyBlock

Source§

fn default() -> Self

Creates a default KeyBlock with both public keys initialized to [0xFF; 32].

§Returns
  • A KeyBlock instance with both the encryption and hash public keys set to 0xFF.
Source§

impl FromStream for KeyBlock

Source§

fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
where R: Read + Seek,

Deserializes a KeyBlock from a stream.

This method reads 64 bytes (32 bytes for each of the enc_pubkey and hash_pubkey) from the provided reader and populates the KeyBlock instance fields accordingly.

§Parameters
  • reader: A mutable reference to a reader implementing io::Read and io::Seek.
§Returns
  • Ok(()): If the KeyBlock was successfully deserialized.
  • Err(Error): If an error occurs while reading from the stream.
Source§

impl ToStream for KeyBlock

Source§

fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + Seek,

Serializes a KeyBlock to a stream.

§Parameters
  • writer: A mutable reference to a writer implementing io::Write and io::Seek.
§Returns
  • Ok(()): If the KeyBlock was successfully written to the stream.
  • Err(Error): If an error occurs while writing to the stream.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.