0.0
No commit activity in last 3 years
No release in over 3 years
Split and reconstruct secrets using the shamir's secret sharing algorithm
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Gem Version Build Status Test Coverage Code Climate Inline docs

secret_sharing

Warning: This implementation has not been tested in production nor has it been examined by a security audit. All uses are your own responsibility.

A ruby implementation of Shamir's Secret Sharing.

Installation

Add this line to your application's Gemfile:

gem 'secret_sharing'

And then execute:

$ bundle

Or install it yourself as:

$ gem install secret_sharing

Implementation details

This implementation of Shamir's Secret Sharing has initially been developed to be used in duse, however, it is designed to be used in any other context just as well.

The representation of a share is simply a pair of integers represented as a Point. We chose to be unopionated in terms of a string representation of a share, mainly to make it easier for this library to become compatible with other implementations.

When generating a random polynomial, we make sure the coefficients are random, but never zero. If we would allow the coefficients to be zero, it could result in a lower threshold than intended. For example, if the threshold is three, then the degree of the polynomial would be two so in the form of f(x)=a0 + a1*x + a2*x^2. If a2 would be zero than the polynomial would be of dergree one, which would result in a real threshold of two rather than three.

Usage

require "secret_sharing"
shares = SecretSharing.split("my secret", 2, 3)
# => [<SecretSharing::Point @x=1, @y=5098750880207642474240885>, <SecretSharing::Point @x=2, @y=10197493837875874270610422>, <SecretSharing::Point @x=3, @y=15296236795544106066979959>]
secret = SecretSharing.combine(shares[0..1]) # two shares are enough to reconstruct!
# => "my secret"

Further documentation on rubydoc.

Rubies

Tested on

  • Ruby MRI
  • JRuby

Contributing

  1. Fork it ( https://github.com/duse-io/secret_sharing_ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request