Skip to main content
3 of 3
added 45 characters in body
user2284570
  • 343
  • 2
  • 16

Swapping a single bit inside a 40 bytes inputs fed to keccak256. Is it safe to assume no change in the first 20 bytes can result in the same hash?

I have the following data (represented as hex from binary below) where the lower bytes is controlled by attacker in the second case :

0x00: 000000000000000000000000cf269986 ????????????????
0x10: da781407b0eeeac3ea79ac1c9d857d38 ?x???????y?????8
0x20: 00000000000000000000000000000000 ????????????????
0x30: 00000000000000000000000000000001 ????????????????
0x40: 00000000000000000000000000000000 ????????????????

which does 0x1350c327906a2da929ed2a625e133cdfc3aaa945d7540e93b1266293dd2c1d11.

0x00: 000000000000000000000000cf269986 ????????????????
0x10: da781407b0eeeac3ea79ac1c9d857d38 ?x???????y?????8
0x20: 00000000000000000000000000000000 ????????????????
0x30: 00000000000000000000000000000002 ????????????????
0x40: 00000000000000000000000000000000 ????????????????

which does 0xf11930e4cc6cdaaaa9da21243f512da3fba796ffa7c74870669af9cee3a06c0c. Because the use of 0x2 from 0x1 left shift a single bit by one (but both inputs keep the same length).

Even if the change is about a single byte, there’s no way to modify the first 20 bytes of the second case so the hash is equal to 0x1350c327906a2da929ed2a625e133cdfc3aaa945d7540e93b1266293dd2c1d11(the hash of first case) without requiring a computational power not available on the short term, right ?

user2284570
  • 343
  • 2
  • 16