Merge branch 'fix-constant-and-more-tests' of github.com:aeternity/enacl
This commit is contained in:
commit
25d411aa7d
@ -137,7 +137,7 @@ enif_crypto_curve25519_scalarmult(ErlNifEnv *env, int argc,
|
||||
memcpy(bp, basepoint.data, crypto_scalarmult_curve25519_BYTES);
|
||||
|
||||
/* Clear the high-bit. Better safe than sorry. */
|
||||
bp[31] &= 0x7f;
|
||||
bp[crypto_scalarmult_curve25519_BYTES - 1] &= 0x7f;
|
||||
|
||||
do {
|
||||
if (!enif_alloc_binary(crypto_scalarmult_curve25519_BYTES, &output)) {
|
||||
@ -1174,7 +1174,6 @@ static void uint64_pack(unsigned char *y, ErlNifUInt64 x) {
|
||||
*y++ = x;
|
||||
x >>= 8;
|
||||
*y++ = x;
|
||||
x >>= 8;
|
||||
}
|
||||
|
||||
static ErlNifUInt64 uint64_unpack(const unsigned char *x) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
-module(enacl_eqc).
|
||||
-include_lib("eqc/include/eqc.hrl").
|
||||
-compile(export_all).
|
||||
-compile([export_all, nowarn_export_all]).
|
||||
|
||||
-ifndef(mini).
|
||||
-compile({parse_transform, eqc_parallelize}).
|
||||
@ -828,8 +828,26 @@ prop_randombytes() ->
|
||||
end
|
||||
end).
|
||||
|
||||
%% SCRAMBLING
|
||||
prop_scramble_block() ->
|
||||
?FORALL({Block, Key}, {binary(16), eqc_gen:largebinary(32)},
|
||||
is_binary(enacl_ext:scramble_block_16(Block, Key))).
|
||||
|
||||
%% Scala multiplication
|
||||
prop_scalarmult() ->
|
||||
Bytes = 32,
|
||||
?FORALL({S1, S2, Basepoint}, {binary(Bytes), binary(Bytes), binary(Bytes)},
|
||||
equals(enacl:curve25519_scalarmult(S1,
|
||||
enacl:curve25519_scalarmult(S2, Basepoint)),
|
||||
enacl:curve25519_scalarmult(S2,
|
||||
enacl:curve25519_scalarmult(S1, Basepoint)))
|
||||
).
|
||||
|
||||
%% HELPERS
|
||||
|
||||
%% INTERNAL FUNCTIONS
|
||||
%% ------------------------------------------------------------
|
||||
|
||||
badargs(Thunk) ->
|
||||
try
|
||||
Thunk(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user