Commit 1562eed9 authored by Jesper Louis Andersen's avatar Jesper Louis Andersen
Browse files

Use DS-variants whenever it doesn't make sense.

Some operations are simply too expensive. Always run these on the dirty
scheduler.
parent 66cf2751
...@@ -354,12 +354,7 @@ sign_keypair() -> ...@@ -354,12 +354,7 @@ sign_keypair() ->
SK :: binary(), SK :: binary(),
SM :: binary(). SM :: binary().
sign(M, SK) -> sign(M, SK) ->
case iolist_size(M) of enacl_nif:crypto_sign(M, SK).
K when K =< ?SIGN_SIZE ->
bump(enacl_nif:crypto_sign_b(M, SK), ?SIGN_REDUCTIONS, ?SIGN_SIZE, K);
_ ->
enacl_nif:crypto_sign(M, SK)
end.
%% @doc sign_open/2 opens a digital signature %% @doc sign_open/2 opens a digital signature
%% %%
...@@ -373,18 +368,9 @@ sign(M, SK) -> ...@@ -373,18 +368,9 @@ sign(M, SK) ->
PK :: binary(), PK :: binary(),
M :: binary(). M :: binary().
sign_open(SM, PK) -> sign_open(SM, PK) ->
case iolist_size(SM) of case enacl_nif:crypto_sign_open(SM, PK) of
K when K =< ?SIGN_SIZE -> M when is_binary(M) -> {ok, M};
R = case enacl_nif:crypto_sign_open_b(SM, PK) of {error, Err} -> {error, Err}
M when is_binary(M) -> {ok, M};
{error, Err} -> {error, Err}
end,
bump(R, ?SIGN_REDUCTIONS, ?SIGN_SIZE, byte_size(SM));
_ ->
case enacl_nif:crypto_sign_open(SM, PK) of
M when is_binary(M) -> {ok, M};
{error, Err} -> {error, Err}
end
end. end.
%% @doc sign_detached/2 computes a digital signature given a message and a secret key. %% @doc sign_detached/2 computes a digital signature given a message and a secret key.
...@@ -397,12 +383,7 @@ sign_open(SM, PK) -> ...@@ -397,12 +383,7 @@ sign_open(SM, PK) ->
SK :: binary(), SK :: binary(),
DS :: binary(). DS :: binary().
sign_detached(M, SK) -> sign_detached(M, SK) ->
case iolist_size(M) of enacl_nif:crypto_sign_detached(M, SK).
K when K =< ?SIGN_SIZE ->
bump(enacl_nif:crypto_sign_detached_b(M, SK), ?SIGN_REDUCTIONS, ?SIGN_SIZE, K);
_ ->
enacl_nif:crypto_sign_detached(M, SK)
end.
%% @doc sign_verify_detached/3 verifies the given signature against the given %% @doc sign_verify_detached/3 verifies the given signature against the given
%% message for the given public key. %% message for the given public key.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment