The issue is that, for such _sign implementation, use of bytes.concat() is not recommended as bytes.concat() per solidity documentation is used in case:
the bytes.concat function can concatenate an arbitrary number of bytes or bytes1 ... bytes32 values. The function returns a single bytes memory array that contains the contents of the arguments without padding.
_sigHash is a single input in bytes32 form and its not arbitrary number of bytes to use the bytes.concate().
Further, Sapphire has used abi.encodePacked() instead of bytes.concat() wherever Sapphire.sign() function used.
For example in Sapphire'sEthereumUtils.sol , see below how bytes32 digest has used abi.encodePacked to concatenate the bytes.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xeb5f742f50e72bd0b9a2ab9f05147ae2a027e65f13e3cceb384b38a88d86c2ef Severity: low
Description: Description\
AbstractTxSerializer.sol
,_sign()
has usedbytes.concat
to concatenate the input bytes32_sigHash
:Affected code: https://github.com/hats-finance/illuminex-0x0bb4aa1f58719707405c231fcdf0b405714799cf/blob/3ad7c2aedf991493aab45d3e0847b7e07f5c0d07/packages/contracts/contracts/illuminex/xengine/chains/btc/wallet/tx-serializer/AbstractTxSerializer.sol#L90
The issue is that, for such
_sign
implementation, use ofbytes.concat()
is not recommended asbytes.concat()
per solidity documentation is used in case:_sigHash
is a single input in bytes32 form and its not arbitrary number of bytes to use the bytes.concate().Further, Sapphire has used
abi.encodePacked()
instead ofbytes.concat()
whereverSapphire.sign()
function used.For example in
Sapphire's
EthereumUtils.sol , see below how bytes32digest
has usedabi.encodePacked
to concatenate the bytes.Therefore, its recommended to use
abi.encodePacked()
.Recommendation to fix\ Consider below changes in
AbstractTxSerializer.sol
: