From e421ed317f90992f3afd7739e8a98152d3f0bec8 Mon Sep 17 00:00:00 2001 From: Alexander Klink Date: Sun, 19 Sep 2010 14:06:10 +0200 Subject: [PATCH] README, Rakefile, gemspec --- README | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ Rakefile | 22 +++++++++++++++++ secretsharing.gemspec | 27 +++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 README create mode 100644 Rakefile create mode 100644 secretsharing.gemspec diff --git a/README b/README new file mode 100644 index 0000000..79b1ed6 --- /dev/null +++ b/README @@ -0,0 +1,67 @@ +== Description + A libary for sharing secrets in an information-theoretically secure way. + It uses Shamir's secret sharing to enable sharing a (random) secret between + n persons where k <= n persons are enough to recover the secret. k-1 secret + share holders learn nothing about the secret when they combine their shares. + + This library is based on the OpenXPKI::Crypto::Secret::Split Perl module used + in the open source PKI software OpenXPKI, which was written by Alexander Klink + for the OpenXPKI project in 2006. + +== Prerequisites + This package requires Ruby 1.8 or later. + +== Installation instructions + rake test (optional) + rake install (non-gem) or rake install_gem (gem) + +== Synopsis + require 'secretsharing' + + # create an object for 3 out of 5 secret sharing + s = SecretSharing::Shamir.new(5,3) + + # create a random secret (returns the secret) + s.create_random_secret() + + # show secret + puts s.secret + + # show shares + s.shares.each { |share| puts share } + + # recover secret from shares + + s2 = SecretSharing::Shamir.new(3) + # accepts SecretSharing::Shamir::Share objects or + # string representations thereof + s2 << s.shares[0] + s2 << s.shares[2] + s2 << s.shares[4] + puts s2.secret + +== Future Plans + Add support for using your own instead of a random secret. + +== Copyright + (c) 2010 Alexander Klink + +== License + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +== Warranty + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +== Author + Alexander Klink + secretsharing@alech.de + http://www.alech.de + @alech on Twitter diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..99cb332 --- /dev/null +++ b/Rakefile @@ -0,0 +1,22 @@ +require 'rake' +require 'rake/testtask' + +desc "Install the secretsharing package (non-gem)" +task :install do + dest = File.join(Config::CONFIG['sitelibdir'], 'secretsharing') + Dir.mkdir(dest) unless File.exists? dest + cp 'lib/secretsharing/shamir.rb', dest, :verbose => true +end + +desc 'Install the secretsharing package as a gem' +task :install_gem do + ruby 'secretsharing.gemspec' + file = Dir["*.gem"].first + sh "gem install #{file}" +end + +Rake::TestTask.new do |t| + t.libs << 'lib' + t.warning = true + t.test_files = FileList['test/test_*'] +end diff --git a/secretsharing.gemspec b/secretsharing.gemspec new file mode 100644 index 0000000..9ec6ecf --- /dev/null +++ b/secretsharing.gemspec @@ -0,0 +1,27 @@ +require 'rubygems' + +spec = Gem::Specification.new do |gem| + gem.name = 'secretsharing' + gem.version = '0.1' + gem.author = 'Alexander Klink' + gem.email = 'secretsharing@alech.de' + gem.platform = Gem::Platform::RUBY + gem.summary = 'A library to share secrets in an information-theoretically secure way.' + gem.description =<<'XEOF' +A libary for sharing secrets in an information-theoretically secure way. +It uses Shamir's secret sharing to enable sharing a (random) secret between +n persons where k <= n persons are enough to recover the secret. k-1 secret +share holders learn nothing about the secret when they combine their shares. +XEOF + gem.test_file = 'test/test_shamir.rb' + gem.has_rdoc = 'true' + gem.require_path = 'lib' + gem.extra_rdoc_files = [ 'README' ] + + gem.files = Dir['lib/secretsharing.rb'] + Dir['lib/secretsharing/*'] + Dir['test/test_shamir.rb'] +end + +if $0 == __FILE__ + Gem.manage_gems + Gem::Builder.new(spec).build +end -- 2.11.4.GIT