Added bindings for crypto_sign_seed_keypair in libsodium

This commit is contained in:
Ole Andre Birkedal
2019-06-08 18:19:44 +02:00
parent 885662c069
commit 6f4a0c2521
3 changed files with 51 additions and 0 deletions
+17
View File
@@ -33,7 +33,9 @@
%% EQC
sign_keypair_public_size/0,
sign_keypair_secret_size/0,
sign_keypair_seed_size/0,
sign_keypair/0,
sign_seed_keypair/1,
sign/2,
sign_open/2,
sign_detached/2,
@@ -513,6 +515,10 @@ sign_keypair_public_size() ->
sign_keypair_secret_size() ->
enacl_nif:crypto_sign_SECRETKEYBYTES().
%% @private
sign_keypair_seed_size() ->
enacl_nif:crypto_sign_SEEDBYTES().
%% @doc sign_keypair/0 returns a signature keypair for signing
%%
%% The returned value is a map in order to make it harder to misuse keys.
@@ -522,6 +528,17 @@ sign_keypair() ->
{PK, SK} = enacl_nif:crypto_sign_keypair(),
#{ public => PK, secret => SK}.
%% @doc sign_seed_keypair/1 returns a signature keypair based on seed for signing
%%
%% The returned value is a map in order to make it harder to misuse keys.
%% @end
-spec sign_seed_keypair(S) -> #{ atom() => binary() }
when
S :: binary().
sign_seed_keypair(S) ->
{PK, SK} = enacl_nif:crypto_sign_seed_keypair(S),
#{ public => PK, secret => SK}.
%% @doc sign/2 signs a message with a digital signature identified by a secret key.
%%
%% Given a message `M' and a secret key `SK' the function will sign the message and return a signed message `SM'.
+4
View File
@@ -25,8 +25,10 @@
crypto_sign_PUBLICKEYBYTES/0,
crypto_sign_SECRETKEYBYTES/0,
crypto_sign_SEEDBYTES/0,
crypto_sign_keypair/0,
crypto_sign_seed_keypair/1,
crypto_sign/2,
crypto_sign_open/2,
@@ -211,8 +213,10 @@ crypto_box_open_afternm_b(_CipherText, _Nonce, _K) -> erlang:nif_error(nif_not_l
crypto_sign_PUBLICKEYBYTES() -> erlang:nif_error(nif_not_loaded).
crypto_sign_SECRETKEYBYTES() -> erlang:nif_error(nif_not_loaded).
crypto_sign_SEEDBYTES() -> erlang:nif_error(nif_not_loaded).
crypto_sign_keypair() -> erlang:nif_error(nif_not_loaded).
crypto_sign_seed_keypair(_S) -> erlang:nif_error(nif_not_loaded).
crypto_sign(_M, _SK) -> erlang:nif_error(nif_not_loaded).
crypto_sign_open(_SignedMessage, _PK) -> erlang:nif_error(nif_not_loaded).