Closed thegostep closed 5 years ago
For the first 3 options, it would be worthwhile to perform input validation by checking the length of the bytes field
Option 2:
function _combineMultiHash(MultiHash memory multihash) internal pure returns (bytes memory) {
return abi.encode(multihash.hashFunction, multihash.digestSize, multihash.hash);
}
function _splitMultiHash(bytes memory source) internal pure returns (MultiHash memory) {
(uint8 hashFunction, uint8 digestSize, bytes32 hash) = abi.decode(source, (uint8,uint8,bytes32));
return MultiHash(hash, hashFunction, digestSize);
}
For now, split using assembly and source length validation
Options: