dev-rewards
dev-rewards copied to clipboard
HASH=$(...) fails silently if the wrong sha3sum is installed
Suppose you're on a Mac and you've run brew install sha3sum, giving you a sha3sum command that's incompatible with the expected one.
Then this line:
HASH=$(echo -n "$DATA_HEX" | xxd -r -p | (sha3sum -a Keccak256 -t || true) | sed 's/[^[:xdigit:]].*//')
writes
/opt/homebrew/bin/sha3sum: valid arguments for -a are 224 (default), 256, 384, and 512
to stderr and returns an empty value. Later on,
SIGNATURE_HEX=$(echo "$HASH" | xxd -r -p | openssl pkeyutl -sign -inkey "$ETH_KEY" | xxd -p -c 72)
will successfully sign an empty string.