Skip to content

Commit 9cdb495

Browse files
committed
Utils testing for EvaluatePolynomial; README, and documentation
1 parent 70ef4aa commit 9cdb495

File tree

5 files changed

+69
-2
lines changed

5 files changed

+69
-2
lines changed

Contributors.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Contributors:
2+
Alexander Scheel - [email protected]

README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
# sssa-golang
1+
# sssaas-golang
2+
An implementation of Shamir's Secret Sharing Algorithm in Go
23

3-
sssa-golang
4+
Copyright (C) 2015 Alexander Scheel, Joel May, Matthew Burket
5+
See Contributors.md for a complete list of contributors.
6+
Licensed under the MIT License.
7+
8+
## Usage
9+
Note: this library is for a pure implementation of SSS in Go;
10+
if you are looking for the API Library for SSSaaS, look [here](https://github.com/SSSAAS/sssaas-golang).
11+
12+
sssa.create(minimum int, shares int, raw string) - creates a set of shares
13+
14+
sssa.combine(shares []string) - combines shares into secret
15+
16+
For more detailed documentation, check out docs/sssa.md
17+
18+
## Contributing
19+
We welcome pull requests, issues, security advice on this library, or other contributions you feel are necessary. Feel free to open an issue to discuss any questions you have about this library.
20+
21+
For security issues, send a GPG-encrypted email to <[email protected]> with public key [0xBDC5F518A973035E](https://pgp.mit.edu/pks/lookup?op=vindex&search=0xBDC5F518A973035E).

docs/safeprime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
99995644905598542077721161034987774965417302630805822064337798850767846245779

docs/sssa.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SSSA - Ruby
2+
## Constants
3+
prime = 99995644905598542077721161034987774965417302630805822064337798850767846245779
4+
Safe Prime; big.Int
5+
6+
## Functions
7+
create(minimum int, number int, raw string)
8+
minimum - number of shares required to recreate the secret
9+
number - total number of shares to generate
10+
raw - secret to protect, as a string
11+
12+
returns shares as an array of base64 strings of variable length
13+
dependent on the size of the raw secret
14+
15+
combine(shares []string)
16+
shares - array of base64 strings returned by create function
17+
18+
returns a string of secret
19+
note: this string can be ill-formatted utf8 potentially, if the
20+
minimum number of shares was not met

utils_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,29 @@ func TestModInverse(t *testing.T) {
7070
}
7171
}
7272
}
73+
74+
func TestEvaluatePolynomial(t *testing.T) {
75+
values := [][][]*big.Int {
76+
[][]*big.Int{
77+
[]*big.Int{big.NewInt(20), big.NewInt(21), big.NewInt(42),},
78+
[]*big.Int{big.NewInt(0)},
79+
},
80+
[][]*big.Int{
81+
[]*big.Int{big.NewInt(0), big.NewInt(0), big.NewInt(0),},
82+
[]*big.Int{big.NewInt(4),},
83+
},
84+
[][]*big.Int{
85+
[]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3), big.NewInt(4), big.NewInt(5),},
86+
[]*big.Int{big.NewInt(10),},
87+
},
88+
}
89+
90+
actual := []*big.Int{big.NewInt(20), big.NewInt(0), big.NewInt(54321)}
91+
92+
for i := range(values) {
93+
result := evaluatePolynomial(values[i][0], values[i][1][0])
94+
if result.Cmp(actual[i]) != 0 {
95+
t.Fatalf("Fatal: EvaluatePolynomial[%v] failed\nExpected: %v; Got: %v\n", i, actual[i], result)
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)