Small fixes

This commit is contained in:
Sean Hinde
2023-01-13 11:31:14 +01:00
parent 55cb5526eb
commit 4f8b06713f
4 changed files with 10 additions and 15 deletions
+2 -1
View File
@@ -4,7 +4,8 @@
{registered, []},
{applications,
[kernel,
stdlib
stdlib,
sha3
]},
{env,[]},
{modules, []},
+2 -7
View File
@@ -1,7 +1,5 @@
-module(ecrecover).
%% https://github.com/mbrix/libsecp256k1
%% API
-export([recover/2, recover/3]).
@@ -11,10 +9,6 @@
%%=============================================================================
%% NIF API
%% GoodMsg1 = <<71,23,50,133,168,215,52,30,94,151,47,198,119,40,99,132,248,2,248,239,66,165,236,95,3,187,250,37,76,176,31,173>>.
%% GoodSig1_v = <<27,101,10,207,157,63,95,10,44,121,151,118,161,37,67,85,213,244,6,23,98,162,55,57,106,153,160,224,227,252,43,205,103,41,81,74,13,172,178,230,35,172,74,189,21,124,177,129,99,255,148,34,128,219,77,92,170,214,109,223,148,27,161,46,3>>.
%% ecrecover:recover(<<71,23,50,133,168,215,52,30,94,151,47,198,119,40,99,132,248,2,248,239,66,165,236,95,3,187,250,37,76,176,31,173>>, <<27,101,10,207,157,63,95,10,44,121,151,118,161,37,67,85,213,244,6,23,98,162,55,57,106,153,160,224,227,252,43,205,103,41,81,74,13,172,178,230,35,172,74,189,21,124,177,129,99,255,148,34,128,219,77,92,170,214,109,223,148,27,161,46,3>>).
%%
load() ->
EbinDir = filename:dirname(code:which(?MODULE)),
@@ -29,6 +23,7 @@ not_loaded(Line) ->
%%=============================================================================
%% External API
-spec recover(<<_:(32*8)>>, <<_:(65*8)>>) -> <<_:(32*8)>>.
recover(Hash, <<V, Sig:64/binary>>) when V == 27; V == 28 ->
RecId = V - 27,
case recover(Hash, Sig, RecId) of
@@ -41,7 +36,7 @@ recover(Hash, <<V, Sig:64/binary>>) when V == 27; V == 28 ->
recover(_Hash, _VSig) ->
<<0:256>>.
-spec recover(<<_:(32*8)>>, <<_:(65*8)>>, integer()) -> <<_:(32*8)>>.
-spec recover(<<_:(32*8)>>, <<_:(64*8)>>, integer()) -> <<_:(32*8)>>.
recover(_Hash, _Sig, _RecId) ->
not_loaded(?LINE).