From 1b6c85b0b4823ce77ca4123ca52ee7f64925e271 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Mon, 31 Jan 2022 18:52:37 +0900 Subject: [PATCH 1/3] bip-322: clarify how the message is serialized --- bip-0322.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bip-0322.mediawiki b/bip-0322.mediawiki index 9b5afed4..ed384402 100644 --- a/bip-0322.mediawiki +++ b/bip-0322.mediawiki @@ -61,7 +61,7 @@ The to_spend transaction is: vout[0].nValue = 0 vout[0].scriptPubKey = message_challenge -where message_hash is a BIP340-tagged hash of the message, i.e. sha256_tag(m), where tag = BIP0322-signed-message, and message_challenge is the to be proven (public) key script. +where message_hash is a BIP340-tagged hash of the message, i.e. sha256_tag(m), where tag = BIP0322-signed-message and m is the message as is without length prefix or null terminator, and message_challenge is the to be proven (public) key script. The to_sign transaction is: From aa92d9cd6e6dd334f4a21c1faf41cb7fe88eed74 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Wed, 26 Jan 2022 19:17:52 +0900 Subject: [PATCH 2/3] add test vectors to BIP-322 --- bip-0322.mediawiki | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bip-0322.mediawiki b/bip-0322.mediawiki index ed384402..c0978fc1 100644 --- a/bip-0322.mediawiki +++ b/bip-0322.mediawiki @@ -144,7 +144,7 @@ This specification is backwards compatible with the legacy signmessage/verifymes == Reference implementation == -TODO +* Bitcoin Core pull request (basic support) at: https://github.com/bitcoin/bitcoin/pull/24058 == Acknowledgements == @@ -160,4 +160,21 @@ This document is licensed under the Creative Commons CC0 1.0 Universal license. == Test vectors == -TODO +=== Message hashing === + +Message hashes are BIP340-tagged hashes of a message, i.e. sha256_tag(m), where tag = BIP0322-signed-message, and m is the message as is without length prefix or null terminator: + +* Message = "" (empty string): c90c269c4f8fcbe6880f72a721ddfbf1914268a794cbb21cfafee13770ae19f1 +* Message = "Hello World": f0eb03b1a75ac6d9847f55c624a99169b5dccba2a31f5b23bea77ba270de0a7a + +=== Message signing === + +Given below parameters: + +* private key L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k +* corresponding address bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l + +Produce signatures: + +* Message = "" (empty string): AkcwRAIgFuS8y5m0ym9Gj2odoVB5NIL+cPYkeEj8LL1N/6P58X8CIA6jJ9QH2iYKRXVfmhsDzHq1bMS4Adj0nb8DDSdN/SpBASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI= +* Message = "Hello World": AkcwRAIgG3PASL/vRTgAqogWT6S8rUOQXNnfRzX6JncmbFlHc1ACIGQdsW+rnVmsQzyAYRQisHKFMigDmKiL7LUw4x17Fw5tASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI= From f52e047d09d6ddc7c2dbf6549dfdc91c09e9a026 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Wed, 2 Feb 2022 12:39:11 +0900 Subject: [PATCH 3/3] clarify that SIMPLE format requires version/locktime/sequence=0 for to_sign transaction --- bip-0322.mediawiki | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bip-0322.mediawiki b/bip-0322.mediawiki index c0978fc1..3638d58f 100644 --- a/bip-0322.mediawiki +++ b/bip-0322.mediawiki @@ -65,11 +65,11 @@ where message_hash is a BIP340-tagged hash of the message, i.e. sha The to_sign transaction is: - nVersion = 0 or as appropriate (e.g. 2, for time locks) - nLockTime = 0 or as appropriate (for time locks) + nVersion = 0 or (FULL format only) as appropriate (e.g. 2, for time locks) + nLockTime = 0 or (FULL format only) as appropriate (for time locks) vin[0].prevout.hash = to_spend.txid vin[0].prevout.n = 0 - vin[0].nSequence = 0 or as appropriate (for time locks) + vin[0].nSequence = 0 or (FULL format only) as appropriate (for time locks) vin[0].scriptWitness = message_signature vout[0].nValue = 0 vout[0].scriptPubKey = OP_RETURN