seedsplit.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. help.seedsplit: seedsplit help notes for MMGen suite
  12. """
  13. def help(proto,cfg):
  14. from ..seedsplit import SeedShareIdx,SeedShareCount,MasterShareIdx
  15. return """
  16. COMMAND NOTES:
  17. This command generates shares one at a time. Shares may be output to any
  18. MMGen wallet format, with one limitation: only one share in a given split may
  19. be in hidden incognito format, and it must be the master share in the case of
  20. a master-share split.
  21. If the command's optional first argument is omitted, the default wallet is
  22. used for the split.
  23. The last argument is a seed split specifier consisting of an optional split
  24. ID, a share index, and a share count, all separated by colons. The split ID
  25. must be a valid UTF-8 string. If omitted, the ID 'default' is used. The
  26. share index (the index of the share being generated) must be in the range
  27. {si.min_val}-{si.max_val} and the share count (the total number of shares in the split)
  28. in the range {sc.min_val}-{sc.max_val}.
  29. Master Shares
  30. Each seed has a total of {mi.max_val} master shares, which can be used as the first
  31. shares in multiple splits if desired. To generate a master share, use the
  32. --master-share (-M) option with an index in the range {mi.min_val}-{mi.max_val} and omit
  33. the last argument.
  34. When creating and joining a split using a master share, ensure that the same
  35. master share index is used in all split and join commands.
  36. EXAMPLES:
  37. Split a BIP39 seed phrase into two BIP39 shares. Rejoin the split:
  38. $ echo 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong' > sample.bip39
  39. $ mmgen-seedsplit -o bip39 sample.bip39 1:2
  40. BIP39 mnemonic data written to file '03BAE887-default-1of2[D51CB683][128].bip39'
  41. $ mmgen-seedsplit -o bip39 sample.bip39 2:2
  42. BIP39 mnemonic data written to file '03BAE887-default-2of2[67BFD36E][128].bip39'
  43. $ mmgen-seedjoin -o bip39 \\
  44. '03BAE887-default-2of2[67BFD36E][128].bip39' \\
  45. '03BAE887-default-1of2[D51CB683][128].bip39'
  46. BIP39 mnemonic data written to file '03BAE887[128].bip39'
  47. $ cat '03BAE887[128].bip39'
  48. zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong
  49. Create a 3-way default split of your default wallet, outputting all shares
  50. to default wallet format. Rejoin the split:
  51. $ mmgen-seedsplit 1:3 # Step A
  52. $ mmgen-seedsplit 2:3 # Step B
  53. $ mmgen-seedsplit 3:3 # Step C
  54. $ mmgen-seedjoin <output_of_step_A> <output_of_step_B> <output_of_step_C>
  55. Create a 2-way split of your default wallet with ID string 'alice',
  56. outputting shares to MMGen native mnemonic format. Rejoin the split:
  57. $ mmgen-seedsplit -o words alice:1:2 # Step D
  58. $ mmgen-seedsplit -o words alice:2:2 # Step E
  59. $ mmgen-seedjoin <output_of_step_D> <output_of_step_E>
  60. Create a 2-way split of your default wallet with ID string 'bob' using
  61. master share #7, outputting share #1 (the master share) to default wallet
  62. format and share #2 to BIP39 format. Rejoin the split:
  63. $ mmgen-seedsplit -M7 # Step X
  64. $ mmgen-seedsplit -M7 -o bip39 bob:2:2 # Step Y
  65. $ mmgen-seedjoin -M7 --id-str=bob <output_of_step_X> <output_of_step_Y>
  66. Create a 2-way split of your default wallet with ID string 'alice' using
  67. master share #7. Rejoin the split using master share #7 generated in the
  68. previous example:
  69. $ mmgen-seedsplit -M7 -o bip39 alice:2:2 # Step Z
  70. $ mmgen-seedjoin -M7 --id-str=alice <output_of_step_X> <output_of_step_Z>
  71. Create a 2-way default split of your default wallet with an incognito-format
  72. master share hidden in file 'my.hincog' at offset 1325. Rejoin the split:
  73. $ mmgen-seedsplit -M4 -o hincog -J my.hincog,1325 1:2 # Step M (share A)
  74. $ mmgen-seedsplit -M4 -o bip39 2:2 # Step N (share B)
  75. $ mmgen-seedjoin -M4 -H my.hincog,1325 <output_of_step_N>
  76. """.strip().format(
  77. si = SeedShareIdx,
  78. sc = SeedShareCount,
  79. mi = MasterShareIdx )