[][src]Enum sss_rs::sharer::Secret

pub enum Secret {
    InMemory(Vec<u8>),
    InFile(String),
}

Contains the secret, whether in file or in memory stored in a Vec of bytes. This can be used for both sharing and reconstructing. When reconstructing, you can set it to reconstruct into a Vec by setting it to InMemory, or you can set it to output to a file. For sharing, you can input a secret to be shared, either a file or a vec of bytes.

Variants

InMemory(Vec<u8>)
InFile(String)

Methods

impl Secret[src]

pub fn empty_in_memory() -> Self[src]

Constructs an empty vec for the secret.

pub fn empty_in_memory_with_capacity(capacity: usize) -> Self[src]

Constructs an empty vec for the secret but allocates an intial capacity.

pub fn point_at_file(path: &str) -> Self[src]

(u8, u8)s the secret to a file. This file can either be a source for the secret, or an output file for reconstructing a secret

pub fn len(&self) -> Result<u64, Box<dyn Error>>[src]

Attempts to get the length of the Secret. This can fail if the secret is a file path that doesn't exist.

pub fn calculate_hash(&self) -> Result<Vec<u8>, Box<dyn Error>>[src]

Calculates and returns the Sha3-512 hash of the first 64 bytes of the secret. This is mainly used for verifying secret reconstruction, where the chances of incorrect reconstruction resulting in the first 64 bytes being correct is extremely low.

If $secret.len() is less than 64 bytes, then only $secret.len() number of bytes is used.

pub fn get_hash_hex(&self) -> Result<String, Box<dyn Error>>[src]

Calculcates and returns the hash of the first 64 bytes of the share in a string with hexidecimal digits.

pub fn verify(&self, hash: &[u8]) -> Result<bool, Box<dyn Error>>[src]

Calculates a hash and compares it to the given hash. Returns Ok(true) if they're equivalent, Ok(false) if they aren't or an error if there was an issue calculating the hash (likely a read error if Secret was a file)

pub fn reconstruct_from_srcs(
    &mut self,
    srcs: &mut Vec<Box<dyn Read>>,
    src_len: u64
) -> Result<(), Box<dyn Error>>
[src]

Reconstructs a secret from a given list of srcs. The srcs should all read the same number of bytes. $src_len MUST be an accurate length of the shares

pub fn reconstruct_from_files(
    &mut self,
    dir: &str,
    stem: &str,
    shares_required: u8
) -> Result<(), Box<dyn Error>>
[src]

Performs the reconstruction of the shares. No validation is done at the moment to verify that the reconstructed secret is correct.

Trait Implementations

impl<'_> IntoIterator for &'_ Secret[src]

type Item = Result<Vec<u8>, Box<dyn Error>>

The type of the elements being iterated over.

type IntoIter = SecretIterator

Which kind of iterator are we turning this into?

impl Debug for Secret[src]

Auto Trait Implementations

impl Send for Secret

impl Sync for Secret

impl Unpin for Secret

impl UnwindSafe for Secret

impl RefUnwindSafe for Secret

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]