[][src]Trait xaynet::crypto::ByteObject

pub trait ByteObject: Sized {
    const LENGTH: usize;

    fn zeroed() -> Self;
fn as_slice(&self) -> &[u8];
fn from_slice(bytes: &[u8]) -> Option<Self>; fn from_slice_unchecked(bytes: &[u8]) -> Self { ... }
fn generate() -> Self { ... } }

An interface for slicing into cryptographic byte objects.

Associated Constants

const LENGTH: usize

Length in bytes of this object

Loading content...

Required methods

fn zeroed() -> Self

Creates a new object with all the bytes initialized to 0.

fn as_slice(&self) -> &[u8]

Gets the object byte representation.

fn from_slice(bytes: &[u8]) -> Option<Self>

Creates an object from the given buffer.

Errors

Returns None if the length of the byte-slice isn't equal to the length of the object.

Loading content...

Provided methods

fn from_slice_unchecked(bytes: &[u8]) -> Self

Creates an object from the given buffer.

Panics

Panics if the length of the byte-slice isn't equal to the length of the object.

fn generate() -> Self

Generates an object with random bytes

Loading content...

Implementors

impl ByteObject for EncryptKeySeed[src]

impl ByteObject for PublicEncryptKey[src]

impl ByteObject for PublicSigningKey[src]

impl ByteObject for SecretEncryptKey[src]

impl ByteObject for SecretSigningKey[src]

impl ByteObject for Sha256[src]

impl ByteObject for Signature[src]

impl ByteObject for SigningKeySeed[src]

impl ByteObject for EncryptedMaskSeed[src]

impl ByteObject for MaskSeed[src]

impl ByteObject for RoundSeed[src]

fn from_slice(bytes: &[u8]) -> Option<Self>[src]

Creates a round seed from a slice of bytes.

Errors

Fails if the length of the input is invalid.

fn zeroed() -> Self[src]

Creates a round seed initialized to zero.

fn as_slice(&self) -> &[u8][src]

Gets the round seed as a slice.

Loading content...