View Source ekeyx (ekeyx v1.0.0)

Shamir's Secret Sharing (SSS) algorithm

byte-compatible to Hashicorp Vault's implementation of Shamir's Secret Sharing (SSS) algorithm.

Summary

Functions

Generate secret shares using Shamir's Secret Sharing algorithm.

Generate secret shares using Shamir's Secret Sharing algorithm.

Recover secret from shares.

Recover secret from shares.

Functions

Link to this function

generate_shares(K, N, Secret)

View Source
-spec generate_shares(K :: pos_integer(), N :: pos_integer(), Secret :: nonempty_binary()) ->
                         Shares :: [binary(), ...].

Generate secret shares using Shamir's Secret Sharing algorithm.

Equivalent to generate_shares(K, N, Secret, binary)

Link to this function

generate_shares(K, N, Secret, Base)

View Source
-spec generate_shares(K :: pos_integer(),
                      N :: pos_integer(),
                      Secret :: nonempty_binary(),
                      Base :: binary | base16 | base64) ->
                         Shares :: [binary(), ...].

Generate secret shares using Shamir's Secret Sharing algorithm.

Parameters

  • K: number of shares required to recover the secret
  • N: number of total shares to generate
  • Secret : binary of the raw secret to split N ways, requiring K shares to recover.
  • Base : output encoding
-spec recover_secret(Shares :: [binary(), ...]) -> Secret :: nonempty_binary().

Recover secret from shares.

Number of shares must be equal or greater than the K parameter used to generate shares.

Link to this function

recover_secret(Shares, Base)

View Source
-spec recover_secret(Shares :: [binary(), ...], Base :: binary | base16 | base64) ->
                        Secret :: nonempty_binary().

Recover secret from shares.

Equivalent to recover_secret(Shares, binary)