A pure-Ruby implementation of Shamir's Secret Sharing.
Please be aware that this gem has not undergone any form of security evaluation. This gem is not recommended for usage under mission-critical circumstances and should not be relied upon to protect confidential or secret information. Users should assume that this gem is insecure until they can independently confirm otherwise.
This gem is a minimal implementation of Shamir's Secret Sharing in Ruby that may be used to split a secret piece of text into a list of shares from which that text may later be recovered. By default, CLOVERSPLITTER uses the 18th Mersenne prime for share generation and produces a total of six shares with a minimum of three shares required for recovery. Although these defaults may be changed through optional parameters in the CloverSplitter.generate_shares
function, doing so is not recommended and may cause errors or issues with secrecy and recovery.
- Ruby >= 2.5.5 (CLOVERSPLITTER has not been tested on anything below 2.5.5)
- SecureRandom (included in the Ruby Standard Library)
CLOVERSPLITTER can be installed as follows:
gem install cloversplitter
A list of six shares (with a minimum of three shares required for secret recovery) may be generated as follows:
secret = "This is a secret piece of text!"
full_list = CloverSplitter.generate_shares(secret)
After a list of shares has been generated, the secret to which those shares pertain may be recovered from that list as follows:
recovered_secret = CloverSplitter.recover_secret(full_list)
The secret can also be recovered from a subset of the original shares, provided that the number of shares contained within that subset is equal to or greater than the minimum number of shares required for recovery:
partial_list = full_list[0, 3]
recovered_secret = CloverSplitter.recover_secret(partial_list)
Copyright (C) 2020 Peter Bruce Funnell
This project is licensed under the MIT License. See the LICENSE file for details.
If you found this project useful and would like to encourage me to continue making open source software, please consider making a donation via the following link:
https://www.buymeacoffee.com/peterfunnell
Donations in Bitcoin (BTC) are also very welcome. My BTC wallet address is as follows:
3EdoXV1w8H7y7M9ZdpjRC7GPnX4aouy18g