Skip to content

Commit

Permalink
Assert key size before signing blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Berman committed Jan 16, 2025
1 parent 0efb87b commit 8f0f729
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/arweave/src/ar_node_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2187,16 +2187,19 @@ assert_key_type(RewardKey, Height) ->
case Height >= ar_fork:height_2_9() of
false ->
case RewardKey of
{{?RSA_KEY_TYPE, _, _}, {?RSA_KEY_TYPE, _}} ->
{{?RSA_KEY_TYPE, _, _}, {?RSA_KEY_TYPE, Pub}} ->
true = byte_size(Pub) == 512,
ok;
_ ->
exit(invalid_reward_key)
end;
true ->
case RewardKey of
{{?RSA_KEY_TYPE, _, _}, {?RSA_KEY_TYPE, _}} ->
{{?RSA_KEY_TYPE, _, _}, {?RSA_KEY_TYPE, Pub}} ->
true = byte_size(Pub) == 512,
ok;
{{?ECDSA_KEY_TYPE, _, _}, {?ECDSA_KEY_TYPE, _}} ->
{{?ECDSA_KEY_TYPE, _, _}, {?ECDSA_KEY_TYPE, Pub}} ->
true = byte_size(Pub) == ?ECDSA_PUB_KEY_SIZE,
ok;
_ ->
exit(invalid_reward_key)
Expand Down

0 comments on commit 8f0f729

Please sign in to comment.