ct_ref_3seed.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  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_py_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', args + [self.usr_rand_arg])
  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, key and password files for 128-, 192- and 256-bit seeds'
  195. networks = ('btc','btc_tn','ltc','ltc_tn')
  196. passthru_opts = ('coin','testnet')
  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. 'ltc': ('2B23 5E97 848A B961','AEC3 E774 0B21 0202'),
  205. },
  206. 'refaddrgen_segwit_1': {
  207. 'btc': ('9914 6D10 2307 F348','83C8 A6B6 ADA8 25B2'),
  208. 'ltc': ('CC09 A190 B7DF B7CD','0425 7893 C6F1 ECA3'),
  209. },
  210. 'refaddrgen_bech32_1': {
  211. 'btc': ('C529 D686 31AA ACD4','21D0 26AD 3A22 5465'),
  212. 'ltc': ('3DFB CFCC E180 DC9D','8C72 D5C2 07E0 5F7B'),
  213. },
  214. 'refaddrgen_compressed_1': {
  215. 'btc': ('95EB 8CC0 7B3B 7856','16E6 6170 154D 2202'),
  216. 'ltc': ('35D5 8ECA 9A42 46C3','15B3 5492 D3D3 6854'),
  217. },
  218. 'refkeyaddrgen_legacy_1': {
  219. 'btc': ('CF83 32FB 8A8B 08E2','1F67 B73A FF8C 5D15'),
  220. 'ltc': ('1896 A26C 7F14 2D01','FA0E CD4E ADAF DBF4'),
  221. },
  222. 'refkeyaddrgen_compressed_1': {
  223. 'btc': ('E43A FA46 5751 720A','FDEE 8E45 1C0A 02AD'),
  224. 'ltc': ('7603 2FE3 2145 FFAD','3FE0 5A8E 5FBE FF3E'),
  225. },
  226. 'refkeyaddrgen_segwit_1': {
  227. 'btc': ('C13B F717 D4E8 CF59','BB71 175C 5416 19D8'),
  228. 'ltc': ('054B 9794 55B4 5D82','DE85 3CF3 9636 FE2E'),
  229. },
  230. 'refkeyaddrgen_bech32_1': {
  231. 'btc': ('934F 1C33 6C06 B18C','A283 5BAB 7AF3 3EA4'),
  232. 'ltc': ('A6AD DF53 5968 7B6A','9572 43E0 A4DC 0B2E'),
  233. },
  234. 'refpasswdgen_1': 'EB29 DC4F 924B 289F',
  235. 'refpasswdgen_half_1':'D310 2593 B5D9 2E88',
  236. 'ref_b32passwdgen_1': '37B6 C218 2ABC 7508',
  237. 'ref_hexpasswdgen_1': '8E99 E696 84CE E7D5',
  238. 'ref_hexpasswdgen_half_1': '8E99 E696 84CE E7D5',
  239. 'ref_bip39_12_passwdgen_1': '834F CF45 0B33 8AF0',
  240. 'ref_bip39_18_passwdgen_1': '834F CF45 0B33 8AF0',
  241. 'ref_bip39_24_passwdgen_1': '834F CF45 0B33 8AF0',
  242. 'ref_hex2bip39_24_passwdgen_1': '91AF E735 A31D 72A0',
  243. 'refaddrgen_legacy_2': {
  244. 'btc': ('8C17 A5FA 0470 6E89','764C 66F9 7502 AAEA'),
  245. 'ltc': ('2B77 A009 D5D0 22AD','51D1 979D 0A35 F24B'),
  246. },
  247. 'refaddrgen_compressed_2': {
  248. 'btc': ('2615 8401 2E98 7ECA','A386 EE07 A356 906D'),
  249. 'ltc': ('197C C48C 3C37 AB0F','8DDC 5FE3 BFF9 1226'),
  250. },
  251. 'refaddrgen_segwit_2': {
  252. 'btc': ('91C4 0414 89E4 2089','BF9F C67F ED22 A47B'),
  253. 'ltc': ('8F12 FA7B 9F12 594C','2609 8494 A23C F836'),
  254. },
  255. 'refaddrgen_bech32_2': {
  256. 'btc': ('2AA3 78DF B965 82EB','027B 1C1F 7FB2 D859'),
  257. 'ltc': ('951C 8FB2 FCA5 87D1','4A5D 67E0 8210 FEF2'),
  258. },
  259. 'refkeyaddrgen_legacy_2': {
  260. 'btc': ('9648 5132 B98E 3AD9','1BD3 5A36 D51C 256D'),
  261. 'ltc': ('DBD4 FAB6 7E46 CD07','8822 3FDF FEC0 6A8C'),
  262. },
  263. 'refkeyaddrgen_compressed_2': {
  264. 'btc': ('6D6D 3D35 04FD B9C3','94BF 4BCF 10B2 394B'),
  265. 'ltc': ('F5DA 9D60 6798 C4E9','7918 88DE 9096 DD7A'),
  266. },
  267. 'refkeyaddrgen_segwit_2': {
  268. 'btc': ('C98B DF08 A3D5 204B','7E7F DF50 FE04 6F68'),
  269. 'ltc': ('1829 7FE7 2567 CB91','BE92 D19C 7589 EF30'),
  270. },
  271. 'refkeyaddrgen_bech32_2': {
  272. 'btc': ('4A6B 3762 DF30 9368','12DD 1888 36BA 85F7'),
  273. 'ltc': ('5C12 FDD4 17AB F179','E195 B28C 59C4 C5EC'),
  274. },
  275. 'refpasswdgen_2': 'ADEA 0083 094D 489A',
  276. 'refpasswdgen_half_2':'12B3 4929 9506 76E0',
  277. 'ref_b32passwdgen_2': '2A28 C5C7 36EC 217A',
  278. 'ref_hexpasswdgen_2': '88F9 0D48 3A7E 7CC2',
  279. 'ref_hexpasswdgen_half_2': '59F3 8F48 861E 1186',
  280. 'ref_bip39_12_passwdgen_2': 'D32D B8D7 A840 250B',
  281. 'ref_bip39_18_passwdgen_2': '0FAA 78DD A6BA 31AD',
  282. 'ref_bip39_24_passwdgen_2': '0FAA 78DD A6BA 31AD',
  283. 'ref_hex2bip39_24_passwdgen_2': '0E8E 23C9 923F 7C2D',
  284. 'refaddrgen_legacy_3': {
  285. 'btc': ('6FEF 6FB9 7B13 5D91','424E 4326 CFFE 5F51'),
  286. 'ltc': ('AD52 C3FE 8924 AAF0','4EBE 2E85 E969 1B30'),
  287. },
  288. 'refaddrgen_compressed_3': {
  289. 'btc': ('A33C 4FDE F515 F5BC','6C48 AA57 2056 C8C8'),
  290. 'ltc': ('3FC0 8F03 C2D6 BD19','4C0A 49B6 2DD1 1BE0'),
  291. },
  292. 'refaddrgen_segwit_3': {
  293. 'btc': ('06C1 9C87 F25C 4EE6','072C 8B07 2730 CB7A'),
  294. 'ltc': ('63DF E42A 0827 21C3','5DD1 D186 DBE1 59F2'),
  295. },
  296. 'refaddrgen_bech32_3': {
  297. 'btc': ('9D2A D4B6 5117 F02E','0527 9C39 6C1B E39A'),
  298. 'ltc': ('FF1C 7939 5967 AB82','ED3D 8AA4 BED4 0B40'),
  299. },
  300. 'refkeyaddrgen_legacy_3': {
  301. 'btc': ('9F2D D781 1812 8BAD','88CC 5120 9A91 22C2'),
  302. 'ltc': ('B804 978A 8796 3ED4','98B5 AC35 F334 0398'),
  303. },
  304. 'refkeyaddrgen_compressed_3': {
  305. 'btc': ('420A 8EB5 A9E2 7814','F43A CB4A 81F3 F735'),
  306. 'ltc': ('8D1C 781F EB7F 44BC','05F3 5C68 FD31 FCEF'),
  307. },
  308. 'refkeyaddrgen_segwit_3': {
  309. 'btc': ('A447 12C2 DD14 5A9B','C770 7391 C415 21F9'),
  310. 'ltc': ('E8A3 9F6E E164 A521','D3D5 BFDD F5D5 20BD'),
  311. },
  312. 'refkeyaddrgen_bech32_3': {
  313. 'btc': ('D0DD BDE3 87BE 15AE','7552 D70C AAB8 DEAA'),
  314. 'ltc': ('74A0 7DD5 963B 6326','2CDA A007 4B9F E9A5'),
  315. },
  316. 'refpasswdgen_3': '2D6D 8FBA 422E 1315',
  317. 'refpasswdgen_half_3':'272C B770 0176 D7EA',
  318. 'ref_b32passwdgen_3': 'F6C1 CDFB 97D9 FCAE',
  319. 'ref_hexpasswdgen_3': 'BD4F A0AC 8628 4BE4',
  320. 'ref_hexpasswdgen_half_3': 'FBDD F733 FFB9 21C1',
  321. 'ref_bip39_12_passwdgen_3': 'A86E EA14 974A 1B0E',
  322. 'ref_bip39_18_passwdgen_3': 'EF87 9904 88E2 5884',
  323. 'ref_bip39_24_passwdgen_3': 'EBE8 2A8F 8F8C 7DBD',
  324. 'ref_hex2bip39_24_passwdgen_3': '93FA 5EFD 33F3 760E',
  325. 'ref_xmrseed_25_passwdgen_3': '91AE E76A 2827 C8CC',
  326. }
  327. cmd_group = (
  328. ('ref_walletgen_brain', ([],'generating new reference wallet + filename check (brain)')),
  329. ('refaddrgen_legacy', ([],'new refwallet addr chksum (uncompressed)')),
  330. ('refaddrgen_compressed', ([],'new refwallet addr chksum (compressed)')),
  331. ('refaddrgen_segwit', ([],'new refwallet addr chksum (segwit)')),
  332. ('refaddrgen_bech32', ([],'new refwallet addr chksum (bech32)')),
  333. ('refkeyaddrgen_legacy', ([],'new refwallet key-addr chksum (uncompressed)')),
  334. ('refkeyaddrgen_compressed', ([],'new refwallet key-addr chksum (compressed)')),
  335. ('refkeyaddrgen_segwit', ([],'new refwallet key-addr chksum (segwit)')),
  336. ('refkeyaddrgen_bech32', ([],'new refwallet key-addr chksum (bech32)')),
  337. ('refpasswdgen', ([],'new refwallet passwd file chksum')),
  338. ('refpasswdgen_half', ([],'new refwallet passwd file chksum (half-length)')),
  339. ('ref_b32passwdgen', ([],'new refwallet passwd file chksum (base32)')),
  340. ('ref_hexpasswdgen', ([],'new refwallet passwd file chksum (hex)')),
  341. ('ref_hexpasswdgen_half', ([],'new refwallet passwd file chksum (hex, half-length)')),
  342. ('ref_bip39_12_passwdgen', ([],'new refwallet passwd file chksum (BIP39, 12 words)')),
  343. ('ref_bip39_18_passwdgen', ([],'new refwallet passwd file chksum (BIP39, up to 18 words)')),
  344. ('ref_bip39_24_passwdgen', ([],'new refwallet passwd file chksum (BIP39, up to 24 words)')),
  345. ('ref_xmrseed_25_passwdgen', ([],'new refwallet passwd file chksum (Monero 25-word mnemonic)')),
  346. ('ref_hex2bip39_24_passwdgen',([],'new refwallet passwd file chksum (hex-to-BIP39, up to 24 words)')),
  347. )
  348. def call_addrgen(self,mmtype,pfx='addr'):
  349. wf = self.get_file_with_ext('mmdat')
  350. return getattr(self,pfx+'gen')(wf,check_ref=True,mmtype=mmtype)
  351. def refaddrgen_legacy(self):
  352. return self.call_addrgen('legacy')
  353. def refaddrgen_compressed(self):
  354. return self.call_addrgen('compressed')
  355. def refaddrgen_segwit(self):
  356. return self.call_addrgen('segwit')
  357. def refaddrgen_bech32(self):
  358. return self.call_addrgen('bech32')
  359. def refkeyaddrgen_legacy(self):
  360. return self.call_addrgen('legacy','keyaddr')
  361. def refkeyaddrgen_compressed(self):
  362. return self.call_addrgen('compressed','keyaddr')
  363. def refkeyaddrgen_segwit(self):
  364. return self.call_addrgen('segwit','keyaddr')
  365. def refkeyaddrgen_bech32(self):
  366. return self.call_addrgen('bech32','keyaddr')
  367. def pwgen(self,ftype,id_str,pwfmt=None,pwlen=None,extra_args=[],stdout=False):
  368. wf = self.get_file_with_ext('mmdat')
  369. pf = joinpath(self.tmpdir,pwfile)
  370. pwfmt = (['--passwd-fmt='+pwfmt] if pwfmt else [])
  371. pwlen = (['--passwd-len='+str(pwlen)] if pwlen else [])
  372. return self.addrgen(
  373. wf,
  374. check_ref = True,
  375. ftype = ftype,
  376. id_str = id_str,
  377. extra_args = pwfmt + pwlen + extra_args,
  378. stdout = stdout)
  379. def refpasswdgen(self):
  380. return self.pwgen('pass','alice@crypto.org')
  381. def refpasswdgen_half(self):
  382. return self.pwgen('pass','alice@crypto.org',pwlen='h')
  383. def ref_b32passwdgen(self):
  384. return self.pwgen('pass32','фубар@crypto.org','b32',17)
  385. def ref_hexpasswdgen(self):
  386. pwlen = {'1':32,'2':48,'3':64}[self.test_name[-1]]
  387. return self.pwgen('passhex','фубар@crypto.org','hex',pwlen)
  388. def ref_hexpasswdgen_half(self):
  389. ea = ['--accept-defaults']
  390. return self.pwgen('passhex','фубар@crypto.org','hex','h',ea,stdout=True)
  391. def mn_pwgen(self,req_pw_len,pwfmt,ftype='passbip39',stdout=False):
  392. pwlen = min(req_pw_len,{'1':12,'2':18,'3':24}[self.test_name[-1]])
  393. if pwfmt == 'xmrseed':
  394. if cfg.no_altcoin:
  395. return 'skip'
  396. pwlen += 1
  397. ea = ['--accept-defaults']
  398. return self.pwgen(ftype,'фубар@crypto.org',pwfmt,pwlen,ea,stdout=stdout)
  399. def ref_bip39_12_passwdgen(self):
  400. return self.mn_pwgen(12,'bip39',stdout=True)
  401. def ref_bip39_18_passwdgen(self):
  402. return self.mn_pwgen(18,'bip39',stdout=True)
  403. def ref_bip39_24_passwdgen(self):
  404. return self.mn_pwgen(24,'bip39')
  405. def ref_hex2bip39_24_passwdgen(self):
  406. return self.mn_pwgen(24,'hex2bip39')
  407. def ref_xmrseed_25_passwdgen(self):
  408. return self.mn_pwgen(24,'xmrseed',ftype='passxmrseed')