Question about the SHA-1 Collision

Hi. I'm using Jimmy Song's book and there is something I do not understand. I am working through the SHA-1 collision in the end of chapter 6 on Script:

Here is the ScriptPubKey:

6E – 2DUP

87 – EQUAL

91 – NOT

69 – VERIFY

A7 – SHA1

7C – SWAP

A7 – SHA1

87 – EQUAL

I'll assume that there are two values there that we can call x and y. The top of the stack is at the end of the list.

x, y

2DUP(x,y) = (x, y, y, y)

EQUAL(x, y, y, y) = (x, y, 1)

NOT(x, y, 1) = (x, y, 0)

VERIFY(x, y, 0) -> FAIL!

SHA1(x, y) = (x, SHA1[y])

SWAP(x, SHA1[y]) = (SHA1[y], x)

SHA1(SHA1[y], x) = (SHA1[y], SHA1[x])

EQUAL(SHA1[y], SHA1[x]) -> Will be true if you find the collision.

I do not understand what the four commands are doing at the beginning.

EDIT: I made a mistake on 2DUP.

x, y

2DUP(x,y) = (x, y, x, y)

EQUAL(x, y, y, y) = (x, y, 0) #Check that the two values are unequal

NOT(x, y, 1) = (x, y, 1)

VERIFY(x, y, 1) -> PASS!, will fail if they are equal.

SHA1(x, y) = (x, SHA1[y])

SWAP(x, SHA1[y]) = (SHA1[y], x)

SHA1(SHA1[y], x) = (SHA1[y], SHA1[x])

EQUAL(SHA1[y], SHA1[x]) -> Will be true if you find the collision.

submitted by /u/extrastone
[link] [comments]

Leave a Reply

Your email address will not be published. Required fields are marked *