Insecure Commitment

So far we've treated tt as just a number, a 32 byte scalar.

If tt is just random, this tweak achieves nothing. We've turned a key PP into another key QQ, and now we spend with d+td + t instead of dd. What's the point !!

But let's take another case. We treat tt as the hash of some data, a contract.

Imagine we have:

contract = "Alice pays Bob 2 BTC"t = hash(contract)

So now tt is not a random 32 byte value anymore. It's the 32 byte output of a hash of a contract.

Q=P+tG=P+hash(contract)GQ = P + t \cdot G = P + \text{hash(contract)} \cdot G

We say QQ commits to the contract.

It means the contract can't be changed. If someone tries to cheat and replaces "Alice pays Bob 2 BTC" with "Alice pays Bob 5 BTC", then tt changes, and if tt changes then QQ changes too.

That's the whole trick:

A tweaked key is a commitment carried inside a public key QQ.


Insecure commitment

Imagine this scenario.

Alice wants to pay Bob 10 BTC. She creates a contract:

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

Then she generates the tweaked key that commits to this contract:

t=hash(contract)Q=P+tGt = \text{hash(contract)} \qquad Q = P + t \cdot G

Then she pays to QQ.

Everything is good until now, right ?

It isn't.

Why it breaks

Imagine Alice makes a second contract:

contract' = "Alice agrees to pay 0.1 BTC to Bob"t' = hash(contract')

A contract that pays Bob 0.1 instead of 10 BTC.

Let's do some math. We know:

Q=P+tG=dG+tG=(d+t)GQ = P + t \cdot G = d \cdot G + t \cdot G = (d + t) \cdot G

Alice wants the fake contract tt' to give the same QQ. So she picks a different private key:

d=d+ttd' = d + t - t'

dd' is the private key for a new point PP'. And now she computes:

(d+t)G=(d+tt+t)G=(d+t)G=Q← forged(d' + t') \cdot G = (d + t - t' + t') \cdot G = (d + t) \cdot G = Q \quad \text{← forged}

Did you notice ? Alice got the same QQ using a different contract.

Bob is unaware of any of this. He only ever sees QQ.

So the same QQ commits to both contracts:

Q=P+tGQ=P+tGQ = P + t \cdot G \qquad Q = P' + t' \cdot G

What Bob actually loses

Bob thought QQ was proof that Alice committed to paying him 10 BTC.

But Alice can open that same QQ to whichever contract suits her. Later she just shows PP' and contract', and claims the deal was always 0.1 BTC. Bob has no way to prove otherwise.

A commitment is only useful if it can be opened one way. This one can be opened two ways, so it's worth nothing.

The root cause

Look at what Alice did: she chose PP after choosing the contract.

Nothing in t = hash(contract) stops her. The tweak knows about the contract, but it knows nothing about which key it is being added to.

That's the hole we need to close, and it's what the next lesson is about.

Suggest Edits