mirror of
https://github.com/valitydev/shamir.git
synced 2024-11-06 01:35:18 +00:00
MSPF-440: upgrade codebase to OTP 21 and move to rebar3
This commit is contained in:
parent
232ac4f71d
commit
5ac616232a
@ -1,5 +1,5 @@
|
||||
{deps, [
|
||||
{proper, ".*", {git, "https://github.com/manopapad/proper.git", "master"}}
|
||||
{proper, "1.3.0"}
|
||||
]}.
|
||||
|
||||
{cover_enabled, true}.
|
||||
|
6
rebar.lock
Normal file
6
rebar.lock
Normal file
@ -0,0 +1,6 @@
|
||||
{"1.1.0",
|
||||
[{<<"proper">>,{pkg,<<"proper">>,<<"1.3.0">>},0}]}.
|
||||
[
|
||||
{pkg_hash,[
|
||||
{<<"proper">>, <<"C1ACD51C51DA17A2FE91D7A6FC6A0C25A6A9849D8DC77093533109D1218D8457">>}]}
|
||||
].
|
@ -27,7 +27,7 @@ share(Secret, Threshold, Count) when is_list(Secret) ->
|
||||
|
||||
share(Secret, Threshold, Count) when (Secret >= 0 andalso Secret =< 255) ->
|
||||
GF = galois:generate(8),
|
||||
Coeffs = binary_to_list(crypto:rand_bytes(Threshold - 1)) ++ [Secret],
|
||||
Coeffs = binary_to_list(crypto:strong_rand_bytes(Threshold - 1)) ++ [Secret],
|
||||
[horner(GF, X, Coeffs) || X <- lists:seq(1, Count)].
|
||||
|
||||
horner(GF, X, Coeffs) ->
|
||||
|
@ -21,7 +21,7 @@ hello_test() ->
|
||||
shamir(<<"hello">>, 3, 4).
|
||||
|
||||
key_test() ->
|
||||
shamir(crypto:rand_bytes(32), 3, 15).
|
||||
shamir(crypto:strong_rand_bytes(32), 3, 15).
|
||||
|
||||
shamir(Secret, Threshold, Count) ->
|
||||
Shares = shamir:share(Secret, Threshold, Count),
|
||||
@ -41,8 +41,8 @@ proper_test_() ->
|
||||
prop_secrets() ->
|
||||
?FORALL(Secret, secret(),
|
||||
begin
|
||||
Threshold = random:uniform(10),
|
||||
Count = Threshold * random:uniform(10),
|
||||
Threshold = rand:uniform(10),
|
||||
Count = Threshold * rand:uniform(10),
|
||||
Shares = shamir:share(Secret, Threshold, Count),
|
||||
RecoveredSecret = shamir:recover(
|
||||
lists:sublist(
|
||||
@ -52,7 +52,7 @@ prop_secrets() ->
|
||||
).
|
||||
|
||||
secret() ->
|
||||
crypto:rand_bytes(1 + random:uniform(64)).
|
||||
crypto:strong_rand_bytes(1 + rand:uniform(64)).
|
||||
|
||||
shuffle(List) ->
|
||||
%% Determine the log n portion then randomize the list.
|
||||
@ -67,7 +67,7 @@ randomize(T, List) ->
|
||||
|
||||
randomize(List) ->
|
||||
D = lists:map(fun(A) ->
|
||||
{random:uniform(), A}
|
||||
{rand:uniform(), A}
|
||||
end, List),
|
||||
{_, D1} = lists:unzip(lists:keysort(1, D)),
|
||||
D1.
|
||||
|
Loading…
Reference in New Issue
Block a user