repo.or.cz
/
secretsharing.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
raise error if k > n
[secretsharing.git]
/
lib
/
secretsharing
/
shamir.rb
blob
74c2e94295fd5fef016c3faeeaaccf31ad647b77
1
module SecretSharing
2
class Shamir
3
attr_reader :n, :k, :secret
4
5
def initialize(n, k=n)
6
if k > n then
7
raise ArgumentError, 'k must be smaller or equal than n'
8
end
9
@n = n
10
@k = k
11
@secret = nil
12
@shares = []
13
end
14
15
def secret_set?
16
! @secret.nil?
17
end
18
end
19
end