Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 1.17 KB

Puzzle4.md

File metadata and controls

31 lines (19 loc) · 1.17 KB

Analysis

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

  1. CALLVALUE (34): This opcode gets the value sent with the transaction and pushes it onto the stack.

  2. CODESIZE (38): This opcode pushes the size of the code (in bytes) onto the stack.

  3. XOR (18): This opcode performs a bitwise exclusive OR (XOR) between the top two values on the stack and pushes the result back onto the stack. In this case, it will XOR V (CALLVALUE) and 0C (CODESIZE).

  4. 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.

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

  6. STOP (00): Halts execution.

Execution

  • The XOR operation at byte 02 will XOR the values V and 0C.

  • For the JUMP at byte 03 to be successful, the result of the XOR operation must be 0A, which is the address of JUMPDEST.

  • The XOR operation can be expressed as:

      V XOR 0C = 0A (hex)
      V = 0A XOR 0C
      V = 10 XOR 12 (dec)
    
      10: 00001100 (binary)
      12: 00001010 (binary)
      ----------------------
      06: 00000110 (binary)