ct_ref_3seed.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. test.cmdtest_d.ct_ref_3seed: Saved and generated reference file tests for 128,
  20. 192 and 256-bit seeds for the cmdtest.py test suite
  21. """
  22. import os
  23. from mmgen.util import msg, capfirst
  24. from mmgen.wallet import get_wallet_cls
  25. from ..include.common import cfg, cmp_or_die, joinpath
  26. from .common import (
  27. pwfile,
  28. ref_wallet_hash_preset,
  29. ref_wallet_brainpass,
  30. ref_wallet_incog_offset,
  31. ref_dir,
  32. ok_msg
  33. )
  34. from .ct_base import CmdTestBase
  35. from .ct_shared import CmdTestShared
  36. from .ct_wallet import CmdTestWalletConv
  37. class CmdTestRef3Seed(CmdTestBase, CmdTestShared):
  38. 'saved wallet files for 128-, 192- and 256-bit seeds + generated filename checks'
  39. networks = ('btc',)
  40. mmtypes = (None,)
  41. tmpdir_nums = [6, 7, 8]
  42. addr_idx_list_in = '1010,500-501,31-33,1,33,500,1011'
  43. pass_idx_list_in = '1,4,9-11,1100'
  44. chk_data = {
  45. 'lens': (128, 192, 256),
  46. 'sids': ('FE3C6545', '1378FC64', '98831F3A'),
  47. }
  48. shared_deps = ['mmdat', pwfile]
  49. skip_cmds = (
  50. 'ref_xmrseed_25_passwdgen_1',
  51. 'ref_xmrseed_25_passwdgen_2',
  52. )
  53. cmd_group = (
  54. # reading saved reference wallets
  55. ('ref_wallet_chk', ([], 'saved reference wallet')),
  56. ('ref_seed_chk', ([], 'saved seed file')),
  57. ('ref_hex_chk', ([], 'saved mmhex file')),
  58. ('ref_plainhex_chk', ([], 'saved hex file')),
  59. ('ref_dieroll_chk', ([], 'saved dieroll (b6d) file')),
  60. ('ref_mn_chk', ([], 'saved native MMGen mnemonic file')),
  61. ('ref_bip39_chk', ([], 'saved BIP39 mnemonic file')),
  62. ('ref_hincog_chk', ([], 'saved hidden incog reference wallet')),
  63. ('ref_brain_chk', ([], 'saved brainwallet')), # in ct_shared
  64. # generating new reference ('abc' brainwallet) wallets for filename checks:
  65. ('ref_walletgen_brain', ([], 'generating new reference wallet + filename check (brain)')),
  66. ('ref_walletconv_words', ([], 'wallet filename (native mnemonic)')),
  67. ('ref_walletconv_bip39', ([], 'wallet filename (bip39)')),
  68. ('ref_walletconv_seed', ([], 'wallet filename (seed)')),
  69. ('ref_walletconv_hexseed', ([], 'wallet filename (hex seed)')),
  70. ('ref_walletconv_plainhexseed', ([], 'wallet filename (plain hex seed)')),
  71. ('ref_walletconv_dieroll', ([], 'wallet filename (dieroll (b6d) seed)')),
  72. ('ref_walletconv_incog', ([], 'wallet filename (incog)')),
  73. ('ref_walletconv_hexincog', ([], 'wallet filename (hex incog)')),
  74. )
  75. def __init__(self, trunner, cfgs, spawn):
  76. for k, _ in self.cmd_group:
  77. for n in (1, 2, 3): # 128, 192, 256 bits
  78. setattr(self, f'{k}_{n}', getattr(self, k))
  79. if cfgs:
  80. for n in self.tmpdir_nums:
  81. cfgs[str(n)]['addr_idx_list'] = self.addr_idx_list_in
  82. cfgs[str(n)]['pass_idx_list'] = self.pass_idx_list_in
  83. CmdTestBase.__init__(self, trunner, cfgs, spawn)
  84. def ref_wallet_chk(self):
  85. wf = joinpath(ref_dir, CmdTestWalletConv.sources[str(self.seed_len)]['ref_wallet'])
  86. return self.walletchk(wf, sid=self.seed_id)
  87. def ref_ss_chk(self, ss_type):
  88. ss = get_wallet_cls(ss_type)
  89. return self.walletchk(
  90. wf = joinpath(ref_dir, f'{self.seed_id}.{ss.ext}'),
  91. wcls = ss,
  92. sid = self.seed_id)
  93. def ref_seed_chk(self):
  94. return self.ref_ss_chk('seed')
  95. def ref_hex_chk(self):
  96. return self.ref_ss_chk('mmhex')
  97. def ref_plainhex_chk(self):
  98. return self.ref_ss_chk('plainhex')
  99. def ref_dieroll_chk(self):
  100. return self.ref_ss_chk('dieroll')
  101. def ref_mn_chk(self):
  102. return self.ref_ss_chk('words')
  103. def ref_bip39_chk(self):
  104. return self.ref_ss_chk('bip39')
  105. def ref_hincog_chk(self, desc='hidden incognito data'):
  106. source = CmdTestWalletConv.sources[str(self.seed_len)]
  107. for wtype, edesc, of_arg in (
  108. ('hic_wallet', '', []),
  109. ('hic_wallet_old', '(old format)', ['-O'])):
  110. ic_arg = ['-H{},{}'.format(
  111. joinpath(ref_dir, source[wtype]),
  112. ref_wallet_incog_offset)
  113. ]
  114. slarg = [f'-l{self.seed_len} ']
  115. hparg = ['-p1']
  116. if wtype == 'hic_wallet_old' and cfg.profile:
  117. msg('')
  118. t = self.spawn('mmgen-walletchk',
  119. slarg + hparg + of_arg + ic_arg,
  120. extra_desc=edesc)
  121. t.passphrase(desc, self.wpasswd+'\n')
  122. if wtype == 'hic_wallet_old':
  123. t.expect('Is the Seed ID correct? (Y/n): ', '\n')
  124. chk = t.expect_getend('Seed ID: ')
  125. cmp_or_die(self.seed_id, chk)
  126. ok_msg()
  127. t.skip_ok = True
  128. return t
  129. def ref_walletgen_brain(self):
  130. sl_arg = f'-l{self.seed_len}'
  131. hp_arg = f'-p{ref_wallet_hash_preset}'
  132. label = f'ref. wallet (pw {ref_wallet_brainpass!r}, seed len {self.seed_len}) α'
  133. bf = 'ref.mmbrain'
  134. args = ['-d', self.tmpdir, hp_arg, sl_arg, '-ibw', '-L', label]
  135. self.write_to_tmpfile(bf, ref_wallet_brainpass)
  136. self.write_to_tmpfile(pwfile, self.wpasswd)
  137. t = self.spawn('mmgen-walletconv', self.testnet_opt + args + [self.usr_rand_arg], no_passthru_opts=True)
  138. t.license()
  139. t.expect('Enter brainwallet: ', ref_wallet_brainpass+'\n')
  140. ocls = get_wallet_cls('mmgen')
  141. t.passphrase_new('new '+ocls.desc, self.wpasswd)
  142. t.usr_rand(self.usr_rand_chars)
  143. fn = os.path.split(t.written_to_file(capfirst(ocls.desc)))[-1]
  144. import re
  145. idx = int(self.test_name[-1]) - 1
  146. pat = r'{}-[0-9A-F]{{8}}\[{},1\]{}.mmdat'.format(
  147. self.chk_data['sids'][idx],
  148. self.chk_data['lens'][idx],
  149. '-α' if cfg.debug_utf8 else '')
  150. assert re.match(pat, fn), f'{pat} != {fn}'
  151. sid = os.path.basename(fn.split('-')[0])
  152. cmp_or_die(sid, self.seed_id, desc='Seed ID')
  153. return t
  154. def ref_walletconv(self, ofmt, extra_args=[], re_pat=None):
  155. wf = self.get_file_with_ext('mmdat')
  156. pf = joinpath(self.tmpdir, pwfile)
  157. t = self.spawn('mmgen-walletconv', extra_args+['-d', 'test/trash', '-o', ofmt, '-P'+pf, wf])
  158. wcls = get_wallet_cls(fmt_code=ofmt)
  159. fn = os.path.split(t.written_to_file(capfirst(wcls.desc)))[-1]
  160. idx = int(self.test_name[-1]) - 1
  161. sid = self.chk_data['sids'][idx]
  162. slen = self.chk_data['lens'][idx]
  163. if re_pat:
  164. import re
  165. pat = re_pat.format(sid, slen)
  166. assert re.match(pat, fn), f'{pat} != {fn}'
  167. else:
  168. cmp_or_die('{}[{}]{}.{}'.format(
  169. sid,
  170. slen,
  171. '-α' if cfg.debug_utf8 else '',
  172. wcls.ext),
  173. fn)
  174. return t
  175. def ref_walletconv_words(self):
  176. return self.ref_walletconv(ofmt='mn')
  177. def ref_walletconv_bip39(self):
  178. return self.ref_walletconv(ofmt='bip39')
  179. def ref_walletconv_seed(self):
  180. return self.ref_walletconv(ofmt='mmseed')
  181. def ref_walletconv_hexseed(self):
  182. return self.ref_walletconv(ofmt='mmhex')
  183. def ref_walletconv_plainhexseed(self):
  184. return self.ref_walletconv(ofmt='hex')
  185. def ref_walletconv_dieroll(self):
  186. return self.ref_walletconv(ofmt='dieroll')
  187. def ref_walletconv_incog(self, ofmt='incog', ext='mmincog'):
  188. args = ['-r0', '-p1']
  189. pat = r'{}-[0-9A-F]{{8}}-[0-9A-F]{{8}}\[{},1\]' + ('-α' if cfg.debug_utf8 else '') + '.' + ext
  190. return self.ref_walletconv(ofmt=ofmt, extra_args=args, re_pat=pat)
  191. def ref_walletconv_hexincog(self):
  192. return self.ref_walletconv_incog(ofmt='incog_hex', ext='mmincox')
  193. class CmdTestRef3Addr(CmdTestRef3Seed):
  194. 'generated reference address and key-address files for 128-, 192- and 256-bit seeds'
  195. networks = ('btc', 'btc_tn', 'ltc', 'ltc_tn', 'bch', 'bch_tn')
  196. passthru_opts = ('coin', 'testnet', 'cashaddr')
  197. tmpdir_nums = [26, 27, 28]
  198. shared_deps = ['mmdat', pwfile]
  199. chk_data = {
  200. 'lens': (128, 192, 256),
  201. 'sids': ('FE3C6545', '1378FC64', '98831F3A'),
  202. 'refaddrgen_legacy_1': {
  203. 'btc': ('B230 7526 638F 38CB', 'A9DC 5A13 12CB 1317'),
  204. 'bch': ('026D AFE0 8C60 6CFF', 'B406 4937 D884 6E48'),
  205. 'ltc': ('2B23 5E97 848A B961', 'AEC3 E774 0B21 0202'),
  206. },
  207. 'refaddrgen_segwit_1': {
  208. 'btc': ('9914 6D10 2307 F348', '83C8 A6B6 ADA8 25B2'),
  209. 'ltc': ('CC09 A190 B7DF B7CD', '0425 7893 C6F1 ECA3'),
  210. },
  211. 'refaddrgen_bech32_1': {
  212. 'btc': ('C529 D686 31AA ACD4', '21D0 26AD 3A22 5465'),
  213. 'ltc': ('3DFB CFCC E180 DC9D', '8C72 D5C2 07E0 5F7B'),
  214. },
  215. 'refaddrgen_compressed_1': {
  216. 'btc': ('95EB 8CC0 7B3B 7856', '16E6 6170 154D 2202'),
  217. 'bch': ('C560 A343 CEAB 118E', '3F56 8DC5 0383 CD78'),
  218. 'ltc': ('35D5 8ECA 9A42 46C3', '15B3 5492 D3D3 6854'),
  219. },
  220. 'refkeyaddrgen_legacy_1': {
  221. 'btc': ('CF83 32FB 8A8B 08E2', '1F67 B73A FF8C 5D15'),
  222. 'bch': ('6909 4C64 119A 7681', '7E48 5071 5E41 D1AE'),
  223. 'ltc': ('1896 A26C 7F14 2D01', 'FA0E CD4E ADAF DBF4'),
  224. },
  225. 'refkeyaddrgen_compressed_1': {
  226. 'btc': ('E43A FA46 5751 720A', 'FDEE 8E45 1C0A 02AD'),
  227. 'bch': ('7068 9B37 8ABF 3E31', 'C688 29A5 BA4C 21B2'),
  228. 'ltc': ('7603 2FE3 2145 FFAD', '3FE0 5A8E 5FBE FF3E'),
  229. },
  230. 'refkeyaddrgen_segwit_1': {
  231. 'btc': ('C13B F717 D4E8 CF59', 'BB71 175C 5416 19D8'),
  232. 'ltc': ('054B 9794 55B4 5D82', 'DE85 3CF3 9636 FE2E'),
  233. },
  234. 'refkeyaddrgen_bech32_1': {
  235. 'btc': ('934F 1C33 6C06 B18C', 'A283 5BAB 7AF3 3EA4'),
  236. 'ltc': ('A6AD DF53 5968 7B6A', '9572 43E0 A4DC 0B2E'),
  237. },
  238. 'refaddrgen_legacy_2': {
  239. 'btc': ('8C17 A5FA 0470 6E89', '764C 66F9 7502 AAEA'),
  240. 'bch': ('8117 24B6 3FDA 6B40', 'E58C A8A4 C371 66AE'),
  241. 'ltc': ('2B77 A009 D5D0 22AD', '51D1 979D 0A35 F24B'),
  242. },
  243. 'refaddrgen_compressed_2': {
  244. 'btc': ('2615 8401 2E98 7ECA', 'A386 EE07 A356 906D'),
  245. 'bch': ('3364 0F9D 8355 2A53', '3451 F741 0A8A FA56'),
  246. 'ltc': ('197C C48C 3C37 AB0F', '8DDC 5FE3 BFF9 1226'),
  247. },
  248. 'refaddrgen_segwit_2': {
  249. 'btc': ('91C4 0414 89E4 2089', 'BF9F C67F ED22 A47B'),
  250. 'ltc': ('8F12 FA7B 9F12 594C', '2609 8494 A23C F836'),
  251. },
  252. 'refaddrgen_bech32_2': {
  253. 'btc': ('2AA3 78DF B965 82EB', '027B 1C1F 7FB2 D859'),
  254. 'ltc': ('951C 8FB2 FCA5 87D1', '4A5D 67E0 8210 FEF2'),
  255. },
  256. 'refkeyaddrgen_legacy_2': {
  257. 'btc': ('9648 5132 B98E 3AD9', '1BD3 5A36 D51C 256D'),
  258. 'bch': ('C4D8 7C36 DC77 F8C2', '953D 245C 8CFF AC72'),
  259. 'ltc': ('DBD4 FAB6 7E46 CD07', '8822 3FDF FEC0 6A8C'),
  260. },
  261. 'refkeyaddrgen_compressed_2': {
  262. 'btc': ('6D6D 3D35 04FD B9C3', '94BF 4BCF 10B2 394B'),
  263. 'bch': ('3E7F C369 2AB9 BD58', '0C99 14CD 5ADE 6782'),
  264. 'ltc': ('F5DA 9D60 6798 C4E9', '7918 88DE 9096 DD7A'),
  265. },
  266. 'refkeyaddrgen_segwit_2': {
  267. 'btc': ('C98B DF08 A3D5 204B', '7E7F DF50 FE04 6F68'),
  268. 'ltc': ('1829 7FE7 2567 CB91', 'BE92 D19C 7589 EF30'),
  269. },
  270. 'refkeyaddrgen_bech32_2': {
  271. 'btc': ('4A6B 3762 DF30 9368', '12DD 1888 36BA 85F7'),
  272. 'ltc': ('5C12 FDD4 17AB F179', 'E195 B28C 59C4 C5EC'),
  273. },
  274. 'refaddrgen_legacy_3': {
  275. 'btc': ('6FEF 6FB9 7B13 5D91', '424E 4326 CFFE 5F51'),
  276. 'bch': ('E580 43BB 0F96 AA93', '630E 174A 8DDE 1BCE'),
  277. 'ltc': ('AD52 C3FE 8924 AAF0', '4EBE 2E85 E969 1B30'),
  278. },
  279. 'refaddrgen_compressed_3': {
  280. 'btc': ('A33C 4FDE F515 F5BC', '6C48 AA57 2056 C8C8'),
  281. 'bch': ('E37B AF41 7997 A28C', '0D5D 9A58 D6E9 92EE'),
  282. 'ltc': ('3FC0 8F03 C2D6 BD19', '4C0A 49B6 2DD1 1BE0'),
  283. },
  284. 'refaddrgen_segwit_3': {
  285. 'btc': ('06C1 9C87 F25C 4EE6', '072C 8B07 2730 CB7A'),
  286. 'ltc': ('63DF E42A 0827 21C3', '5DD1 D186 DBE1 59F2'),
  287. },
  288. 'refaddrgen_bech32_3': {
  289. 'btc': ('9D2A D4B6 5117 F02E', '0527 9C39 6C1B E39A'),
  290. 'ltc': ('FF1C 7939 5967 AB82', 'ED3D 8AA4 BED4 0B40'),
  291. },
  292. 'refkeyaddrgen_legacy_3': {
  293. 'btc': ('9F2D D781 1812 8BAD', '88CC 5120 9A91 22C2'),
  294. 'bch': ('A0EE B039 48F4 24AE', 'B014 E0AB 5F87 EC64'),
  295. 'ltc': ('B804 978A 8796 3ED4', '98B5 AC35 F334 0398'),
  296. },
  297. 'refkeyaddrgen_compressed_3': {
  298. 'btc': ('420A 8EB5 A9E2 7814', 'F43A CB4A 81F3 F735'),
  299. 'bch': ('33E7 5C06 88CF 2792', '6E09 FF73 B7C8 00D4'),
  300. 'ltc': ('8D1C 781F EB7F 44BC', '05F3 5C68 FD31 FCEF'),
  301. },
  302. 'refkeyaddrgen_segwit_3': {
  303. 'btc': ('A447 12C2 DD14 5A9B', 'C770 7391 C415 21F9'),
  304. 'ltc': ('E8A3 9F6E E164 A521', 'D3D5 BFDD F5D5 20BD'),
  305. },
  306. 'refkeyaddrgen_bech32_3': {
  307. 'btc': ('D0DD BDE3 87BE 15AE', '7552 D70C AAB8 DEAA'),
  308. 'ltc': ('74A0 7DD5 963B 6326', '2CDA A007 4B9F E9A5'),
  309. },
  310. }
  311. cmd_group = (
  312. ('ref_walletgen_brain', ([], 'generating new reference wallet + filename check (brain)')),
  313. ('refaddrgen_legacy', ([], 'new refwallet addr chksum (uncompressed)')),
  314. ('refaddrgen_compressed', ([], 'new refwallet addr chksum (compressed)')),
  315. ('refaddrgen_segwit', ([], 'new refwallet addr chksum (segwit)')),
  316. ('refaddrgen_bech32', ([], 'new refwallet addr chksum (bech32)')),
  317. ('refkeyaddrgen_legacy', ([], 'new refwallet key-addr chksum (uncompressed)')),
  318. ('refkeyaddrgen_compressed', ([], 'new refwallet key-addr chksum (compressed)')),
  319. ('refkeyaddrgen_segwit', ([], 'new refwallet key-addr chksum (segwit)')),
  320. ('refkeyaddrgen_bech32', ([], 'new refwallet key-addr chksum (bech32)')),
  321. )
  322. def call_addrgen(self, mmtype, name='addrgen'):
  323. wf = self.get_file_with_ext('mmdat')
  324. return getattr(self, name)(wf, check_ref=True, mmtype=mmtype)
  325. def refaddrgen_legacy(self):
  326. return self.call_addrgen('legacy')
  327. def refaddrgen_compressed(self):
  328. return self.call_addrgen('compressed')
  329. def refaddrgen_segwit(self):
  330. if self.proto.cap('segwit'):
  331. return self.call_addrgen('segwit')
  332. return 'skip'
  333. def refaddrgen_bech32(self):
  334. if self.proto.cap('segwit'):
  335. return self.call_addrgen('bech32')
  336. return 'skip'
  337. def refkeyaddrgen_legacy(self):
  338. return self.call_addrgen('legacy', 'keyaddrgen')
  339. def refkeyaddrgen_compressed(self):
  340. return self.call_addrgen('compressed', 'keyaddrgen')
  341. def refkeyaddrgen_segwit(self):
  342. if self.proto.cap('segwit'):
  343. return self.call_addrgen('segwit', 'keyaddrgen')
  344. return 'skip'
  345. def refkeyaddrgen_bech32(self):
  346. if self.proto.cap('segwit'):
  347. return self.call_addrgen('bech32', 'keyaddrgen')
  348. return 'skip'
  349. class CmdTestRef3Passwd(CmdTestRef3Seed):
  350. 'generated reference password files for 128-, 192- and 256-bit seeds'
  351. tmpdir_nums = [26, 27, 28]
  352. shared_deps = ['mmdat', pwfile]
  353. chk_data = {
  354. 'lens': (128, 192, 256),
  355. 'sids': ('FE3C6545', '1378FC64', '98831F3A'),
  356. 'refpasswdgen_1': 'EB29 DC4F 924B 289F',
  357. 'refpasswdgen_half_1': 'D310 2593 B5D9 2E88',
  358. 'ref_b32passwdgen_1': '37B6 C218 2ABC 7508',
  359. 'ref_hexpasswdgen_1': '8E99 E696 84CE E7D5',
  360. 'ref_hexpasswdgen_half_1': '8E99 E696 84CE E7D5',
  361. 'ref_bip39_12_passwdgen_1': '834F CF45 0B33 8AF0',
  362. 'ref_bip39_18_passwdgen_1': '834F CF45 0B33 8AF0',
  363. 'ref_bip39_24_passwdgen_1': '834F CF45 0B33 8AF0',
  364. 'ref_hex2bip39_24_passwdgen_1': '91AF E735 A31D 72A0',
  365. 'refpasswdgen_2': 'ADEA 0083 094D 489A',
  366. 'refpasswdgen_half_2': '12B3 4929 9506 76E0',
  367. 'ref_b32passwdgen_2': '2A28 C5C7 36EC 217A',
  368. 'ref_hexpasswdgen_2': '88F9 0D48 3A7E 7CC2',
  369. 'ref_hexpasswdgen_half_2': '59F3 8F48 861E 1186',
  370. 'ref_bip39_12_passwdgen_2': 'D32D B8D7 A840 250B',
  371. 'ref_bip39_18_passwdgen_2': '0FAA 78DD A6BA 31AD',
  372. 'ref_bip39_24_passwdgen_2': '0FAA 78DD A6BA 31AD',
  373. 'ref_hex2bip39_24_passwdgen_2': '0E8E 23C9 923F 7C2D',
  374. 'refpasswdgen_3': '2D6D 8FBA 422E 1315',
  375. 'refpasswdgen_half_3': '272C B770 0176 D7EA',
  376. 'ref_b32passwdgen_3': 'F6C1 CDFB 97D9 FCAE',
  377. 'ref_hexpasswdgen_3': 'BD4F A0AC 8628 4BE4',
  378. 'ref_hexpasswdgen_half_3': 'FBDD F733 FFB9 21C1',
  379. 'ref_bip39_12_passwdgen_3': 'A86E EA14 974A 1B0E',
  380. 'ref_bip39_18_passwdgen_3': 'EF87 9904 88E2 5884',
  381. 'ref_bip39_24_passwdgen_3': 'EBE8 2A8F 8F8C 7DBD',
  382. 'ref_hex2bip39_24_passwdgen_3': '93FA 5EFD 33F3 760E',
  383. 'ref_xmrseed_25_passwdgen_3': '91AE E76A 2827 C8CC',
  384. }
  385. cmd_group = (
  386. ('ref_walletgen_brain', ([], 'generating new reference wallet + filename check (brain)')),
  387. ('refpasswdgen', ([], 'new refwallet passwd file chksum')),
  388. ('refpasswdgen_half', ([], 'new refwallet passwd file chksum (half-length)')),
  389. ('ref_b32passwdgen', ([], 'new refwallet passwd file chksum (base32)')),
  390. ('ref_hexpasswdgen', ([], 'new refwallet passwd file chksum (hex)')),
  391. ('ref_hexpasswdgen_half', ([], 'new refwallet passwd file chksum (hex, half-length)')),
  392. ('ref_bip39_12_passwdgen', ([], 'new refwallet passwd file chksum (BIP39, 12 words)')),
  393. ('ref_bip39_18_passwdgen', ([], 'new refwallet passwd file chksum (BIP39, up to 18 words)')),
  394. ('ref_bip39_24_passwdgen', ([], 'new refwallet passwd file chksum (BIP39, up to 24 words)')),
  395. ('ref_xmrseed_25_passwdgen', ([], 'new refwallet passwd file chksum (Monero 25-word mnemonic)')),
  396. ('ref_hex2bip39_24_passwdgen', ([], 'new refwallet passwd file chksum (hex-to-BIP39, up to 24 words)')),
  397. )
  398. def pwgen(self, ftype, id_str, pwfmt=None, pwlen=None, extra_opts=[], stdout=False):
  399. wf = self.get_file_with_ext('mmdat')
  400. pwfmt = ([f'--passwd-fmt={pwfmt}'] if pwfmt else [])
  401. pwlen = ([f'--passwd-len={pwlen}'] if pwlen else [])
  402. return self.addrgen(
  403. wf,
  404. check_ref = True,
  405. ftype = ftype,
  406. id_str = id_str,
  407. extra_opts = pwfmt + pwlen + extra_opts,
  408. stdout = stdout,
  409. no_passthru_opts = True)
  410. def refpasswdgen(self):
  411. return self.pwgen('pass', 'alice@crypto.org')
  412. def refpasswdgen_half(self):
  413. return self.pwgen('pass', 'alice@crypto.org', pwlen='h')
  414. def ref_b32passwdgen(self):
  415. return self.pwgen('pass32', 'фубар@crypto.org', 'b32', 17)
  416. def ref_hexpasswdgen(self):
  417. pwlen = {'1':32, '2':48, '3':64}[self.test_name[-1]]
  418. return self.pwgen('passhex', 'фубар@crypto.org', 'hex', pwlen)
  419. def ref_hexpasswdgen_half(self):
  420. return self.pwgen('passhex', 'фубар@crypto.org', 'hex', 'h', ['--accept-defaults'], stdout=True)
  421. def mn_pwgen(self, pwlen, pwfmt, ftype='passbip39'):
  422. if pwlen > {'1':12, '2':18, '3':24}[self.test_name[-1]]:
  423. return 'skip'
  424. if pwfmt == 'xmrseed':
  425. if cfg.no_altcoin:
  426. return 'skip'
  427. pwlen += 1
  428. return self.pwgen(ftype, 'фубар@crypto.org', pwfmt, pwlen, ['--accept-defaults'])
  429. def ref_bip39_12_passwdgen(self):
  430. return self.mn_pwgen(12, 'bip39')
  431. def ref_bip39_18_passwdgen(self):
  432. return self.mn_pwgen(18, 'bip39')
  433. def ref_bip39_24_passwdgen(self):
  434. return self.mn_pwgen(24, 'bip39')
  435. def ref_hex2bip39_24_passwdgen(self):
  436. return self.mn_pwgen(24, 'hex2bip39')
  437. def ref_xmrseed_25_passwdgen(self):
  438. return self.mn_pwgen(24, 'xmrseed', ftype='passxmrseed')