Skip to content

Latest commit

 

History

History
22 lines (12 loc) · 1.06 KB

Puzzle3.md

File metadata and controls

22 lines (12 loc) · 1.06 KB

Analysis

Let's break down the bytecode and understand the flow of execution to find the answer:

  1. CALLDATASIZE (36): This opcode pushes the size of the calldata (in bytes) onto the stack.

  2. JUMP (56): This opcode alters the program counter to the location specified by the top stack item. It jumps to the location if it's a valid JUMPDEST.

  3. JUMPDEST (5B): Marks a valid destination for jumps.

  4. STOP (00): Halts execution.

Execution

  • At byte 00, CALLDATASIZE will push the size of the calldata onto the stack.
  • At byte 01, JUMP will use this value to determine where to jump.

Since the only JUMPDEST in this sequence is at byte 04, for the JUMP at byte 01 to be successful, the value pushed by CALLDATASIZE must be 04 (in hexadecimal). This means the calldata's size should be 4 bytes.

Here, the actual content of these 4 bytes doesn't impact the execution flow in this case, as only their size is used.

Therefore, a valid calldata could be 0x12345678, where 0x denotes the hexadecimal representation, and the following 8 characters represent 4 bytes.