Streamlining of secret and _verify

The secret key API is now streamlined.

Also, all verify-type functions are
now returning boolean() values.
This makes the API consistent.
This commit is contained in:
Jesper Louis Andersen
2020-02-06 11:12:32 +01:00
parent 1cb2c3a2a2
commit 7999d08e9d
5 changed files with 18 additions and 20 deletions
+4 -7
View File
@@ -623,17 +623,14 @@ sign_detached(M, SK) ->
%% message for the given public key.
%%
%% Given a signature `SIG', a message `M', and a public key `PK', the function computes
%% true iff the `SIG' is valid for `M' and `PK'.
-spec sign_verify_detached(SIG, M, PK) -> {ok, M} | {error, failed_verification}
%% true iff the `SIG' is valid for `M' and `PK'; false otherwise.
-spec sign_verify_detached(SIG, M, PK) -> boolean()
when
SIG :: binary(),
M :: iodata(),
PK :: binary().
sign_verify_detached(SIG, M, PK) ->
case enacl_nif:crypto_sign_verify_detached(SIG, M, PK) of
true -> {ok, M};
false -> {error, failed_verification}
end.
enacl_nif:crypto_sign_verify_detached(SIG, M, PK).
-type sign_state() :: reference().
@@ -669,7 +666,7 @@ sign_final_create(SignState, SK) ->
%% Verifies that `SIG` is a valid signature for the message whose content has
%% been previously supplied using `sign_update/2` using the public key `PK.`
%% @end
-spec sign_final_verify(S, SIG, PK) -> ok | {error, failed_verification}
-spec sign_final_verify(S, SIG, PK) -> boolean()
when S :: sign_state(),
SIG :: binary(),
PK :: iodata().