An implementation of Shamir's Secret Sharing:
your secret is encrypted into N
keys, of which only K
are needed to
reconstruct the original secret.
Check the README for tips on usage!
encryptBytes : { seed : Random.Seed, parts : Basics.Int, minPartsNeeded : Basics.Int } -> Bytes -> Result EncryptError ( List Key.Internal.Key, Random.Seed )
Allows splitting the Bytes secret to a given number of keys.
encryptString : { seed : Random.Seed, parts : Basics.Int, minPartsNeeded : Basics.Int } -> String -> Result EncryptError ( List Key.Internal.Key, Random.Seed )
Allows splitting the String secret to a given number of keys.
Compared to encryptBytes
, adds one extra 32bit integer at the beginning, saying
how many UTF-8 bytes the string has. This is required for correct reconstruction
later with decryptString
.
These validation rules are in effect:
decryptBytes : List Key.Internal.Key -> Result DecryptError Bytes
Allows deconstructing the Bytes secret from the given keys.
decryptString : List Key.Internal.Key -> Result DecryptError String
Allows deconstructing the String secret from the given keys.
Compared to decryptBytes
, requires one extra 32bit integer at the beginning,
saying how many UTF-8 bytes the string has. This is given automatically during
encryption with encryptString
.
The library will fail decrypting if:
decryptString