github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/dispute/lib/LibHashing.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity ^0.8.15;
     3  
     4  import "src/libraries/DisputeTypes.sol";
     5  
     6  /// @title Hashing
     7  /// @notice This library contains all of the hashing utilities used in the Cannon contracts.
     8  library LibHashing {
     9      /// @notice Hashes a claim and a position together.
    10      /// @param _claim A Claim type.
    11      /// @param _position The position of `claim`.
    12      /// @param _challengeIndex The index of the claim being moved against.
    13      /// @return claimHash_ A hash of abi.encodePacked(claim, position|challengeIndex);
    14      function hashClaimPos(
    15          Claim _claim,
    16          Position _position,
    17          uint256 _challengeIndex
    18      )
    19          internal
    20          pure
    21          returns (ClaimHash claimHash_)
    22      {
    23          assembly {
    24              mstore(0x00, _claim)
    25              mstore(0x20, or(shl(128, _position), and(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, _challengeIndex)))
    26              claimHash_ := keccak256(0x00, 0x40)
    27          }
    28      }
    29  }