diff --git a/Makefile b/Makefile index 25a7179..43c0345 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,10 @@ dialyzer: $(REBAR) dialyzer ct: all - $(REBAR) ct --suite=test/aecuckoo_SUITE + $(REBAR) ct --suite=test/gmcuckoo_SUITE eunit: - $(REBAR) eunit --module=aeminer_pow_tests,aeminer_pow_cuckoo_tests + $(REBAR) eunit --module=gmminer_pow_tests,gmminer_pow_cuckoo_tests clean: $(REBAR) clean diff --git a/README.md b/README.md index 0e68154..1b8bb70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# aeminer +# gmminer Erlang library to work with CPU and CUDA cuckoo miners. diff --git a/include/aeminer.hrl b/include/gmminer.hrl similarity index 100% rename from include/aeminer.hrl rename to include/gmminer.hrl diff --git a/src/aeminer.app.src b/src/gmminer.app.src similarity index 79% rename from src/aeminer.app.src rename to src/gmminer.app.src index 7b8f807..06b8bc4 100644 --- a/src/aeminer.app.src +++ b/src/gmminer.app.src @@ -1,5 +1,5 @@ -{application, aeminer, - [{description, "Aeternity miner"}, +{application, gmminer, + [{description, "Gajumaru miner"}, {vsn, "1.0.0"}, {registered, []}, {applications, diff --git a/src/aeminer_blake2b_256.erl b/src/gmminer_blake2b_256.erl similarity index 90% rename from src/aeminer_blake2b_256.erl rename to src/gmminer_blake2b_256.erl index d83e557..8ca4f2e 100644 --- a/src/aeminer_blake2b_256.erl +++ b/src/gmminer_blake2b_256.erl @@ -1,4 +1,4 @@ --module(aeminer_blake2b_256). +-module(gmminer_blake2b_256). -export([hash/1]). diff --git a/src/aeminer_pow.erl b/src/gmminer_pow.erl similarity index 96% rename from src/aeminer_pow.erl rename to src/gmminer_pow.erl index ac8983c..13afa5c 100644 --- a/src/aeminer_pow.erl +++ b/src/gmminer_pow.erl @@ -4,7 +4,7 @@ %%% Common functions and behaviour for Proof of Work %%% @end %%%============================================================================= --module(aeminer_pow). +-module(gmminer_pow). -export([integer_to_scientific/1, next_nonce/2, @@ -22,7 +22,7 @@ instance/0 ]). --include("aeminer.hrl"). +-include("gmminer.hrl"). -type nonce() :: ?MIN_NONCE..?MAX_NONCE. @@ -38,7 +38,7 @@ -type instance() :: non_neg_integer(). --type config() :: aeminer_pow_cuckoo:config(). +-type config() :: gmminer_pow_cuckoo:config(). %%------------------------------------------------------------------------------ %% Target threshold and difficulty @@ -114,7 +114,7 @@ target_to_difficulty(SciTgt) -> -spec next_nonce(nonce(), config()) -> nonce(). next_nonce(Nonce, Cfg) -> - Nonce + aeminer_pow_cuckoo:repeats(Cfg). + Nonce + gmminer_pow_cuckoo:repeats(Cfg). -spec pick_nonce() -> nonce(). pick_nonce() -> @@ -122,7 +122,7 @@ pick_nonce() -> -spec trim_nonce(nonce(), config()) -> nonce(). trim_nonce(Nonce, Cfg) -> - case Nonce + aeminer_pow_cuckoo:repeats(Cfg) < ?MAX_NONCE of + case Nonce + gmminer_pow_cuckoo:repeats(Cfg) < ?MAX_NONCE of true -> Nonce; false -> 0 end. diff --git a/src/aeminer_pow_cuckoo.erl b/src/gmminer_pow_cuckoo.erl similarity index 96% rename from src/aeminer_pow_cuckoo.erl rename to src/gmminer_pow_cuckoo.erl index 5c77606..b654933 100644 --- a/src/aeminer_pow_cuckoo.erl +++ b/src/gmminer_pow_cuckoo.erl @@ -1,4 +1,5 @@ %%%------------------------------------------------------------------- +%%% @copyright (C) 2025, QPQ AG %%% @copyright (C) 2019, Aeternity Anstalt %%% @doc %%% A library providing Cuckoo Cycle PoW generation and verification. @@ -13,7 +14,7 @@ %%% %%% @end %%%------------------------------------------------------------------- --module(aeminer_pow_cuckoo). +-module(gmminer_pow_cuckoo). -export([config/7, addressed_instances/1, @@ -54,19 +55,19 @@ -endif. -include_lib("hut/include/hut.hrl"). --include("aeminer.hrl"). +-include("gmminer.hrl"). --type hashable() :: aeminer_blake2b_256:hashable(). +-type hashable() :: gmminer_blake2b_256:hashable(). --type hash() :: aeminer_blake2b_256:hash(). +-type hash() :: gmminer_blake2b_256:hash(). --type nonce() :: aeminer_pow:nonce(). +-type nonce() :: gmminer_pow:nonce(). --type int_target() :: aeminer_pow:int_target(). +-type int_target() :: gmminer_pow:int_target(). --type sci_target() :: aeminer_pow:sci_target(). +-type sci_target() :: gmminer_pow:sci_target(). --type instance() :: aeminer_pow:instance() +-type instance() :: gmminer_pow:instance() | undefined. -type exec() :: binary(). @@ -81,7 +82,7 @@ -type edge_bits() :: pos_integer(). --type instances() :: [aeminer_pow:instance()] +-type instances() :: [gmminer_pow:instance()] | undefined. -type solution() :: [integer()]. @@ -156,7 +157,7 @@ hex_enc_header(#config{hex_enc_header = HexEncHdr}) -> -spec hash_data(hashable()) -> hash(). hash_data(Data) -> - aeminer_blake2b_256:hash(Data). + gmminer_blake2b_256:hash(Data). %%------------------------------------------------------------------------------ %% Proof of Work generation with default settings @@ -179,7 +180,7 @@ hash_data(Data) -> {ok, {nonce(), solution()}} | {error, no_solution} | {error, {runtime, term()}}. generate(Data, Target, Nonce, Config, Instance) when Nonce >= 0, Nonce =< ?MAX_NONCE -> - Hash = aeminer_blake2b_256:hash(Data), + Hash = gmminer_blake2b_256:hash(Data), generate_from_hash(Hash, Target, Nonce, Config, Instance). -spec generate_from_hash(hash(), sci_target(), nonce(), config(), instance()) -> @@ -222,7 +223,7 @@ verify(Data, Nonce, Soln, Target, EdgeBits) when verify_proof(Data, Nonce, Solution, EdgeBits) -> %% Cuckoo has an 80 byte header, we have to use that as well %% packed Hash + Nonce = 56 bytes, add 24 bytes of 0:s - Hash = aeminer_blake2b_256:hash(Data), + Hash = gmminer_blake2b_256:hash(Data), verify_proof_from_hash(Hash, Nonce, Solution, EdgeBits). -spec verify_proof_from_hash(hash(), nonce(), solution(), edge_bits()) -> boolean(). @@ -235,7 +236,7 @@ verify_proof_from_hash(Hash, Nonce, Solution, EdgeBits) -> get_target(Soln, EdgeBits) when is_list(Soln), length(Soln) =:= ?SOLUTION_SIZE -> NodeSize = get_node_size(EdgeBits), Bin = solution_to_binary(lists:sort(Soln), NodeSize * 8, <<>>), - Hash = aeminer_blake2b_256:hash(Bin), + Hash = gmminer_blake2b_256:hash(Bin), <> = Hash, Val. @@ -309,7 +310,7 @@ exec_bin_dir(#config{exec_group = ExecGroup}) -> -define(POW_SHORT_CYCLE, {error, cycle_too_short}). verify_proof_(Header, Solution, EdgeBits) -> - {K0, K1, K2, K3} = aeminer_siphash24:create_keys(Header), + {K0, K1, K2, K3} = gmminer_siphash24:create_keys(Header), EdgeMask = (1 bsl EdgeBits) - 1, try @@ -345,7 +346,7 @@ verify_proof_(Header, Solution, EdgeBits) -> end. sipnode(K0, K1, K2, K3, Proof, UOrV, EdgeMask) -> - SipHash = aeminer_siphash24:hash(K0, K1, K2, K3, 2*Proof + UOrV) band EdgeMask, + SipHash = gmminer_siphash24:hash(K0, K1, K2, K3, 2*Proof + UOrV) band EdgeMask, (SipHash bsl 1) bor UOrV. check_cycle(Nodes0) -> @@ -398,7 +399,7 @@ find_node(X, [N1, N2 | Nodes], Acc) -> %% Since this hash is purely internal, we don't use api encoding. %% @end %%------------------------------------------------------------------------------ --spec pack_header_and_nonce(binary(), aeminer_pow:nonce()) -> string(). +-spec pack_header_and_nonce(binary(), gmminer_pow:nonce()) -> string(). pack_header_and_nonce(Hash, Nonce) when byte_size(Hash) == 32 -> %% Cuckoo originally uses 32-bit nonces inserted at the end of its 80-byte buffer. %% This buffer is hashed into the keys used by the main algorithm. @@ -599,8 +600,8 @@ test_target(Soln, Target, EdgeBits) -> test_target1(Soln, Target, NodeSize) -> Bin = solution_to_binary(lists:sort(Soln), NodeSize * 8), - Hash = aeminer_blake2b_256:hash(Bin), - aeminer_pow:test_target(Hash, Target). + Hash = gmminer_blake2b_256:hash(Bin), + gmminer_pow:test_target(Hash, Target). %%------------------------------------------------------------------------------ %% Convert solution (a list of 42 numbers) to a binary diff --git a/src/aeminer_siphash24.erl b/src/gmminer_siphash24.erl similarity index 91% rename from src/aeminer_siphash24.erl rename to src/gmminer_siphash24.erl index 33246ad..c069921 100644 --- a/src/aeminer_siphash24.erl +++ b/src/gmminer_siphash24.erl @@ -5,7 +5,7 @@ %%% @end %%%============================================================================= --module(aeminer_siphash24). +-module(gmminer_siphash24). -export([create_keys/1, hash/5]). @@ -28,12 +28,12 @@ %%%============================================================================= -spec create_keys(binary()) -> - {aeminer_siphash24:siphash_key(), - aeminer_siphash24:siphash_key(), - aeminer_siphash24:siphash_key(), - aeminer_siphash24:siphash_key()}. + {gmminer_siphash24:siphash_key(), + gmminer_siphash24:siphash_key(), + gmminer_siphash24:siphash_key(), + gmminer_siphash24:siphash_key()}. create_keys(Header) -> - AuxHash = <<_:32/binary>> = aeminer_blake2b_256:hash(Header), + AuxHash = <<_:32/binary>> = gmminer_blake2b_256:hash(Header), < HeaderEquivalent = <<0:(44*8), (base64:encode(<>))/binary, 0:(24*8)>>, 42 = length(Solution), - true = aeminer_pow_cuckoo:verify_proof_(HeaderEquivalent, Solution, 15), + true = gmminer_pow_cuckoo:verify_proof_(HeaderEquivalent, Solution, 15), ok. diff --git a/test/aeminer_pow_cuckoo_tests.erl b/test/gmminer_pow_cuckoo_tests.erl similarity index 97% rename from test/aeminer_pow_cuckoo_tests.erl rename to test/gmminer_pow_cuckoo_tests.erl index c9f228b..8b24039 100644 --- a/test/aeminer_pow_cuckoo_tests.erl +++ b/test/gmminer_pow_cuckoo_tests.erl @@ -1,17 +1,18 @@ %%%============================================================================= +%%% @copyright (C) 2025, QPQ AG %%% @copyright (C) 2019, Aeternity Anstalt %%% @doc -%%% Unit tests for the aeminer_pow_cuckoo module +%%% Unit tests for the gmminer_pow_cuckoo module %%% @end %%%============================================================================= --module(aeminer_pow_cuckoo_tests). +-module(gmminer_pow_cuckoo_tests). -include_lib("eunit/include/eunit.hrl"). --include("aeminer.hrl"). +-include("gmminer.hrl"). --define(TEST_MODULE, aeminer_pow_cuckoo). --define(POW_MODULE, aeminer_pow). +-define(TEST_MODULE, gmminer_pow_cuckoo). +-define(POW_MODULE, gmminer_pow). -define(TEST_BIN, <<"wsffgujnjkqhduihsahswgdf">>). -define(TEST_HIGH_NONCE, 38). %% Nonce with solution with high target. diff --git a/test/aeminer_pow_tests.erl b/test/gmminer_pow_tests.erl similarity index 97% rename from test/aeminer_pow_tests.erl rename to test/gmminer_pow_tests.erl index 54097bb..cd9a73d 100644 --- a/test/aeminer_pow_tests.erl +++ b/test/gmminer_pow_tests.erl @@ -1,16 +1,17 @@ %%%============================================================================= +%%% @copyright (C) 2025, QPQ AG %%% @copyright (C) 2019, Aeternity Anstalt %%% @doc -%%% Unit tests for the aeminer_pow module +%%% Unit tests for the gmminer_pow module %%% @end %%%============================================================================= --module(aeminer_pow_tests). +-module(gmminer_pow_tests). -include_lib("eunit/include/eunit.hrl"). --define(TEST_MODULE, aeminer_pow). +-define(TEST_MODULE, gmminer_pow). --include("aeminer.hrl"). +-include("gmminer.hrl"). conversion_test_() -> {setup, @@ -47,7 +48,7 @@ conversion_test_() -> ?assertEqual(255, ?TEST_MODULE:scientific_to_integer(16#0200ff00)), ?assertEqual(16#800000, ?TEST_MODULE:scientific_to_integer(16#04008000)), ?assertEqual(?HIGHEST_TARGET_INT, - aeminer_pow:scientific_to_integer(?HIGHEST_TARGET_SCI)) + gmminer_pow:scientific_to_integer(?HIGHEST_TARGET_SCI)) end}, {"Integer to scientific and back", fun() ->