Skip to content

Commit 01ae99f

Browse files
authored
Removed unused enacl lib. Use eblake2 for hash. (#8)
* Removed unused lib. * Replace local blake2 implementation with eblake2. * Add eblake2 dep to app file. * Add eblake2 to rebar config. * Use hex for eblake2. * Bump version. * Replace local rlp with aeserialization repo. Use ref till first release is available. * Remove unused vars.
1 parent a35307f commit 01ae99f

8 files changed

Lines changed: 47 additions & 272 deletions

File tree

rebar.config

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
{erl_opts, [debug_info]}.
44

5-
{deps, [ {getopt, "1.0.1"}
5+
{deps, [ {eblake2, "1.0.0"}
6+
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git",
7+
{ref, "b55c372"}}}
8+
, {getopt, "1.0.1"}
69
]}.
710

8-
{escript_incl_apps, [aebytecode, getopt]}.
11+
{escript_incl_apps, [aebytecode, eblake2, aeserialization, getopt]}.
912
{escript_main_app, aebytecode}.
1013
{escript_name, aefateasm}.
1114
{escript_emu_args, "%%!"}.
@@ -19,16 +22,19 @@
1922
]}.
2023

2124

22-
{relx, [{release, {aessembler, "0.0.1"},
23-
[aebytecode, getopt]},
25+
{relx, [{release, {aebytecode, "2.0.1"},
26+
[aebytecode, eblake2, getopt]},
2427

2528
{dev_mode, true},
2629
{include_erts, false},
2730

2831
{extended_start_script, true}]}.
2932

3033
{profiles, [{binary, [
31-
{deps, [ {getopt, "1.0.1"}
34+
{deps, [ {eblake2, "1.0.0"}
35+
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git",
36+
{ref, "b55c372"}}}
37+
, {getopt, "1.0.1"}
3238
]},
3339

3440
{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",

rebar.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{"1.1.0",
2-
[{<<"enacl">>,
3-
{git,"https://github.com/aeternity/enacl.git",
4-
{ref,"26180f42c0b3a450905d2efd8bc7fd5fd9cece75"}},
2+
[{<<"aeserialization">>,
3+
{git,"https://github.com/aeternity/aeserialization.git",
4+
{ref,"b55c3726f4a21063721c68d6fa7fda39121edf11"}},
55
0},
6+
{<<"base58">>,
7+
{git,"https://github.com/aeternity/erl-base58.git",
8+
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}},
9+
1},
10+
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
611
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0}]}.
712
[
813
{pkg_hash,[
14+
{<<"eblake2">>, <<"EC8AD20E438AAB3F2E8D5D118C366A0754219195F8A0F536587440F8F9BCF2EF">>},
915
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>}]}
1016
].

src/aeb_blake2.erl

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/aeb_fate_asm.erl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ asm_to_bytecode(AssemblerCode, Options) ->
350350
Signatures = serialize_sigs(Env),
351351
SymbolTable = serialize_symbol_table(Env),
352352
Annotatations = serialize_annotations(Env),
353-
ByteCode = << (aeb_rlp:encode(list_to_binary(ByteList)))/binary,
354-
(aeb_rlp:encode(list_to_binary(Signatures)))/binary,
355-
(aeb_rlp:encode(SymbolTable))/binary,
356-
(aeb_rlp:encode(Annotatations))/binary
353+
ByteCode = << (aeser_rlp:encode(list_to_binary(ByteList)))/binary,
354+
(aeser_rlp:encode(list_to_binary(Signatures)))/binary,
355+
(aeser_rlp:encode(SymbolTable))/binary,
356+
(aeser_rlp:encode(Annotatations))/binary
357357
>>,
358358

359359
case proplists:lookup(pp_hex_string, Options) of
@@ -366,14 +366,14 @@ asm_to_bytecode(AssemblerCode, Options) ->
366366
{Env, ByteCode}.
367367

368368
strip(ByteCode) ->
369-
{Code, _Rest} = aeb_rlp:decode_one(ByteCode),
369+
{Code, _Rest} = aeser_rlp:decode_one(ByteCode),
370370
Code.
371371

372372
bytecode_to_fate_code(Bytes, _Options) ->
373-
{ByteCode, Rest1} = aeb_rlp:decode_one(Bytes),
374-
{Signatures, Rest2} = aeb_rlp:decode_one(Rest1),
375-
{SymbolTable, Rest3} = aeb_rlp:decode_one(Rest2),
376-
{Annotations, <<>>} = aeb_rlp:decode_one(Rest3),
373+
{ByteCode, Rest1} = aeser_rlp:decode_one(Bytes),
374+
{Signatures, Rest2} = aeser_rlp:decode_one(Rest1),
375+
{SymbolTable, Rest3} = aeser_rlp:decode_one(Rest2),
376+
{Annotations, <<>>} = aeser_rlp:decode_one(Rest3),
377377

378378
Env1 = deserialize(ByteCode, #{ function => none
379379
, bb => 0
@@ -844,7 +844,7 @@ insert_fun({Name, Type, RetType}, Code, #{functions := Functions} = Env) ->
844844

845845
mk_hash(Id) ->
846846
%% Use first 4 bytes of blake hash
847-
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = aeb_blake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
847+
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = eblake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
848848
<<A,B,C,D>>.
849849

850850
%% Handle annotations

src/aeb_fate_encoding.erl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ serialize(String) when ?IS_FATE_STRING(String),
104104
?FATE_STRING_SIZE(String) > 0,
105105
?FATE_STRING_SIZE(String) >= ?SHORT_STRING_SIZE ->
106106
Bytes = ?FATE_STRING_VALUE(String),
107-
<<?LONG_STRING, (aeb_rlp:encode(Bytes))/binary>>;
107+
<<?LONG_STRING, (aeser_rlp:encode(Bytes))/binary>>;
108108
serialize(?FATE_ADDRESS(Address)) when is_binary(Address) ->
109-
<<?ADDRESS, (aeb_rlp:encode(Address))/binary>>;
109+
<<?ADDRESS, (aeser_rlp:encode(Address))/binary>>;
110110
serialize(?FATE_TUPLE(T)) when size(T) > 0 ->
111111
S = size(T),
112112
L = tuple_to_list(T),
@@ -148,7 +148,7 @@ serialize(?FATE_VARIANT(Size, Tag, Values)) when 0 =< Size
148148
%% -----------------------------------------------------
149149

150150
rlp_integer(S) when S >= 0 ->
151-
aeb_rlp:encode(binary:encode_unsigned(S)).
151+
aeser_rlp:encode(binary:encode_unsigned(S)).
152152

153153
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
154154
V = ?FATE_INTEGER_VALUE(I),
@@ -187,28 +187,28 @@ deserialize2(<<?POS_SIGN:1, I:6, ?SMALL_INT:1, Rest/binary>>) ->
187187
deserialize2(<<?NEG_SIGN:1, I:6, ?SMALL_INT:1, Rest/binary>>) ->
188188
{?MAKE_FATE_INTEGER(-I), Rest};
189189
deserialize2(<<?NEG_BIG_INT, Rest/binary>>) ->
190-
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
190+
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
191191
{?MAKE_FATE_INTEGER(-binary:decode_unsigned(Bint) - ?SMALL_INT_SIZE),
192192
Rest2};
193193
deserialize2(<<?POS_BIG_INT, Rest/binary>>) ->
194-
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
194+
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
195195
{?MAKE_FATE_INTEGER(binary:decode_unsigned(Bint) + ?SMALL_INT_SIZE),
196196
Rest2};
197197
deserialize2(<<?NEG_BITS, Rest/binary>>) ->
198-
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
198+
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
199199
{?FATE_BITS(-binary:decode_unsigned(Bint)), Rest2};
200200
deserialize2(<<?POS_BITS, Rest/binary>>) ->
201-
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
201+
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
202202
{?FATE_BITS(binary:decode_unsigned(Bint)), Rest2};
203203
deserialize2(<<?LONG_STRING, Rest/binary>>) ->
204-
{String, Rest2} = aeb_rlp:decode_one(Rest),
204+
{String, Rest2} = aeser_rlp:decode_one(Rest),
205205
{?MAKE_FATE_STRING(String), Rest2};
206206
deserialize2(<<S:6, ?SHORT_STRING:2, Rest/binary>>) ->
207207
String = binary:part(Rest, 0, S),
208208
Rest2 = binary:part(Rest, byte_size(Rest), - (byte_size(Rest) - S)),
209209
{?MAKE_FATE_STRING(String), Rest2};
210210
deserialize2(<<?ADDRESS, Rest/binary>>) ->
211-
{A, Rest2} = aeb_rlp:decode_one(Rest),
211+
{A, Rest2} = aeser_rlp:decode_one(Rest),
212212
{?FATE_ADDRESS(A), Rest2};
213213
deserialize2(<<?TRUE, Rest/binary>>) ->
214214
{?FATE_TRUE, Rest};
@@ -223,23 +223,23 @@ deserialize2(<<?EMPTY_MAP, Rest/binary>>) ->
223223
deserialize2(<<?EMPTY_STRING, Rest/binary>>) ->
224224
{?FATE_EMPTY_STRING, Rest};
225225
deserialize2(<<?LONG_TUPLE, Rest/binary>>) ->
226-
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
226+
{BSize, Rest1} = aeser_rlp:decode_one(Rest),
227227
N = binary:decode_unsigned(BSize) + ?SHORT_TUPLE_SIZE,
228228
{List, Rest2} = deserialize_elements(N, Rest1),
229229
{?FATE_TUPLE(list_to_tuple(List)), Rest2};
230230
deserialize2(<<S:4, ?SHORT_TUPLE:4, Rest/binary>>) ->
231231
{List, Rest1} = deserialize_elements(S, Rest),
232232
{?FATE_TUPLE(list_to_tuple(List)), Rest1};
233233
deserialize2(<<?LONG_LIST, Rest/binary>>) ->
234-
{BLength, Rest1} = aeb_rlp:decode_one(Rest),
234+
{BLength, Rest1} = aeser_rlp:decode_one(Rest),
235235
Length = binary:decode_unsigned(BLength) + ?SHORT_LIST_SIZE,
236236
{List, Rest2} = deserialize_elements(Length, Rest1),
237237
{?MAKE_FATE_LIST(List), Rest2};
238238
deserialize2(<<S:4, ?SHORT_LIST:4, Rest/binary>>) ->
239239
{List, Rest1} = deserialize_elements(S, Rest),
240240
{?MAKE_FATE_LIST(List), Rest1};
241241
deserialize2(<<?MAP, Rest/binary>>) ->
242-
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
242+
{BSize, Rest1} = aeser_rlp:decode_one(Rest),
243243
Size = binary:decode_unsigned(BSize),
244244
{List, Rest2} = deserialize_elements(2*Size, Rest1),
245245
Map = insert_kv(List, #{}),

0 commit comments

Comments
 (0)