Skip to content

Instantly share code, notes, and snippets.

@ItsCuzzo
Created August 9, 2022 07:13
Show Gist options
  • Save ItsCuzzo/472db3ffba0bf1034bbaf642cac23123 to your computer and use it in GitHub Desktop.
Save ItsCuzzo/472db3ffba0bf1034bbaf642cac23123 to your computer and use it in GitHub Desktop.
Testing keccak in assembly.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
contract KekTest {
/// 22578
function regHash(uint256 a, uint256 b) external pure returns (bytes32) {
return keccak256(abi.encodePacked(a, b));
}
/// 22160
function asmHash(uint256 a, uint256 b) external pure returns (bytes32 _hash) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
_hash := keccak256(0x00, 64)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment