Skip to content

Commit 34cb2d7

Browse files
Fix ordering of preimage concatenation to match bip340, h(P||R||m) -> h(R||P||m)
1 parent b6d87a3 commit 34cb2d7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

_topics/en/adaptor-signatures.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Alice creates a valid signature commitment (`s`) for the transaction paying Bob
168168
(`P = pG`). She also uses a private random nonce (`r`), a hidden value
169169
(`t`), and the elliptic curve points for them (`R = rG, T = tG`):
170170

171-
s = r + t + H(P || R + T || m) * p
171+
s = r + t + H(R + T || P || m) * p
172172

173173
She subtracts `t` from the signature commitment to produce a signature adaptor:
174174

@@ -181,20 +181,20 @@ data:
181181

182182
Bob can verify the adaptor:
183183

184-
s' * G ?= R + H(P || R+T || m) * P
184+
s' * G ?= R + H(R + T || P || m) * P
185185

186186
But the adaptor is not a valid BIP340 signature. For a valid signature, BIP340 expects
187187
`x` and `Y`, using them with the expression:
188188

189-
x * G ?= Y + H(P || Y || m) * P
189+
x * G ?= Y + H(Y || P || m) * P
190190

191191
However,
192192

193193
- If Bob sets `Y = R` so that it matches the `s'` he received in the
194-
adaptor, then BIP340 is going to fail on `H(P || R || m)`
195-
since Alice computed her hash with `H(P || R + T || m)`.
194+
adaptor, then BIP340 is going to fail on `H(R || P || m)`
195+
since Alice computed her hash with `H(R + T || P || m)`.
196196

197-
- If Bob sets `Y = R + T` so that it matches `H(P || R + T || m)`, BIP340
197+
- If Bob sets `Y = R + T` so that it matches `H(R + T || P || m)`, BIP340
198198
is going to fail on the initial `Y` since Bob is providing `R + T`
199199
rather than the needed `R`.
200200

@@ -204,7 +204,7 @@ signature Alice created but Bob doesn't commit to `t` here, since Bob
204204
doesn't know that value. All variables here except `T` are different
205205
for Bob than they were for Alice:
206206

207-
s = r + H(P || R + T || m) * p
207+
s = r + H(R + T || P || m) * p
208208

209209
Unlike Alice, Bob doesn't need to tweak his signature. Bob's signature commitment `s` is
210210
not a part of a valid signature because it commits to `r` and `R + T`, which
@@ -221,7 +221,7 @@ adaptor so we use its full form. Alice can produce a
221221
signature from that adaptor using the hidden `t` value that
222222
only she knows so far:
223223

224-
(s + t) * G ?= R + T + H(P || R + T || m) * P
224+
(s + t) * G ?= R + T + H(R + T || P || m) * P
225225

226226
Alice uses the signature to broadcast Bob's transaction that
227227
pays her. When Bob sees `(s + t)` onchain, he can learn the value of `t`:
@@ -231,7 +231,7 @@ pays her. When Bob sees `(s + t)` onchain, he can learn the value of `t`:
231231
He can then use `t` to solve the adaptor Alice gave him
232232
earlier:
233233

234-
(s' + t) * G ?= R + T + H(P || R + T || m) * P
234+
(s' + t) * G ?= R + T + H(R + T || P || m) * P
235235

236236
Bob uses that signature to broadcast the transaction Alice
237237
originally gave him.

0 commit comments

Comments
 (0)