Skip to content

Commit

Permalink
Get everything under the TSS module
Browse files Browse the repository at this point in the history
  • Loading branch information
grempe committed Apr 11, 2016
1 parent 0a9bd54 commit 735c47a
Show file tree
Hide file tree
Showing 15 changed files with 814 additions and 805 deletions.
2 changes: 0 additions & 2 deletions exe/tss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# encoding: utf-8

$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')

require 'tss/cli'

TSS::CLI.start
6 changes: 3 additions & 3 deletions lib/tss.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rubygems'
require 'digest'
require 'base64'
require 'binary_struct'
require 'dry-types'
require 'tss/version'
Expand All @@ -16,13 +16,13 @@ def self.split(args)
unless args.is_a?(Hash) && args.key?(:secret)
raise TSS::ArgumentError, 'TSS.split takes a Hash of arguments with at least a :secret key'
end
Splitter.new(args).split
TSS::Splitter.new(args).split
end

def self.combine(args)
unless args.is_a?(Hash) && args.key?(:shares)
raise TSS::ArgumentError, 'TSS.combine takes a Hash of arguments with at least a :shares key'
end
Combiner.new(args).combine
TSS::Combiner.new(args).combine
end
end
2 changes: 1 addition & 1 deletion lib/tss/blank.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Extracted from active_support gem.
# Extracted from activesupport gem.
# https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/activesupport/lib/active_support/core_ext/object/blank.rb
class Object
# An object is blank if it's false, empty, or a whitespace string.
Expand Down
7 changes: 6 additions & 1 deletion lib/tss/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ module TSS
class CLI < Thor
desc "split SECRET", "split SECRET"
def split(secret)
puts "split #{secret}!"
TSS.split(secret: secret).each do |share|
h = TSS::Util.extract_share_header(share)
identifier = h[:identifier].delete("\x00")
threshold = h[:threshold]
puts "tss-v1-#{identifier}-#{threshold}-" + Base64.urlsafe_encode64(share)
end
end

desc "combine SHARES", "combine SHARES"
Expand Down
Loading

0 comments on commit 735c47a

Please sign in to comment.