-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtcls_tc_verify.sh
343 lines (292 loc) · 21.7 KB
/
tcls_tc_verify.sh
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/sh
# some testcases for the shell script "tx_verify_sig.sh"
#
# Copyright (c) 2015, 2016 Volker Nowarra
# initial release in Nov 2016
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
# USE OR PERFORMANCE OF THIS SOFTWARE.
#
typeset -i LOG=0
logfile=$0.log
chksum_verify() {
if [ "$1" == "$2" ] ; then
echo "ok"
else
echo $1 | tee -a $logfile
echo "*************** checksum mismatch, ref is: ********************" | tee -a $logfile
echo $2 | tee -a $logfile
echo " " | tee -a $logfile
fi
}
to_logfile() {
# echo $chksum_ref >> $logfile
cat tmp_tx_cfile >> $logfile
echo " " >> $logfile
}
chksum_prep() {
result=$( $chksum_cmd tmp_tx_cfile | cut -d " " -f 2 )
# echo $result | cut -d " " -f 2 >> $logfile
chksum_verify "$result" "$chksum_ref"
if [ $LOG -eq 1 ] ; then to_logfile ; fi
}
testcase1() {
# first get the checksums of all necessary files
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 1: get the checksums of all necessary files ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 1a: $chksum_cmd tcls_verify_sig.sh" | tee -a $logfile
cp tcls_verify_sig.sh tmp_tx_cfile
chksum_ref="da5e0fd5e6437b112d7f30ce403fe89762ae2da911cb0cbfa7929c80522767a1"
chksum_prep
echo "=== TESTCASE 1b: $chksum_cmd tcls_key2pem.sh" | tee -a $logfile
cp tcls_key2pem.sh tmp_tx_cfile
chksum_ref="0d576b68fb56e9cb65af51b31aa84d18cd7de896618f505afeedf05974ce20eb"
chksum_prep
echo "=== TESTCASE 1c: $chksum_cmd tcls_strict_sig_verify.sh" | tee -a $logfile
cp tcls_strict_sig_verify.sh tmp_tx_cfile
chksum_ref="a507c6f7fa2d6dd8c83fdc73e02e19115a3870afd9f67bf955e7374676997352"
chksum_prep
echo "=== TESTCASE 1d: $chksum_cmd tcls_verify_hexkey.awk" | tee -a $logfile
cp tcls_verify_hexkey.awk tmp_tx_cfile
chksum_ref="055b79074a8f33d0aa9aa7634980d29f4e3eb0248a730ea784c7a88e64aa7cfd"
chksum_prep
echo " " | tee -a $logfile
}
testcase2() {
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 2: parameters testing ... ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 2a: -d param too short... " | tee -a $logfile
echo "./tcls_verify_sig.sh -v -d 0123456789abcdef -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e" >> $logfile
./tcls_verify_sig.sh -v -d 0123456789abcdef -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e > tmp_tx_cfile
chksum_ref="0895db88502710dd7e1aa02f7042e3cdfc55cb9f9f260898da29e8dfa819613f"
chksum_prep
echo "=== TESTCASE 2b: -p param too short... " | tee -a $logfile
echo "./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 0123456789abcdef -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e" >> $logfile
./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 0123456789abcdef -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e > tmp_tx_cfile
chksum_ref="d39e403b67f013969bab2d50ebf2a0d6804084cb6318d769f249a412512c8be5"
chksum_prep
echo "=== TESTCASE 2c: -s param too short... " | tee -a $logfile
echo "./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221000123456789abcdef" >> $logfile
./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221000123456789abcdef > tmp_tx_cfile
chksum_ref="0e411e0df79fa23e4c504b112bcc0353b8f81dbcc95439459bed91daf5d4726b"
chksum_prep
echo " " | tee -a $logfile
}
testcase3() {
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 3: the pizza transaction ... ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 3a: pizza, quiet operation..." | tee -a $logfile
echo "http://bitcoin.stackexchange.com/questions/32305/how-does-the-ecdsa-verification-algorithm-work-during-transaction/32308#32308" >> $logfile
echo "./tcls_verify_sig.sh -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e" >> $logfile
./tcls_verify_sig.sh -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "=== TESTCASE 3b: pizza, be a bit more verbose..." | tee -a $logfile
echo "./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e" >> $logfile
./tcls_verify_sig.sh -v -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e > tmp_tx_cfile
chksum_ref="4bd3a7543bd8fa3ffd88f639fc568f1f073afc44ceff3beeb301a0e6617b4a80"
chksum_prep
echo "=== TESTCASE 3c: pizza, be very verbose..." | tee -a $logfile
echo "./tcls_verify_sig.sh -vv -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e" >> $logfile
./tcls_verify_sig.sh -vv -d c2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669 -p 042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb -s 30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e > tmp_tx_cfile
chksum_ref="3e19c7c9f511f367d138195d780cfbbf92fecc66e166919dc5413253c92667d2"
chksum_prep
echo " " | tee -a $logfile
}
testcase4() {
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 4: use quiet mode to check 4 sigs ... ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 4a: ./tcls_verify_sig.sh -p p1 -s sig1 -d d1 " | tee -a $logfile
echo "./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 304502210086199572c8e5879fa610bd244c7b2d054c389ed8b023f0a3d11f25606773e3f5022037086414c32a875fc2d43ec30664edbce447836e25f68ec39a3d04fd03590b57 -d 6f13d86405f2672b98d52e9d5244e133244885c4ce0d4f9087da9433a09f914f" >> $logfile
./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 304502210086199572c8e5879fa610bd244c7b2d054c389ed8b023f0a3d11f25606773e3f5022037086414c32a875fc2d43ec30664edbce447836e25f68ec39a3d04fd03590b57 -d 6f13d86405f2672b98d52e9d5244e133244885c4ce0d4f9087da9433a09f914f > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "=== TESTCASE 4b: ./tcls_verify_sig.sh -p p2 -s sig2 -d d2 " | tee -a $logfile
echo "./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 3044022069f4f02bd808eb5381a8bc5b6e3a18219089f83b10b25277345439c52dfb42e30220107a09ad1aff0e20fd5c07b71d536943d72ca15c6e86f77282fe75478a64a466 -d e09e861272e2377a4528fbe28d1ee764706ca4b829aad7e08f4a0325e25c9053" >> $logfile
./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 3044022069f4f02bd808eb5381a8bc5b6e3a18219089f83b10b25277345439c52dfb42e30220107a09ad1aff0e20fd5c07b71d536943d72ca15c6e86f77282fe75478a64a466 -d e09e861272e2377a4528fbe28d1ee764706ca4b829aad7e08f4a0325e25c9053 > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "=== TESTCASE 4c: ./tcls_verify_sig.sh -p p3 -s sig3 -d d3 " | tee -a $logfile
echo "./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 3044022058c884db944e2265f013493d98a56c958a86aeacc6655473a8cf477fac31f375022026b5915ed26e0149effac955ac30ba90ca25919072ab5a20a161575a55a8bc30 -d c5bfe4a6c58fb2e0398006b4109cdea737eb1413a127c5e61039a8858367750b" >> $logfile
./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 3044022058c884db944e2265f013493d98a56c958a86aeacc6655473a8cf477fac31f375022026b5915ed26e0149effac955ac30ba90ca25919072ab5a20a161575a55a8bc30 -d c5bfe4a6c58fb2e0398006b4109cdea737eb1413a127c5e61039a8858367750b > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "=== TESTCASE 4d: ./tcls_verify_sig.sh -p p4 -s sig4 -d d4 " | tee -a $logfile
echo "./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 304402202adca291dd1c4058f124c01218e6d34e5a968de6fb932a4237fd33c5aa26930a0220493502e86bf6684593d5ea888f112503ed7ae054a1f4fa62d38df76898a6731e -d 64623a854acfc3e9ba5761a1209af9f3162d360b4eaff7f5c2d19010fa30f418" >> $logfile
./tcls_verify_sig.sh -p 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 -s 304402202adca291dd1c4058f124c01218e6d34e5a968de6fb932a4237fd33c5aa26930a0220493502e86bf6684593d5ea888f112503ed7ae054a1f4fa62d38df76898a6731e -d 64623a854acfc3e9ba5761a1209af9f3162d360b4eaff7f5c2d19010fa30f418 > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "######################################################" | tee -a $logfile
echo "### we cross check with openssl directly ###" | tee -a $logfile
echo "### openssl pkeyutl <tx_hash.hex -verify -pubin ###" | tee -a $logfile
echo "### -inkey pubkey.pem -sigfile tx_sig.hex ###" | tee -a $logfile
echo "######################################################" | tee -a $logfile
# The pubkey is: 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0
printf 3036301006072a8648ce3d020106052b8104000a032200 > pubkey.txt
printf 03cc5debc62369bd861900b167bc6add5f1a6249bdab4146d5ce698879988dced0 >> pubkey.txt
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <pubkey.txt) | openssl pkey -pubin -inform der >pubkey.pem
echo "=== TESTCASE 4a: openssl pkeyutl ... " | tee -a $logfile
echo "TX_IN[0]:" >> $logfile
echo 6f13d86405f2672b98d52e9d5244e133244885c4ce0d4f9087da9433a09f914f > tx_hash.txt
echo 304502210086199572c8e5879fa610bd244c7b2d054c389ed8b023f0a3d11f25606773e3f5022037086414c32a875fc2d43ec30664edbce447836e25f68ec39a3d04fd03590b57 > tx_sig.txt
# xxd -r -p <tx_hash.txt >tx_hash.hex
# xxd -r -p <tx_sig.txt >tx_sig.hex
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_hash.txt) >tx_hash.hex
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_sig.txt) >tx_sig.hex
openssl pkeyutl <tx_hash.hex -verify -pubin -inkey pubkey.pem -sigfile tx_sig.hex | tee -a $logfile
echo "=== TESTCASE 4b: openssl pkeyutl ... " | tee -a $logfile
echo e09e861272e2377a4528fbe28d1ee764706ca4b829aad7e08f4a0325e25c9053 > tx_hash.txt
echo 3044022069f4f02bd808eb5381a8bc5b6e3a18219089f83b10b25277345439c52dfb42e30220107a09ad1aff0e20fd5c07b71d536943d72ca15c6e86f77282fe75478a64a466 > tx_sig.txt
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_hash.txt) >tx_hash.hex
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_sig.txt) >tx_sig.hex
openssl pkeyutl <tx_hash.hex -verify -pubin -inkey pubkey.pem -sigfile tx_sig.hex | tee -a $logfile
echo "=== TESTCASE 4c: openssl pkeyutl ... " | tee -a $logfile
echo c5bfe4a6c58fb2e0398006b4109cdea737eb1413a127c5e61039a8858367750b > tx_hash.txt
echo 3044022058c884db944e2265f013493d98a56c958a86aeacc6655473a8cf477fac31f375022026b5915ed26e0149effac955ac30ba90ca25919072ab5a20a161575a55a8bc30 > tx_sig.txt
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_hash.txt) >tx_hash.hex
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_sig.txt) >tx_sig.hex
openssl pkeyutl <tx_hash.hex -verify -pubin -inkey pubkey.pem -sigfile tx_sig.hex | tee -a $logfile
echo "=== TESTCASE 4d: openssl pkeyutl ... " | tee -a $logfile
echo 64623a854acfc3e9ba5761a1209af9f3162d360b4eaff7f5c2d19010fa30f418 > tx_hash.txt
echo 304402202adca291dd1c4058f124c01218e6d34e5a968de6fb932a4237fd33c5aa26930a0220493502e86bf6684593d5ea888f112503ed7ae054a1f4fa62d38df76898a6731e > tx_sig.txt
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_hash.txt) >tx_hash.hex
printf $(sed 's/[[:xdigit:]]\{2\}/\\x&/g' <tx_sig.txt) >tx_sig.hex
openssl pkeyutl <tx_hash.hex -verify -pubin -inkey pubkey.pem -sigfile tx_sig.hex | tee -a $logfile
echo " " | tee -a $logfile
}
testcase5() {
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 5: strictly testing signatures... ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 5a: R and S-Value of signature <= N/2 ... " | tee -a $logfile
echo "./tcls_strict_sig_verify.sh -v 30440220443ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902205aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501" >> $logfile
./tcls_strict_sig_verify.sh -v 30440220443ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902205aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501 > tmp_tx_cfile
chksum_ref="5b40890a5590e3e5b54e2cce637e2a3788b8354469101254cec2e5d21fc266d7"
chksum_prep
echo "=== TESTCASE 5b: R and S-Value are zero padded ... " | tee -a $logfile
echo "./tcls_strict_sig_verify.sh -v 304602210090c4fc2369cf225559c1141a1e9be3d7598f0fb7affe8a29f86e737972c7587a022100cbd8619ecae3baa40fdb565014fdac28a95deb90c0fcd4adcbd97d58d0e96f98" >> $logfile
./tcls_strict_sig_verify.sh -v 304602210090c4fc2369cf225559c1141a1e9be3d7598f0fb7affe8a29f86e737972c7587a022100cbd8619ecae3baa40fdb565014fdac28a95deb90c0fcd4adcbd97d58d0e96f98> tmp_tx_cfile
chksum_ref="6f6056fa6fbe6cc389cd3e28351c95b14fc05eb60e88475ae9b75f20dbd48efa"
chksum_prep
echo "=== TESTCASE 5c - error: R-Value of signature >= N/2 ... " | tee -a $logfile
echo "./tcls_strict_sig_verify.sh -v 30440220843ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902205aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501" >> $logfile
./tcls_strict_sig_verify.sh -v 30440220843ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902205aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501 > tmp_tx_cfile
chksum_ref="e2236c7ea3ffc39015417fc40d3cd6957111f38fe08f088dad2f2e4045ee5442"
chksum_prep
echo "=== TESTCASE 5d - error: S-Value of signature >= N/2 ... " | tee -a $logfile
echo "./tcls_strict_sig_verify.sh -v 30440220443ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902208aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501" >> $logfile
./tcls_strict_sig_verify.sh -v 30440220443ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902208aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501 > tmp_tx_cfile
chksum_ref="280da6542732fd4d76b81b098ced5f5e4504d5b60599a84bfc6e18b745b93c38"
chksum_prep
echo "=== TESTCASE 5e - error: R and S-Value of signature >= N/2 ... " | tee -a $logfile
echo "./tcls_strict_sig_verify.sh -v 30440220843ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902208aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501" >> $logfile
./tcls_strict_sig_verify.sh -v 30440220843ad3e0b7a1ee2e7b2341ef0e9f35664d5a664aefb622f2c686ca4836a2d48902208aef0722370bfe315758f4a6b9c656b07471e33d1b30c7c224e07228c701114501 > tmp_tx_cfile
chksum_ref="e123adb190118565c39149e6bf77710791bb5fa9715297a70eb1e1534044ddf0"
chksum_prep
echo " " | tee -a $logfile
}
testcase6() {
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 6: some random sig checks... ===" | tee -a $logfile
echo "================================================================" | tee -a $logfile
echo "=== TESTCASE 6a: example from bitcoin.SE:" | tee -a $logfile
echo "https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required?rq=1" >> $logfile
echo "./tcls_verify_sig.sh -d 30f10a6468b7d98257af63fb40dfcf2cefe991346fd37c67cf7b51ff8d4404d3 -p 042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9 -s 3045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e" >> $logfile
./tcls_verify_sig.sh -d 30f10a6468b7d98257af63fb40dfcf2cefe991346fd37c67cf7b51ff8d4404d3 -p 042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9 -s 3045022100da43201760bda697222002f56266bf65023fef2094519e13077f777baed553b102205ce35d05eabda58cd50a67977a65706347cc25ef43153e309ff210a134722e9e > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
echo "=== TESTCASE 6b: example from bitcoin.SE:" | tee -a $logfile
echo "https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx?noredirect=1&lq=1" >> $logfile
echo "./tcls_verify_sig.sh -d 9302bda273a887cb40c13e02a50b4071a31fd3aae3ae04021b0b843dd61ad18e -s 30460221009e0339f72c793a89e664a8a932df073962a3f84eda0bd9e02084a6a9567f75aa022100bd9cbaca2e5ec195751efdfac164b76250b1e21302e51ca86dd7ebd7020cdc06 -p 0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6" >> $logfile
./tcls_verify_sig.sh -d 9302bda273a887cb40c13e02a50b4071a31fd3aae3ae04021b0b843dd61ad18e -s 30460221009e0339f72c793a89e664a8a932df073962a3f84eda0bd9e02084a6a9567f75aa022100bd9cbaca2e5ec195751efdfac164b76250b1e21302e51ca86dd7ebd7020cdc06 -p 0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6 > tmp_tx_cfile
chksum_ref="0bd65ea014d3210c1b9a7d7d5af78bc4e4b4384b4f3f7f5674e8d6447e4112c3"
chksum_prep
}
all_testcases() {
testcase1
testcase2
testcase3
testcase4
testcase5
testcase6
}
#####################
### here we start ###
#####################
logfile=$0.log
if [ -f "$logfile" ] ; then rm $logfile; fi
echo $date > $logfile
###################################################################
# verify our operating system, cause checksum commands differ ... #
###################################################################
OS=$(uname)
if [ OS="OpenBSD" ] ; then
chksum_cmd=sha256
fi
if [ OS="Linux" ] ; then
chksum_cmd="openssl sha256"
fi
if [ OS="Darwin" ] ; then
chksum_cmd="openssl dgst -sha256"
fi
################################
# command line params handling #
################################
if [ $# -eq 0 ] ; then
all_testcases
fi
if [ $# -eq 1 ] && [ "$1" == "-l" ] ; then
LOG=1
shift
all_testcases
fi
while [ $# -ge 1 ]
do
case "$1" in
-h)
echo "usage: $0 -h|-l [1-9]"
echo " "
echo "script does several testcases, mostly with checksums for verification"
echo " "
exit 0
;;
-l)
LOG=1
shift
;;
1|2|3|4|5|6)
testcase$1
shift
;;
*)
echo "unknown parameter(s), try -h, exiting gracefully ..."
exit 0
;;
esac
done
# clean up
for i in tmp*; do
if [ -f "$i" ]; then rm $i ; fi
done
for i in *hex; do
if [ -f "$i" ]; then rm $i ; fi
done
for i in p*; do
if [ -f "$i" ]; then rm $i ; fi
done
for i in tx*; do
if [ -f "$i" ]; then rm $i ; fi
done