summaryrefslogtreecommitdiff
path: root/cd/96101e87aa4dc5b07e6c37d5b0489dda03e1e3
blob: 1d8239f2ec48affe1635a608c898775b086ced42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Return-Path: <mocay5760@gmail.com>
Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 98C50C002D
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Sat,  5 Nov 2022 08:46:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by smtp3.osuosl.org (Postfix) with ESMTP id 66BDA6119B
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Sat,  5 Nov 2022 08:46:30 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 66BDA6119B
Authentication-Results: smtp3.osuosl.org;
 dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
 header.a=rsa-sha256 header.s=20210112 header.b=Wcd+N5Nv
X-Virus-Scanned: amavisd-new at osuosl.org
X-Spam-Flag: NO
X-Spam-Score: -0.848
X-Spam-Level: 
X-Spam-Status: No, score=-0.848 tagged_above=-999 required=5
 tests=[BAYES_00=-1.9, BITCOIN_OBFU_SUBJ=1, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001] autolearn=no autolearn_force=no
Received: from smtp3.osuosl.org ([127.0.0.1])
 by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id vFa5EiJtABrr
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Sat,  5 Nov 2022 08:46:29 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.8.0
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 87A5760AC2
Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com
 [IPv6:2a00:1450:4864:20::52c])
 by smtp3.osuosl.org (Postfix) with ESMTPS id 87A5760AC2
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Sat,  5 Nov 2022 08:46:29 +0000 (UTC)
Received: by mail-ed1-x52c.google.com with SMTP id a5so10636213edb.11
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Sat, 05 Nov 2022 01:46:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=stqyjavhu0eX+4uUUNZfR3f8DJVm5LqgmeJb/vXEpgY=;
 b=Wcd+N5NvS3iYxD9QXHIzeAU65X95D262PA0BWkc2gE7/rNGzdzWZ5kGkhJqsmwq0Ss
 L2yyBeYUIccG8k2brN+B7/Vh7bXr73yFxrdQeiqFlXpG0EgYGxE4/jOhnW1Sw5uK0kJ1
 ZAM3XqPpRrYyD0mQUyGiFzsQDgrdrgi1ihYSvgZOamrC70ZbqSJHkX4AsOJSgG7agzZQ
 GFDA/gabjbjzXOmzQ/xVLYp8M/PjLs7DgmHO3VL+z8BFnZ8tT3ZfVy8+6zHxkphJwxb5
 n1iMPH78WmvNLHHYqn+7gmO06aE8pIAa0QNs9mLN7Ur1pNgFWWd5Kig3B2PmcXAYt4P2
 5QJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=stqyjavhu0eX+4uUUNZfR3f8DJVm5LqgmeJb/vXEpgY=;
 b=3VwjyR2XZtiESaRWkdP73w8Gnks+vjDrI05TJXd5TfluErh6hZ9QPZEND7rP9fGqHU
 MY+yyMQiUa2/Y6NRYs9SmBdgVOaqhmyWyDWK4/QM+wySsAqkEUKXQDwhEltv1gmhwPqm
 z8f+Y4THproTfIQMh5iYsynTHKhGtA3fLQRogjC+lTocF6gH2W7rtDdtJYoTaI6WvXuG
 XtHxLQFgnHng0XgsYsVbAzaEKbadf3QAvE2nG79ZUiiINazDZXTVFCu5EN8WCETzun/T
 zSw2dKYpodSOcCVcjabxzaILScXJpePerVApnObjHIJyPaymtP7cSkzYQLwNS57Uuzmn
 chVw==
X-Gm-Message-State: ACrzQf2KVewLRBImBe3m/iCOpb6B8P6UApeBXMoM7w6F+w1RUuPnc9Cs
 kxZ5NDlasxhqETeoICKy1GC9W//1UydLfBYhkDSWV/oHn+4=
X-Google-Smtp-Source: AMsMyM6u+npbUFj1zuoLf+Uq5htTxySe5JVkgiMLmXliWwtBbLHi4DjboP+7+KPzLeq9bmt0RbQpQJgKyhyB085mR7I=
X-Received: by 2002:aa7:da03:0:b0:461:4fc2:3e0f with SMTP id
 r3-20020aa7da03000000b004614fc23e0fmr39084531eds.321.1667637987305; Sat, 05
 Nov 2022 01:46:27 -0700 (PDT)
MIME-Version: 1.0
From: MC 5760 <mocay5760@gmail.com>
Date: Sat, 5 Nov 2022 15:46:15 +0700
Message-ID: <CA+Ej=UZBNUoqYW7Rw1d1K=7JwiovuHg6YchQkcrE0_RhjT+Wbw@mail.gmail.com>
To: bitcoin-dev@lists.linuxfoundation.org
Content-Type: multipart/alternative; boundary="000000000000d8f01605ecb539df"
X-Mailman-Approved-At: Sat, 05 Nov 2022 14:26:39 +0000
Subject: [bitcoin-dev] Generate and verify ECDSA signature without "r"
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Nov 2022 08:46:30 -0000

--000000000000d8f01605ecb539df
Content-Type: text/plain; charset="UTF-8"

1. Address: private key -> ECC -> public key compression -> Bech32m encode

2. scriptPubkey: Address -> Bech32m decode -> public key compression

3. Segwit: (dsha256(txid_input & index) * x public key + dsha256(unsigned
raw transaction) mod (private key)) mod (N) => Will give a number of 32
bytes

4. Verify:

x1, y1 = ECC(G, dsha256(txid_input & index))

p1 = ECC(G, dsha256(unsigned raw transaction) mod (Segwit))

p2 = ECC((x1,y1) * x public key mod (Segwit)

x2, y2 = ECAddpoint(p1, p2)

If x2 = x public key => OK

I wrote the python code here:
https://github.com/tanvovan/bitcoin/blob/main/p2pc.py

--000000000000d8f01605ecb539df
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><p class=3D"MsoNormal" style=3D"line-height:normal;backgro=
und-image:initial;background-position:initial;background-size:initial;backg=
round-repeat:initial;background-origin:initial;background-clip:initial;marg=
in:0in 0in 8pt;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">1.
Address: private key -&gt; ECC -&gt; public key compression -&gt; Bech32m
encode</span></p>

<p class=3D"MsoNormal" style=3D"line-height:normal;background-image:initial=
;background-position:initial;background-size:initial;background-repeat:init=
ial;background-origin:initial;background-clip:initial;margin:0in 0in 8pt;fo=
nt-size:11pt;font-family:Calibri,sans-serif"><span style=3D"font-size:12pt;=
font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36,41,47)">2.
scriptPubkey: Address -&gt; Bech32m decode -&gt; public key compression</sp=
an></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;line-height:normal;backg=
round-image:initial;background-position:initial;background-size:initial;bac=
kground-repeat:initial;background-origin:initial;background-clip:initial;fo=
nt-size:11pt;font-family:Calibri,sans-serif"><span style=3D"font-size:12pt;=
font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36,41,47)">3.
Segwit: (dsha256(txid_input &amp; index) * x public key + dsha256(unsigned =
raw
transaction) mod (private key)) mod (N) =3D&gt; Will give a number of 32 by=
tes</span></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;line-height:normal;backg=
round-image:initial;background-position:initial;background-size:initial;bac=
kground-repeat:initial;background-origin:initial;background-clip:initial;fo=
nt-size:11pt;font-family:Calibri,sans-serif"><span style=3D"font-size:12pt;=
font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36,41,47)">4.
Verify:</span></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-=
height:normal;background-image:initial;background-position:initial;backgrou=
nd-size:initial;background-repeat:initial;background-origin:initial;backgro=
und-clip:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">x1, y1 =3D ECC(G, dsha256(txid_input &amp; index))</span></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-=
height:normal;background-image:initial;background-position:initial;backgrou=
nd-size:initial;background-repeat:initial;background-origin:initial;backgro=
und-clip:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">p1 =3D ECC(G, dsha256(unsigned raw transaction) mod (Segwit))</spa=
n></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-=
height:normal;background-image:initial;background-position:initial;backgrou=
nd-size:initial;background-repeat:initial;background-origin:initial;backgro=
und-clip:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">p2 =3D ECC((x1,y1) * x public key mod (Segwit)</span></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-=
height:normal;background-image:initial;background-position:initial;backgrou=
nd-size:initial;background-repeat:initial;background-origin:initial;backgro=
und-clip:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">x2, y2 =3D ECAddpoint(p1, p2)</span></p>

<p class=3D"MsoNormal" style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-=
height:normal;background-image:initial;background-position:initial;backgrou=
nd-size:initial;background-repeat:initial;background-origin:initial;backgro=
und-clip:initial;font-size:11pt;font-family:Calibri,sans-serif"><span style=
=3D"font-size:12pt;font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36=
,41,47)">If x2 =3D x public key =3D&gt; OK</span></p><p class=3D"MsoNormal"=
 style=3D"margin:3pt 0in 8pt;text-indent:0.25in;line-height:normal;backgrou=
nd-image:initial;background-position:initial;background-size:initial;backgr=
ound-repeat:initial;background-origin:initial;background-clip:initial;font-=
size:11pt;font-family:Calibri,sans-serif">I wrote the python code here: <a =
href=3D"https://github.com/tanvovan/bitcoin/blob/main/p2pc.py">https://gith=
ub.com/tanvovan/bitcoin/blob/main/p2pc.py</a><span style=3D"font-size:12pt;=
font-family:&quot;Segoe UI&quot;,sans-serif;color:rgb(36,41,47)"><br></span=
></p></div>

--000000000000d8f01605ecb539df--