Exercises

Same setup as before. This time the tweak has P inside it.

Your job is to run the attack again and watch it fail.

from secp256k1 import *

d = 0x1111111111111111111111111111111111111111111111111111111111111111
P = point_mul(d)

contract  = "Alice agrees to pay 10 BTC to Bob"
contract2 = "Alice agrees to pay 0.1 BTC to Bob"

Task 1: The new tweak

Write the tweak function. The only change is that P goes in the hash.

Task 2: Try the old attack

Alice runs exactly the same trick as last time.

Why did it fail? She needed t2 to pick P2. But the real t2 depends on P2, which didn't exist yet.

Task 3: Brute force

Fine, forget algebra. Just try random keys until one works.

A few tries is nothing. Neither is 2⁶⁴. To land on Q this way you'd have to break SHA-256.

Solution code

Question

In Task 2, Alice had to guess t2 before she could compute P2.

Write down, in one sentence, the loop she is stuck in.

Suggest Edits