Use DS-variants whenever it doesn't make sense.
Some operations are simply too expensive. Always run these on the dirty scheduler.
This commit is contained in:
parent
66cf275152
commit
1562eed9a3
@ -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) ->
|
|||||||
PK :: binary(),
|
PK :: binary(),
|
||||||
M :: binary().
|
M :: binary().
|
||||||
sign_open(SM, PK) ->
|
sign_open(SM, PK) ->
|
||||||
case iolist_size(SM) of
|
|
||||||
K when K =< ?SIGN_SIZE ->
|
|
||||||
R = case enacl_nif:crypto_sign_open_b(SM, PK) of
|
|
||||||
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
|
case enacl_nif:crypto_sign_open(SM, PK) of
|
||||||
M when is_binary(M) -> {ok, M};
|
M when is_binary(M) -> {ok, M};
|
||||||
{error, Err} -> {error, Err}
|
{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) ->
|
|||||||
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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user