Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #61 from matter-labs/vb-fix-oz-keccak256-audit-n-02
Browse files Browse the repository at this point in the history
Add comments for keccak256 wrapper
  • Loading branch information
StanislavBreadless authored Nov 21, 2023
2 parents 123bb68 + a90e2c0 commit d2001f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion contracts/precompiles/Keccak256.yul
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ object "Keccak256" {
// CONSTANTS
////////////////////////////////////////////////////////////////

/// @dev The size of the processing keccak256 block in bytes.
/// @dev Returns the block size used by the keccak256 hashing function.
/// The value 136 bytes corresponds to the size of the input data block that the keccak256
/// algorithm processes in each round, as defined in the keccak256 specification. This is derived
/// from the formula (1600 - 2 * bit length of the digest) / 8, where the bit length for keccak256
/// is 256 bits. For more details, refer to the Keccak specification at
/// https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf#page=30
function BLOCK_SIZE() -> ret {
ret := 136
}

/// @dev The gas cost of processing one keccak256 round.
/// @dev This constant is made equal to the corresponding constant in
/// https://github.com/matter-labs/era-zkevm_opcode_defs/blob/v1.4.1/src/circuit_prices.rs,
/// which was automatically generated depending on the capacity of rounds for a
/// single Keccak256 circuit.
function KECCAK_ROUND_GAS_COST() -> ret {
ret := 40
}
Expand Down

0 comments on commit d2001f6

Please sign in to comment.