Insecure Commitment
So far we've treated as just a number, a 32 byte scalar.
If is just random, this tweak achieves nothing. We've turned a key into another key , and now we spend with instead of . What's the point !!
But let's take another case. We treat as the hash of some data, a contract.
Imagine we have:
contract = "Alice pays Bob 2 BTC"t = hash(contract)So now is not a random 32 byte value anymore. It's the 32 byte output of a hash of a contract.
We say 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 changes, and if changes then changes too.
That's the whole trick:
A tweaked key is a commitment carried inside a public key .
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:
Then she pays to .
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:
Alice wants the fake contract to give the same . So she picks a different private key:
is the private key for a new point . And now she computes:
Did you notice ? Alice got the same using a different contract.
Bob is unaware of any of this. He only ever sees .
So the same commits to both contracts:
What Bob actually loses
Bob thought was proof that Alice committed to paying him 10 BTC.
But Alice can open that same to whichever contract suits her. Later she just shows 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 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.
