Skip to content

Commit bdf19b3

Browse files
committed
Passing tests
1 parent a0ea1aa commit bdf19b3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

lib/sssa.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ def self.isValidShare?(candidate)
102102
count = candidate.size / 44
103103
for j in 0..count
104104
part = candidate[j*44, (j+1)*44]
105-
decode = self.from_base64(part)
106-
if decode < 0 || decode > self.prime
105+
decode = @util.from_base64(part)
106+
if decode < 0 || decode > @prime
107107
return false
108108
end
109109
end
110+
111+
return true
110112
end
111113
end

sssa.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = 'sssa-ruby'
3-
s.version = '0.0.2'
4-
s.date = '2015-11-07'
3+
s.version = '0.0.3'
4+
s.date = '2016-01-17'
55
s.summary = "Shamir's Secret Sharing Algorithm"
66
s.description = "Helper cryptography module for Ruby"
77
s.authors = ["Alexander Scheel"]

tests/sssa.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ def test_library_combine()
1717

1818
assert_equal("test-pass", SSSA::combine(shares))
1919
end
20+
21+
def test_library_isValidShare?()
22+
shares = ["U1k9koNN67-og3ZY3Mmikeyj4gEFwK4HXDSglM8i_xc=yA3eU4_XYcJP0ijD63Tvqu1gklhBV32tu8cHPZXP-bk=", "O7c_iMBaGmQQE_uU0XRCPQwhfLBdlc6jseTzK_qN-1s=ICDGdloemG50X5GxteWWVZD3EGuxXST4UfZcek_teng=", "8qzYpjk7lmB7cRkOl6-7srVTKNYHuqUO2WO31Y0j1Tw=-g6srNoWkZTBqrKA2cMCA-6jxZiZv25rvbrCUWVHb5g=", "wGXxa_7FPFSVqdo26VKdgFxqVVWXNfwSDQyFmCh2e5w=8bTrIEs0e5FeiaXcIBaGwtGFxeyNtCG4R883tS3MsZ0=", "j8-Y4_7CJvL8aHxc8WMMhP_K2TEsOkxIHb7hBcwIBOo=T5-EOvAlzGMogdPawv3oK88rrygYFza3KSki2q8WEgs=", "Hello world"]
23+
24+
results = [true, true, true, true, true, false]
25+
26+
shares.each_with_index do |value, index|
27+
assert_equal(results[index], SSSA::isValidShare?(value))
28+
end
29+
end
2030
end

0 commit comments

Comments
 (0)