Permalink
Browse files

verify all shares are unique.

  • Loading branch information...
Robert Newson
Robert Newson committed Aug 15, 2011
1 parent 01a4300 commit 7ff6aa79b7554c01943739b885b614ce3d26ebcf
Showing with 12 additions and 5 deletions.
  1. +12 −5 test/shamir_test.erl
View
@@ -13,10 +13,17 @@
%% limitations under the License.
-module(shamir_test).
+-include("shamir.hrl").
-include_lib("eunit/include/eunit.hrl").
-shamir_test() ->
- Secret = <<"hello">>,
- Shares = shamir:share(Secret, 3, 4),
- RecoveredSecret= shamir:recover(Shares),
- ?assertEqual(Secret, RecoveredSecret).
+hello_test() ->
+ shamir(<<"hello">>, 3, 4).
+
+key_test() ->
+ shamir(crypto:rand_bytes(32), 3, 15).
+
+shamir(Secret, Threshold, Count) ->
+ Shares = shamir:share(Secret, Threshold, Count),
+ ?assertEqual(Count, length(lists:usort([Y || #share{y=Y} <- Shares]))),
+ RecoveredSecret= shamir:recover(lists:sublist(Shares, Threshold)),
+ ?assertEqual(Secret, RecoveredSecret).

0 comments on commit 7ff6aa7

Please sign in to comment.