secretsharing 0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coco.yml +6 -0
- data/.gitignore +18 -0
- data/.rubocop.yml +29 -0
- data/.travis.yml +16 -0
- data/CHANGES +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.md +286 -0
- data/Rakefile +12 -0
- data/SIGNED.md +99 -0
- data/bin/secretsharing +111 -0
- data/gemfiles/Gemfile.ci +7 -0
- data/lib/secretsharing.rb +25 -0
- data/lib/secretsharing/shamir.rb +91 -293
- data/lib/secretsharing/shamir/container.rb +93 -0
- data/lib/secretsharing/shamir/secret.rb +123 -0
- data/lib/secretsharing/shamir/share.rb +156 -0
- data/lib/secretsharing/version.rb +20 -0
- data/secretsharing.gemspec +47 -0
- data/spec/shamir_container_spec.rb +373 -0
- data/spec/shamir_secret_spec.rb +208 -0
- data/spec/shamir_share_spec.rb +59 -0
- data/spec/shamir_spec.rb +35 -0
- data/spec/spec_helper.rb +33 -0
- metadata +204 -57
- data/README +0 -67
- data/test/test_shamir.rb +0 -161
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f098c9c10d0baf1c9fe59f3e78ac25fd328b562
|
4
|
+
data.tar.gz: 066705c6051aece363ef1fc94cc52afe74e84837
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 658a169db761f026d7521bf8def8ca80ca93d599d99f062ddcd49a4da163a72b204532bb05ef186988d3c200fbc0d2b5bbef407fda5926210f1bd69380de5ad1
|
7
|
+
data.tar.gz: 2c267a45c04ff7dbb20d00b393c418a523645b5596a3a1b1090fec1f812ef87e7af6861032cba297dccf9ce673a0383905d5a0db7137e0d1ad7db079d0066996
|
data/.coco.yml
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
LineLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Lambda:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
MethodLength:
|
8
|
+
Max: 35
|
9
|
+
|
10
|
+
ClassLength:
|
11
|
+
Max: 125
|
12
|
+
|
13
|
+
CyclomaticComplexity:
|
14
|
+
Max: 10
|
15
|
+
|
16
|
+
PerceivedComplexity:
|
17
|
+
Max: 10
|
18
|
+
|
19
|
+
HandleExceptions:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
HashSyntax:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
AbcSize:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
GuardClause:
|
29
|
+
MinBodyLength: 5
|
data/.travis.yml
ADDED
data/CHANGES
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
== v1.0.0
|
2
|
+
Version 1.0.0 is an almost complete rewrite of the original code.
|
3
|
+
This version is NOT backwards compatible with the shares generated
|
4
|
+
with previous version. The API for this version is significantly
|
5
|
+
changed as well. You will need to make some (hopefully simple)
|
6
|
+
code changes to use this newer version. See the README.md file
|
7
|
+
for details.
|
8
|
+
== v0.3
|
9
|
+
Added support for setting your own secret using the set_fixed_secret()
|
10
|
+
method.
|
11
|
+
|
12
|
+
== v0.2
|
13
|
+
Bugfix in Langrange interpolation, which broke 2/2 sharing.
|
14
|
+
Added secret_password method to represent the secret in Base64.
|
15
|
+
|
16
|
+
== v0.1
|
17
|
+
Initial version
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright {yyyy} {name of copyright owner}
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,286 @@
|
|
1
|
+
# SecretSharing
|
2
|
+
|
3
|
+
## Description
|
4
|
+
A Ruby gem for sharing secrets in an information-theoretically secure way.
|
5
|
+
|
6
|
+
It uses Shamir's secret sharing to enable sharing a (random) secret
|
7
|
+
between n persons where k <= n shares are enough to recover the secret.
|
8
|
+
|
9
|
+
k-1 secret share holders learn nothing about the secret when they combine their shares.
|
10
|
+
|
11
|
+
Learn More about [Shamir's Secret Sharing](http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing)
|
12
|
+
|
13
|
+
## Development History
|
14
|
+
|
15
|
+
This library is based on the OpenXPKI::Crypto::Secret::Split Perl module
|
16
|
+
used in the open source PKI software OpenXPKI, which was written by
|
17
|
+
Alexander Klink for the OpenXPKI project in 2006.
|
18
|
+
|
19
|
+
The original source code for Alexander Klink's 'secretsharing' gem
|
20
|
+
can be found at <http://repo.or.cz/w/secretsharing.git>
|
21
|
+
|
22
|
+
It has been further enhanced, modularized, and a full test suite
|
23
|
+
has been added by Glenn Rempe (<glenn@rempe.us>) and can be found
|
24
|
+
at <https://github.com/grempe/secretsharing> which is the new canonical
|
25
|
+
repository for the gem.
|
26
|
+
|
27
|
+
WARNING : The public API and the Share String format of the current version
|
28
|
+
of the Gem are *not* backwards compatible with 'secretsharing'
|
29
|
+
versions <= '0.3'.
|
30
|
+
|
31
|
+
## Should I use it?
|
32
|
+
|
33
|
+
This code has not yet been tested in production. It is seemingly well tested though with a full Minitest suite and 100% test code coverage and appears to be working well for what it was designed to do. The code also undergoes a continuous integration test run on many different Ruby runtimes upon every push.
|
34
|
+
|
35
|
+
The mathematics of the code, which is critical to its operation, and its suitability for use as a security product have not yet been tested or verified by security minded folks. `Yet`. If you are one of those strongly mathematically or security minded folks please do get in touch if you think you can help validate the current implementation. Suggestions or concerns welcome.
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
Add this line to your application's Gemfile:
|
40
|
+
|
41
|
+
gem 'secretsharing'
|
42
|
+
|
43
|
+
And then execute:
|
44
|
+
|
45
|
+
$ bundle
|
46
|
+
|
47
|
+
Or install it yourself as:
|
48
|
+
|
49
|
+
$ gem install secretsharing
|
50
|
+
|
51
|
+
## Usage in a Ruby/Rails project.
|
52
|
+
|
53
|
+
require 'secretsharing'
|
54
|
+
|
55
|
+
# create an object for 3 out of 5 secret sharing
|
56
|
+
c1 = SecretSharing::Shamir::Container.new(5,3)
|
57
|
+
|
58
|
+
# create a random secret (returns the secret)
|
59
|
+
c1.secret = SecretSharing::Shamir::Secret.new
|
60
|
+
|
61
|
+
# (or create a fixed secret of your choice by passing in an OpenSSL::BN object in the :secret arg)
|
62
|
+
c1.secret = SecretSharing::Shamir::Secret.new(:secret => OpenSSL::BN.new('123456789'))
|
63
|
+
|
64
|
+
# show secret
|
65
|
+
puts c1.secret
|
66
|
+
|
67
|
+
# show shares
|
68
|
+
c1.shares.each { |share| puts share }
|
69
|
+
|
70
|
+
# recover secret from shares by using a new Container
|
71
|
+
# where the number of Shares expected is the same.
|
72
|
+
c2 = SecretSharing::Shamir::Container.new(3)
|
73
|
+
|
74
|
+
# Accepts SecretSharing::Shamir::Share objects or
|
75
|
+
# string representations thereof
|
76
|
+
c2 << c1.shares[0]
|
77
|
+
c2 << c1.shares[2]
|
78
|
+
c2 << c1.shares[4]
|
79
|
+
|
80
|
+
c2.secret? #=> true
|
81
|
+
puts c2.secret
|
82
|
+
|
83
|
+
# Test that the secret used to generate the HMAC
|
84
|
+
# matches the HMAC of the secret that was re-constructed
|
85
|
+
c2.secret.valid_hmac? #=> true
|
86
|
+
|
87
|
+
## Usage via the command line CLI
|
88
|
+
|
89
|
+
First, use the `secretsharing` program to generate a set of Shares from a Secret
|
90
|
+
|
91
|
+
````
|
92
|
+
➜ secretsharing git:(master) ✗ secretsharing
|
93
|
+
|
94
|
+
Shamir's Secret Sharing
|
95
|
+
|
96
|
+
Would you like to 'encode' a new secret as shares, or 'decode' one from existing shares?
|
97
|
+
1. encode
|
98
|
+
2. decode
|
99
|
+
Action? 1
|
100
|
+
|
101
|
+
Would you like to create a 'random' secret, or will you provide a 'fixed' one?
|
102
|
+
1. random
|
103
|
+
2. fixed
|
104
|
+
Type? 1
|
105
|
+
How many total shares (n) do you want to distribute? 5
|
106
|
+
How many of the total shares (k) are required to reveal the secret? 3
|
107
|
+
|
108
|
+
========================================
|
109
|
+
Encoded Secret:
|
110
|
+
|
111
|
+
(k) Value: 3
|
112
|
+
(n) Value: 5
|
113
|
+
|
114
|
+
Secret (Bignum):
|
115
|
+
179040077567401061920833455639501686558874997550289562553628622313673068089718
|
116
|
+
|
117
|
+
Secret (Base64 Compacted & URL Safe):
|
118
|
+
OXY1eHdod3N0NXJ1MWEzZXBuMjgxZnN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ieSI6MjY3NTg2NzE3OTQxNjc0NTA1NjY5ODUzNzkwNjgwNzMzNjQyMjA0NTQ0NjUwODQ5MzM3NTg3NzE3MTU5MTUwNTEzNTk0NzM5MzMwNjcxMH0=
|
133
|
+
|
134
|
+
========================================
|
135
|
+
➜ secretsharing git:(master) ✗
|
136
|
+
````
|
137
|
+
|
138
|
+
Once that is done you can re-hydrate your Secret using any 3 out of the 5 Shares originally generated:
|
139
|
+
|
140
|
+
````
|
141
|
+
➜ secretsharing git:(master) ✗ secretsharing
|
142
|
+
|
143
|
+
Shamir's Secret Sharing
|
144
|
+
|
145
|
+
Would you like to 'encode' a new secret as shares, or 'decode' one from existing shares?
|
146
|
+
1. encode
|
147
|
+
2. decode
|
148
|
+
Action? 2
|
149
|
+
|
150
|
+
How many of shares (k) are required to reveal this secret? 3
|
151
|
+
|
152
|
+
Enter the '3' shares one at a time with a RETURN after each:
|
153
|
+
2gEqeyJobWFjIjoiMDVkNWNlOTIyNjk5ZTUxNzY4ODU2MmJlYjJiZDUzMTI4OTAyYTYzMjAxMjIxMjdjZTVhZjhlMmRiMmY2MmNkMiIsImsiOjMsIm4iOjUsInByaW1lIjozNzA1MzQ2ODU1NTk0MTE4MjUzNTU0MjcxNTIwMjc4MDEzMDUxMzA0NjM5NTA5MzAwNDk4MDQ5MjYyNjQyNjg4MjUzMjIwMTQ4NDc4MDU5LCJwcmltZV9iaXRsZW5ndGgiOjI2MSwidmVyc2lvbiI6MSwieCI6MSwieSI6OTE5NjU5ODE1Njg0MzAwODU5Mjg2OTU1ODMxMzg0NzA2NDQ1NTMyMzQxNDE5ODAyOTA5NzEwMDcxODU1MTgwMjUyMTYxMjk4Nzg0MzE2fQ==
|
154
|
+
2gEreyJobWFjIjoiMDVkNWNlOTIyNjk5ZTUxNzY4ODU2MmJlYjJiZDUzMTI4OTAyYTYzMjAxMjIxMjdjZTVhZjhlMmRiMmY2MmNkMiIsImsiOjMsIm4iOjUsInByaW1lIjozNzA1MzQ2ODU1NTk0MTE4MjUzNTU0MjcxNTIwMjc4MDEzMDUxMzA0NjM5NTA5MzAwNDk4MDQ5MjYyNjQyNjg4MjUzMjIwMTQ4NDc4MDU5LCJwcmltZV9iaXRsZW5ndGgiOjI2MSwidmVyc2lvbiI6MSwieCI6MiwieSI6MjI4MDcyMTc2NjA0NjUwODgwODE1ODY0MTc2ODQyOTY5NDkwODgyODY1OTY4Mzg4MzYyODAyNTE0NTI5MzI4NTE1NDI3Njg3NjM0ODkyNn0=
|
155
|
+
2gEqeyJobWFjIjoiMDVkNWNlOTIyNjk5ZTUxNzY4ODU2MmJlYjJiZDUzMTI4OTAyYTYzMjAxMjIxMjdjZTVhZjhlMmRiMmY2MmNkMiIsImsiOjMsIm4iOjUsInByaW1lIjozNzA1MzQ2ODU1NTk0MTE4MjUzNTU0MjcxNTIwMjc4MDEzMDUxMzA0NjM5NTA5MzAwNDk4MDQ5MjYyNjQyNjg4MjUzMjIwMTQ4NDc4MDU5LCJwcmltZV9iaXRsZW5ndGgiOjI2MSwidmVyc2lvbiI6MSwieCI6MywieSI6NTU2ODc5MDczMDU5OTA2NjU0OTgxNjE5NzQ2NDk2NDU0MDI1MTQzMTkwMjgwNDkxOTQ2NDU4NTExMzAwMjQ4NzY2Nzk5NjUyMzA1NDg5fQ==
|
156
|
+
|
157
|
+
|
158
|
+
========================================
|
159
|
+
Decoded Secret:
|
160
|
+
|
161
|
+
(k) Value: 3
|
162
|
+
|
163
|
+
Secret (Bignum):
|
164
|
+
179040077567401061920833455639501686558874997550289562553628622313673068089718
|
165
|
+
|
166
|
+
Secret (Base64 Compacted & URL Safe):
|
167
|
+
OXY1eHdod3N0NXJ1MWEzZXBuMjgxZnN1Y2Y4dXI1bWRyNG40dTl2Zmk1MG16OXM4emE=
|
168
|
+
|
169
|
+
|
170
|
+
========================================
|
171
|
+
➜ secretsharing git:(master) ✗
|
172
|
+
````
|
173
|
+
|
174
|
+
Easy!
|
175
|
+
|
176
|
+
## Development and Testing
|
177
|
+
|
178
|
+
Install the gemfile dependencies:
|
179
|
+
|
180
|
+
bundle install
|
181
|
+
|
182
|
+
Run the test suite:
|
183
|
+
|
184
|
+
rake test
|
185
|
+
|
186
|
+
Or run the test suite continuously upon watched file changes:
|
187
|
+
|
188
|
+
bundle exec rerun -x rake test
|
189
|
+
|
190
|
+
Build and Install the gem to your local system from the cloned repository:
|
191
|
+
|
192
|
+
rake install
|
193
|
+
|
194
|
+
Run the `secretsharing` binary without installing the Gem locally:
|
195
|
+
|
196
|
+
ruby -I./lib bin/secretsharing
|
197
|
+
|
198
|
+
### Code Quality:
|
199
|
+
|
200
|
+
#### Bug Reporting
|
201
|
+
|
202
|
+
We love bug reports and pull requests.
|
203
|
+
|
204
|
+
<https://github.com/grempe/secretsharing/issues>
|
205
|
+
|
206
|
+
#### Travis CI
|
207
|
+
|
208
|
+
[](https://travis-ci.org/grempe/secretsharing)
|
209
|
+
|
210
|
+
This gem is tested after each git push to the master branch
|
211
|
+
using the [Travis CI](https://travis-ci.org/grempe/secretsharing) automated build and test service against several versions of a the most popular Ruby runtimes (MRI 1.8.7, 1.9.3, 2.0.0, JRuby, REE, Rubinious). A build must be green on all of them to be considered for release.
|
212
|
+
|
213
|
+
A `.travis.yml` file has been added to this project to define which Ruby versions will be tested. Additionally a `gemfiles/Gemfile.ci` file has been created to specify a custom minimal Gemspec to be run on the test hosts. Contributors are not to modify these files.
|
214
|
+
|
215
|
+
#### Code Climate
|
216
|
+
|
217
|
+
[](https://codeclimate.com/github/grempe/secretsharing)
|
218
|
+
|
219
|
+
Code quality and metrics over time are being monitored courtesy of [Code Climate](<https://codeclimate.com>).
|
220
|
+
|
221
|
+
<https://codeclimate.com/github/grempe/secretsharing>
|
222
|
+
|
223
|
+
#### Rubocop
|
224
|
+
|
225
|
+
[RuboCop](https://github.com/bbatsov/rubocop) is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide). A clean `rubocop` run against all `lib` and `spec` code is necessary for a build to be considered for release.
|
226
|
+
|
227
|
+
A `.rubocop.yml` file has been added to this project to define any style exceptions. Contributors are not to modify this file.
|
228
|
+
|
229
|
+
#### COCO
|
230
|
+
|
231
|
+
The [COCO](http://lkdjiin.github.io/coco/) gem provides automatic test code coverage analysis for ruby 1.9.2, 1.9.3 and 2.0. It will be run every time `rake test` is run. If there are any files that are not 100% covered an output report will be generated in `coverage/index.html' and a summary line will be added at the end of the `rake test` output. It is expected that 100% test coverage will be maintained.
|
232
|
+
|
233
|
+
A `.coco.yml` file has been added to this project to define any coverage exceptions. Contributors are not to modify this file.
|
234
|
+
|
235
|
+
#### Semantic Versioning
|
236
|
+
This Gem, and its version number, tries its best to adhere to the
|
237
|
+
'Semantic Versioning' strategy espoused at : <http://semver.org>
|
238
|
+
|
239
|
+
### Contributing
|
240
|
+
|
241
|
+
IMPORTANT
|
242
|
+
Please do not change the VERSION number within your commits.
|
243
|
+
Please include tests that are passing 100% within your commits.
|
244
|
+
Please ensure that you maintain 100% test code coverage as reported by 'coco' which is run after every `rake test` automatically.
|
245
|
+
Please run the `rubocop` tool to ensure you are consistent with Ruby style guidelines for this project.
|
246
|
+
|
247
|
+
1. Fork it
|
248
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
249
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
250
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
251
|
+
5. Create new Pull Request
|
252
|
+
|
253
|
+
## Legal
|
254
|
+
|
255
|
+
### Copyright
|
256
|
+
|
257
|
+
(c) 2010-2015 Alexander Klink and Glenn Rempe
|
258
|
+
|
259
|
+
### License
|
260
|
+
|
261
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
262
|
+
you may not use this file except in compliance with the License.
|
263
|
+
You may obtain a copy of the License at
|
264
|
+
|
265
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
266
|
+
|
267
|
+
### Warranty
|
268
|
+
|
269
|
+
Unless required by applicable law or agreed to in writing,
|
270
|
+
software distributed under the License is distributed on an
|
271
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
272
|
+
either express or implied. See the LICENSE.txt file for the
|
273
|
+
specific language governing permissions and limitations under
|
274
|
+
the License.
|
275
|
+
|
276
|
+
## Authors
|
277
|
+
|
278
|
+
***Alexander Klink***</br>
|
279
|
+
<secretsharing@alech.de></br>
|
280
|
+
<http://www.alech.de></br>
|
281
|
+
@alech on Twitter</br>
|
282
|
+
|
283
|
+
***Glenn Rempe***</br>
|
284
|
+
<glenn@rempe.us></br>
|
285
|
+
<http://www.rempe.us></br>
|
286
|
+
@grempe on Twitter</br>
|