This commit is contained in:
parent
30944928da
commit
4c1af8bbf3
15
.gitea/workflows/test.yaml
Normal file
15
.gitea/workflows/test.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
name: EC Utils Tests
|
||||
run-name: ${{ gitea.actor }} testing EC Utils
|
||||
on: [push, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- name: test
|
||||
run: |
|
||||
. /opt/act_runner/erts/27.2/activate
|
||||
./rebar3 dialyzer
|
||||
./rebar3 eunit
|
@ -17,12 +17,12 @@ gen_scalar() ->
|
||||
?LET(N, gen_large_n(), <<N:256/little>>).
|
||||
|
||||
gen_point() ->
|
||||
?LET(S, gen_scalar(), enacl:crypto_ed25519_scalarmult_base_noclamp(S)).
|
||||
?LET(S, gen_scalar(), enacl:curve25519_scalarmult_base_noclamp(S)).
|
||||
|
||||
prop_compress() ->
|
||||
?FORALL(S, gen_scalar(),
|
||||
begin
|
||||
CompP = enacl:crypto_ed25519_scalarmult_base_noclamp(S),
|
||||
CompP = enacl:curve25519_scalarmult_base_noclamp(S),
|
||||
DecP = ecu_ed25519:scalar_mul_base_noclamp(S),
|
||||
equals(CompP, ecu_ed25519:compress(DecP))
|
||||
end).
|
||||
@ -30,7 +30,7 @@ prop_compress() ->
|
||||
prop_decompress() ->
|
||||
?FORALL(S, gen_scalar(),
|
||||
begin
|
||||
CompP = enacl:crypto_ed25519_scalarmult_base_noclamp(S),
|
||||
CompP = enacl:curve25519_scalarmult_base_noclamp(S),
|
||||
DecP = ecu_ed25519:scalar_mul_base_noclamp(S),
|
||||
equal_pts(DecP, ecu_ed25519:decompress(CompP))
|
||||
end).
|
||||
@ -70,7 +70,7 @@ prop_generate_valid_point() ->
|
||||
prop_scalar_mul_base() ->
|
||||
?FORALL(S, gen_scalar(),
|
||||
begin
|
||||
E = enacl:crypto_ed25519_scalarmult_base(S),
|
||||
E = enacl:curve25519_scalarmult_base(S),
|
||||
P = ecu_ed25519:scalar_mul_base(S),
|
||||
equals(E, ecu_ed25519:compress(P))
|
||||
end).
|
||||
@ -78,7 +78,7 @@ prop_scalar_mul_base() ->
|
||||
prop_scalar_mul_base_noclamp() ->
|
||||
?FORALL(S, gen_scalar(),
|
||||
begin
|
||||
E = enacl:crypto_ed25519_scalarmult_base_noclamp(S),
|
||||
E = enacl:curve25519_scalarmult_base_noclamp(S),
|
||||
P = ecu_ed25519:scalar_mul_base_noclamp(S),
|
||||
equals(E, ecu_ed25519:compress(P))
|
||||
end).
|
||||
@ -86,7 +86,7 @@ prop_scalar_mul_base_noclamp() ->
|
||||
prop_scalar_mul() ->
|
||||
?FORALL({S, P0}, {gen_scalar(), gen_point()},
|
||||
begin
|
||||
E = enacl:crypto_ed25519_scalarmult(S, P0),
|
||||
E = enacl:curve25519_scalarmult(S, P0),
|
||||
P = ecu_ed25519:scalar_mul(S, P0),
|
||||
equals(E, ecu_ed25519:compress(P))
|
||||
end).
|
||||
@ -94,7 +94,7 @@ prop_scalar_mul() ->
|
||||
prop_scalar_mul_noclamp() ->
|
||||
?FORALL({S, P0}, {gen_scalar(), gen_point()},
|
||||
begin
|
||||
E = enacl:crypto_ed25519_scalarmult_noclamp(S, P0),
|
||||
E = enacl:curve25519_scalarmult_noclamp(S, P0),
|
||||
P = ecu_ed25519:scalar_mul_noclamp(S, ecu_ed25519:decompress(P0)),
|
||||
equals(E, ecu_ed25519:compress(P))
|
||||
end).
|
||||
|
@ -20,7 +20,7 @@ gen_scalar() ->
|
||||
?LET(N, gen_large_n(), <<N:256/little>>).
|
||||
|
||||
gen_point() ->
|
||||
?LET(S, gen_scalar(), enacl:crypto_ed25519_scalarmult_base_noclamp(S)).
|
||||
?LET(S, gen_scalar(), enacl:curve25519_scalarmult_base_noclamp(S)).
|
||||
|
||||
prop_keypair_seed() ->
|
||||
?FORALL(Seed, binary(32),
|
||||
|
@ -13,7 +13,7 @@ gen_scalar() ->
|
||||
1 + X rem (ecu_ed25519:n() - 1).
|
||||
|
||||
bench_point_add_test() ->
|
||||
Pts = [ enacl:crypto_ed25519_scalarmult_base(<<(gen_scalar()):256/little>>) || _ <- lists:seq(1, 100) ],
|
||||
Pts = [ enacl:curve25519_scalarmult_base(<<(gen_scalar()):256/little>>) || _ <- lists:seq(1, 100) ],
|
||||
|
||||
PtsEnacl0 = lists:zip(Pts, tl(Pts) ++ [hd(Pts)]),
|
||||
PtsEd255190 = [ {ecu_ed25519:to_ext_hom(P1), ecu_ed25519:to_ext_hom(P2)} || {P1, P2} <- lists:zip(Pts, tl(Pts) ++ [hd(Pts)]) ],
|
||||
@ -39,7 +39,7 @@ bench_scalar_mul_base_test() ->
|
||||
ScalarsEd25519 = lists:append(lists:duplicate(30, Scalars0)),
|
||||
|
||||
{TimeSecp, _} = timer:tc(fun() -> [ecu_secp256k1:scalar_mul_base(S) || S <- ScalarsSecp], ok end),
|
||||
{TimeEnacl, _} = timer:tc(fun() -> [enacl:crypto_ed25519_scalarmult_base(S) || S <- ScalarsEnacl], ok end),
|
||||
{TimeEnacl, _} = timer:tc(fun() -> [enacl:curve25519_scalarmult_base(S) || S <- ScalarsEnacl], ok end),
|
||||
{TimeEd25519, _} = timer:tc(fun() -> [ecu_ed25519:scalar_mul_base(S) || S <- ScalarsEd25519], ok end),
|
||||
|
||||
?debugFmt("", []),
|
||||
@ -58,7 +58,7 @@ bench_scalar_mul_test() ->
|
||||
Test = fun(F, P0, Ss) -> lists:foldl(fun(S, P) -> F(S, P) end, P0, Ss) end,
|
||||
|
||||
{TimeSecp, _} = timer:tc(fun() -> Test(fun ecu_secp256k1:scalar_mul/2, ecu_secp256k1:scalar_mul_base(hd(ScalarsSecp)), tl(ScalarsSecp)) end),
|
||||
{TimeEnacl, _} = timer:tc(fun() -> Test(fun enacl:crypto_ed25519_scalarmult/2, enacl:crypto_ed25519_scalarmult_base(hd(ScalarsEnacl)), tl(ScalarsEnacl)) end),
|
||||
{TimeEnacl, _} = timer:tc(fun() -> Test(fun enacl:curve25519_scalarmult/2, enacl:curve25519_scalarmult_base(hd(ScalarsEnacl)), tl(ScalarsEnacl)) end),
|
||||
{TimeEd25519, _} = timer:tc(fun() -> Test(fun ecu_ed25519:scalar_mul/2, ecu_ed25519:scalar_mul_base(hd(ScalarsEd25519)), tl(ScalarsEd25519)) end),
|
||||
|
||||
?debugFmt("", []),
|
||||
|
Loading…
x
Reference in New Issue
Block a user