motoko-base
motoko-base copied to clipboard
Class `SHA224` in `Principal.mo` contains dead data
let ivs : [[Nat32]] = [
should be a one-dimensional array for only the first 8 values. This also implies simplifying the func reset()
.
Furthermore the iv
in let (sum_bytes, iv) = (28, 0);
can be eliminated (probably).
Yes, iv
and sum_bytes
can both be eliminated from the code and their values hardcoded in the single place where they are used (e.g. iv
in the reset()
function).
Btw, I also noticed that the SHA224 class does not use the latest code from https://github.com/research-ag/sha2. The difference being that the current code there uses direct conversion between Nat8 <-> Nat16 <-> Nat32 and eliminates heap allocations. Anyway, probably not worth touching the whole code again.