[][src]Module sss_rs::raw_share

Structs

CO_MAX
CO_MIN
DEFAULT_PRIME

Enums

Error

Local Error enum, used to report errors that would only occur within this file.

ShuffleOp

Used to specify the shuffle operation to be used, ReverseShuffle undoes Shuffle and vice-versa when given the same hash.

Functions

create_share_lists_from_secrets

This is a wrapper around @create_share_from_secret that loops through the @secret slice and returns a vector of vectors, with each vector being all the shares for a single byte of the secret. The format this returns the secrets in is: share1byte1, share1byte2, share1byte3, ..., share1byte<share_lists.len()> share2byte1, share2byte2, share2byte3, ..., share2byte<share_lists.len()> since that is how they would be distributed. @secret: A slice of bytes to be used to create the vector of share vectors ... For the rest of the arguments, see @create_shares_from_secret

create_share_lists_from_secrets_custom_rng

See $create_shares_from_secret for documentation This function is similar except that a custom RNG can be used to produce the coefficients. NOTE: USE WITH CAUTION, static seeding can lead to predictable sharing and loss of unconditional security.

create_shares_from_secret

Creates a vector of points that serve as the list of shares for a given byte of data. @secret: The secret value that is to be split into shares @prime: The prime number that is used to generate a finite field to increase security. This is not checked to be prime, so no errors will be reported if this value isn't prime, which must be done outside this function for efficiency. @shares_required: The number of shares required to recreate the secret @shares_to_create: The number of shares to create, so any number 'x' shares from the total 'y' shares are enough to recreate the secret. If < shares_required, it's automatically bumped up. @co_max_bits: The maximum number of bits for the randomly generated coefficients of the polynomial hide the secret. If @co_max_bits == 0, this function will panic.

create_shares_from_secret_custom_rng

See $create_shares_from_secret for documentation This function is similar except that a custom RNG can be used to produce the coefficients. NOTE: USE WITH CAUTION, static seeding can lead to predictable sharing and loss of unconditional security.

reconstruct_secret

Reconstructs a secret from a given Vector of shares (points) and returns that secret. No guarantees are made that the shares are valid together and that the secret is valid. If there are enough shares, a secret will be generated. @shares: The vector of shares that are used to regenerate the polynomial and finding the secret. @shares.len() must be >= @shares_needed, else this will return an error. @prime: The original prime used to generate the shares. No guarantees are made that this prime is indeed the original prime, this must be kept from when the shares were generated. This value is also not checked to be prime, which must be done outside this function for efficieny.

reconstruct_secrets_from_share_lists

This is a wrapper around @reconstruct_secret that iterates over each Vec of shares and reconstructs their respective byte of the secret. It expects the shares to be in this format: share1byte1, share1byte2, share1byte3, ..., share1byte<share_lists.len()> share2byte1, share2byte2, share2byte3, ..., share2byte<share_lists.len()> since that is how they would be distributed. @share_lists: A Vec of Vecs, with each Vec containing the shares needed to reconstruct a byte of the secret. ... For the rest of the arguments, see @reconstruct_secret

shuffle_share_lists

A wrapper around shuffle_shares which iterates through a list of share lists and shuffles each one in the same way The share lists must be shuffled and unshuffled with the same password, no checking is done to ensure the password is correct. PRECAUTION: Do not attempt to unshuffle without a copy of the original shuffled share lists so if an incorrect password is accidentally entered and that copy is permamently corrupted, the backup can be used to attempt it again. Some measures could also be taken for verification of the unshuffled reconstructed share but that is left up to library users.

transpose_vec_matrix

Transposes a Vec of Vecs if it is a valid matrix. If it is not an error is returned. @matrix: The matrix to be transposed, must be a valid matrix else an error is returned.