Repository: summa-tx/bitcoin-spv (language: rust)

Issue:
Unnecessary type correction in BTCUtils
#### Description

 The type correction `encodePacked().toBytes32()` is not needed as `sha256` already returns `bytes32`.

#### Examples

https://github.com/summa-tx/bitcoin-spv/blob/f5e4da091a1c97e6432c2d70eba434edb189f919/solidity/contracts/BTCUtils.sol#L114-L117

#### Recommendation

Refactor to `return sha256(abi.encodePacked(sha256(_b)));` to save gas.



Discussion / hints:

Fix patch:
diff --git a/solidity/contracts/BTCUtils.sol b/solidity/contracts/BTCUtils.sol
index 870e15f6..b5ded559 100644
--- a/solidity/contracts/BTCUtils.sol
+++ b/solidity/contracts/BTCUtils.sol
@@ -112,7 +112,7 @@ library BTCUtils {
     /// @param _b        The pre-image
     /// @return          The digest
     function hash256(bytes memory _b) internal pure returns (bytes32) {
-        return abi.encodePacked(sha256(abi.encodePacked(sha256(_b)))).toBytes32();
+        return sha256(abi.encodePacked(sha256(_b)));
     }
 
     /// @notice          Implements bitcoin's hash256 (double sha2)


Test patch: