Skip to content

Commit 97e02b2

Browse files
authored
Merge pull request bitcoin#1279 from kallewoof/202201-bip322-testvecs
clarify message serialization and add test vectors to BIP-322
2 parents 02de475 + f52e047 commit 97e02b2

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

bip-0322.mediawiki

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ The <code>to_spend</code> transaction is:
6161
vout[0].nValue = 0
6262
vout[0].scriptPubKey = message_challenge
6363
64-
where <code>message_hash</code> is a BIP340-tagged hash of the message, i.e. sha256_tag(m), where tag = <code>BIP0322-signed-message</code>, and <code>message_challenge</code> is the to be proven (public) key script.
64+
where <code>message_hash</code> is a BIP340-tagged hash of the message, i.e. sha256_tag(m), where tag = <code>BIP0322-signed-message</code> and <code>m</code> is the message as is without length prefix or null terminator, and <code>message_challenge</code> is the to be proven (public) key script.
6565

6666
The <code>to_sign</code> transaction is:
6767

68-
nVersion = 0 or as appropriate (e.g. 2, for time locks)
69-
nLockTime = 0 or as appropriate (for time locks)
68+
nVersion = 0 or (FULL format only) as appropriate (e.g. 2, for time locks)
69+
nLockTime = 0 or (FULL format only) as appropriate (for time locks)
7070
vin[0].prevout.hash = to_spend.txid
7171
vin[0].prevout.n = 0
72-
vin[0].nSequence = 0 or as appropriate (for time locks)
72+
vin[0].nSequence = 0 or (FULL format only) as appropriate (for time locks)
7373
vin[0].scriptWitness = message_signature
7474
vout[0].nValue = 0
7575
vout[0].scriptPubKey = OP_RETURN
@@ -144,7 +144,7 @@ This specification is backwards compatible with the legacy signmessage/verifymes
144144

145145
== Reference implementation ==
146146

147-
TODO
147+
* Bitcoin Core pull request (basic support) at: https://github.com/bitcoin/bitcoin/pull/24058
148148
149149
== Acknowledgements ==
150150

@@ -160,4 +160,21 @@ This document is licensed under the Creative Commons CC0 1.0 Universal license.
160160

161161
== Test vectors ==
162162

163-
TODO
163+
=== Message hashing ===
164+
165+
Message hashes are BIP340-tagged hashes of a message, i.e. sha256_tag(m), where tag = <code>BIP0322-signed-message</code>, and m is the message as is without length prefix or null terminator:
166+
167+
* Message = "" (empty string): <code>c90c269c4f8fcbe6880f72a721ddfbf1914268a794cbb21cfafee13770ae19f1</code>
168+
* Message = "Hello World": <code>f0eb03b1a75ac6d9847f55c624a99169b5dccba2a31f5b23bea77ba270de0a7a</code>
169+
170+
=== Message signing ===
171+
172+
Given below parameters:
173+
174+
* private key <code>L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k</code>
175+
* corresponding address <code>bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l</code>
176+
177+
Produce signatures:
178+
179+
* Message = "" (empty string): <code>AkcwRAIgFuS8y5m0ym9Gj2odoVB5NIL+cPYkeEj8LL1N/6P58X8CIA6jJ9QH2iYKRXVfmhsDzHq1bMS4Adj0nb8DDSdN/SpBASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI=</code>
180+
* Message = "Hello World": <code>AkcwRAIgG3PASL/vRTgAqogWT6S8rUOQXNnfRzX6JncmbFlHc1ACIGQdsW+rnVmsQzyAYRQisHKFMigDmKiL7LUw4x17Fw5tASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI=</code>

0 commit comments

Comments
 (0)