limited Monero mnemonic seed phrase ('xmrseed') support

- only 256-bit (25-word) new-style mnemonics are supported

Testing:

  $ test/unit_tests.py baseconv
  $ test/tooltest2.py hex2mn mn2hex
  $ test/scrambletest.py pw
  $ test/test.py ref_xmrseed_25_passwdgen_3
  $ test/test.py ref_passwdfile_chk_xmrseed_25

The following operations are supported:

  Generate a random Monero mnemonic:

  $ mmgen-tool mn_rand256 fmt=xmrseed

  Generate a Monero mnemonic from hexadecimal data:

  $ mmgen-tool hex2mn deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef fmt=xmrseed

  Convert the resulting mnemonic back to hexadecimal data:

  $ mmgen-tool mn2hex 'viewpoint donuts ardent template unveil agile meant unafraid urgent athlete rustled mime azure jaded hawk baby jagged haystack baby jagged haystack ramped oncoming point template' fmt=xmrseed

  Note that the result of the reversal does not match the original input.  This
  is because input data is reduced to a spendkey before conversion so that a
  canonical seed phrase is produced.  This is required because Monero seeds,
  unlike ordinary wallet seeds, are tied to a concrete key/address pair.  The
  spendkey can be generated directly using the `hex2wif` command:

  $ mmgen-tool --coin=xmr hex2wif deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef

  Generate a list of passwords in Monero mnemonic format with ID 'mymonero':

  $ mmgen-passgen -f xmrseed 'mymonero' 1-10
This commit is contained in:
The MMGen Project 2020-02-12 10:38:11 +00:00
commit cfa16418b3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
11 changed files with 1776 additions and 13 deletions

View file

@ -42,6 +42,10 @@ class TestSuiteRef3Seed(TestSuiteBase,TestSuiteShared):
'sids': ('FE3C6545', '1378FC64', '98831F3A'),
}
shared_deps = ['mmdat',pwfile]
skip_cmds = (
'ref_xmrseed_25_passwdgen_1',
'ref_xmrseed_25_passwdgen_2',
)
cmd_group = (
# reading saved reference wallets
('ref_wallet_chk', ([],'saved reference wallet')),
@ -319,6 +323,7 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed):
'ref_bip39_18_passwdgen_3': 'EF87 9904 88E2 5884',
'ref_bip39_24_passwdgen_3': 'EBE8 2A8F 8F8C 7DBD',
'ref_hex2bip39_24_passwdgen_3': '93FA 5EFD 33F3 760E',
'ref_xmrseed_25_passwdgen_3': '91AE E76A 2827 C8CC',
}
cmd_group = (
@ -339,6 +344,7 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed):
('ref_bip39_12_passwdgen', ([],'new refwallet passwd file chksum (BIP39, 12 words)')),
('ref_bip39_18_passwdgen', ([],'new refwallet passwd file chksum (BIP39, up to 18 words)')),
('ref_bip39_24_passwdgen', ([],'new refwallet passwd file chksum (BIP39, up to 24 words)')),
('ref_xmrseed_25_passwdgen', ([],'new refwallet passwd file chksum (Monero new-style mnemonic, 25 words)')),
('ref_hex2bip39_24_passwdgen',([],'new refwallet passwd file chksum (hex-to-BIP39, up to 24 words)')),
)
@ -383,6 +389,8 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed):
def mn_pwgen(self,req_pw_len,pwfmt,ftype='passbip39',stdout=False):
pwlen = min(req_pw_len,{'1':12,'2':18,'3':24}[self.test_name[-1]])
if pwfmt == 'xmrseed':
pwlen += 1
ea = ['--accept-defaults']
return self.pwgen(ftype,'фубар@crypto.org',pwfmt,pwlen,ea,stdout=stdout)
@ -390,3 +398,4 @@ class TestSuiteRef3Addr(TestSuiteRef3Seed):
def ref_bip39_18_passwdgen(self): return self.mn_pwgen(18,'bip39',stdout=True)
def ref_bip39_24_passwdgen(self): return self.mn_pwgen(24,'bip39')
def ref_hex2bip39_24_passwdgen(self): return self.mn_pwgen(24,'hex2bip39')
def ref_xmrseed_25_passwdgen(self): return self.mn_pwgen(24,'xmrseed',ftype='passxmrseed')