Beispiel #1
0
    def test_bip44_2(self):
        seed_wlist = "imitate lonely burden old genius trip identify wine walnut forget truly industry quarter october rug public stone rival photo more whip sample fix shrimp"
        d = SeedDerivation.from_mnemonics(seed_wlist.split(" "))

        self.assertEqual(
            d.creds(network_type=NetworkTypes.MAINNET).address,
            b"4AyUd1U6H3jSj2gbbaAyMm8wh3Xoah23x7Pm2SycZkURbHEbRoine8dE2QpJj5sEwp3YBy3z98K9t38Yzv4Fd8o69oTEnoB",
        )
Beispiel #2
0
    def test_slip0010_1(self):
        """
        https://github.com/satoshilabs/slips/blob/master/slip-0010.md
        :return:
        """
        seed = unhexlify(b"000102030405060708090a0b0c0d0e0f")

        d = SeedDerivation.from_master_seed(seed, slip0010=True, path="m")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7"
                )),
        )
        self.assertEqual(
            d.creds(network_type=NetworkTypes.MAINNET).address,
            b"44DybmHAKoojjhn4C57qqZeKQNXBGWznYhKuRHD3LvmyLCN2UxZfcTRLnCQASiyevEYg9szQqrdNeN6tXFa4xw484BSvd4r",
        )

        # m/0'
        d = SeedDerivation.from_master_seed(seed, slip0010=True, path="m/0'")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3"
                )),
        )

        # m/0'/1'/2'/2'/1000000000'
        d = SeedDerivation.from_master_seed(seed,
                                            slip0010=True,
                                            path="m/0'/1'/2'/2'/1000000000'")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793"
                )),
        )
Beispiel #3
0
    def test_bip44_1(self):
        seed_wlist = "permit universe parent weapon amused modify essay borrow tobacco budget walnut lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple"
        d = SeedDerivation.from_mnemonics(seed_wlist.split(" "))

        self.assertEqual(
            d.creds(network_type=NetworkTypes.MAINNET).address,
            b"42uUdtM9DyXTrGxYkyN8KW2myWJo5G71QiKyzheGHhRHY5khGGg4B7UfwzeQezzx65H9QPn2XtKqPHm7rRS1CQNpMFY3wud",
        )
        self.assertEqual(
            d.creds(network_type=NetworkTypes.TESTNET).address,
            b"9tT2891QWLdTrGxYkyN8KW2myWJo5G71QiKyzheGHhRHY5khGGg4B7UfwzeQezzx65H9QPn2XtKqPHm7rRS1CQNpMDDNrji",
        )
Beispiel #4
0
    def test_slip0010_3(self):
        seed_wlist = "permit universe parent weapon amused modify essay borrow tobacco budget walnut lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple"
        d = SeedDerivation.from_mnemonics(seed_wlist.split(" "), slip0010=True)

        self.assertEqual(
            d.creds(network_type=NetworkTypes.MAINNET).address,
            b"497MP7bh5MkCZ1TiZZoYi84s39n5V5HpSgPvrqqUMqw6XcWDu4QhBs4VkqiPsNMhTUPAHHE6DUo9UUqpfSZfxkANPw44Fgn",
        )
        self.assertEqual(
            d.creds(network_type=NetworkTypes.TESTNET).address,
            b"9zetsNFxMirCZ1TiZZoYi84s39n5V5HpSgPvrqqUMqw6XcWDu4QhBs4VkqiPsNMhTUPAHHE6DUo9UUqpfSZfxkANPwbdsur",
        )
Beispiel #5
0
    def test_slip0010_2(self):
        """
        https://github.com/satoshilabs/slips/blob/master/slip-0010.md
        :return:
        """
        seed = unhexlify(
            b"fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"
        )

        # m'
        d = SeedDerivation.from_master_seed(seed, slip0010=True, path="m")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012"
                )),
        )

        # m/0'
        d = SeedDerivation.from_master_seed(seed, slip0010=True, path="m/0'")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"1559eb2bbec5790b0c65d8693e4d0875b1747f4970ae8b650486ed7470845635"
                )),
        )

        # m/0H/2147483647H/1H/2147483646H/2H
        d = SeedDerivation.from_master_seed(
            seed, slip0010=True, path="m/0'/2147483647'/1'/2147483646'/2'")
        self.assertEqual(
            d.monero_master,
            self.recode_int(
                unhexlify(
                    b"551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d"
                )),
        )
Beispiel #6
0
async def amain():
    parser = argparse.ArgumentParser(description="Monero seed utility")
    parser.add_argument("input", metavar="mnemonics", nargs="*", help="Input")

    parser.add_argument(
        "--seed",
        dest="seed",
        default=False,
        action="store_const",
        const=True,
        help=
        "Input is hexcoded seed / master secret, input to Hnode derivation",
    )

    parser.add_argument(
        "--wlist-seed",
        dest="wlist_seed",
        default=False,
        action="store_const",
        const=True,
        help="Mnemonics converted to seed using the wordlist indices",
    )

    parser.add_argument(
        "--electrum-mnemonics",
        dest="electrum_mnemonics",
        default=False,
        action="store_const",
        const=True,
        help="Monero electrum mneomonics encoding Monero master secret seed",
    )

    parser.add_argument(
        "--monero-master",
        dest="monero_master",
        default=False,
        action="store_const",
        const=True,
        help="Monero master secret seed",
    )

    parser.add_argument(
        "--mainnet",
        dest="mainnet",
        default=False,
        action="store_const",
        const=True,
        help="Mainnet",
    )

    parser.add_argument(
        "--testnet",
        dest="testnet",
        default=False,
        action="store_const",
        const=True,
        help="Testnet",
    )

    parser.add_argument(
        "--stagenet",
        dest="stagenet",
        default=False,
        action="store_const",
        const=True,
        help="Stagenet",
    )

    parser.add_argument(
        "--subs",
        dest="subs",
        default=False,
        action="store_const",
        const=True,
        help="Compute 5x5 sub addresses given network",
    )

    parser.add_argument(
        "--slip0010",
        dest="slip0010",
        default=False,
        action="store_const",
        const=True,
        help="Use SLIP-0010 derivation with ED25519",
    )

    parser.add_argument("--path",
                        dest="path",
                        default=None,
                        help="Custom derivation path")
    parser.add_argument("--passphrase",
                        dest="passphrase",
                        default="",
                        help="Specify a passphrase for seed derivation")

    parser.add_argument(
        "--debug",
        dest="debug",
        default=False,
        action="store_const",
        const=True,
        help="Debug",
    )

    args = parser.parse_args()

    mnems = []
    for w in args.input:
        mnems += w.split(" ")
    mnems = [x.strip().lower() for x in mnems]

    bip44_derived = True
    deriv_args = {}
    if args.slip0010:
        deriv_args["slip0010"] = True
    if args.path:
        deriv_args["path"] = args.path

    if (sum([
            args.electrum_mnemonics, args.wlist_seed, args.monero_master,
            args.seed
    ]) > 1):
        raise ValueError("Conflicting input options")

    if args.electrum_mnemonics:
        if args.slip0010 or args.path:
            raise ValueError(
                "--electrum-mnemonics is conflicting with --slip0010 and --path"
            )
        bip44_derived = False
        sd = SeedDerivation.from_monero_mnemonics(mnems)

    elif args.monero_master:
        if args.slip0010 or args.path:
            raise ValueError(
                "--monero-master is conflicting with --slip0010 and --path")
        bip44_derived = False
        seed = binascii.unhexlify(" ".join(mnems))
        sd = SeedDerivation.from_monero_seed(seed)

    elif args.seed:
        seed = binascii.unhexlify(" ".join(mnems))
        sd = SeedDerivation.from_master_seed(seed, **deriv_args)

    else:
        sd = SeedDerivation.from_mnemonics(mnems, args.wlist_seed,
                                           args.passphrase.encode("utf8"),
                                           **deriv_args)

    main_addr = sd.creds(network_type=NetworkTypes.MAINNET)
    test_addr = sd.creds(network_type=NetworkTypes.TESTNET)
    stage_addr = sd.creds(network_type=NetworkTypes.STAGENET)

    if bip44_derived:
        print("Seed bip39 words: %s" % " ".join(mnems))
        print("Seed bip32 b58:   %s\n" %
              binascii.hexlify(sd.master_seed).decode("ascii"))

    if sd.monero_master:
        print("Seed Monero:      %s" %
              binascii.hexlify(sd.monero_master).decode("ascii"))
    if sd.electrum_words:
        print("Seed Monero wrds: %s\n" % sd.electrum_words)

    print("Private spend key: %s" %
          binascii.hexlify(crypto.encodeint(sd.spend_sec)).decode("ascii"))
    print("Private view key:  %s\n" %
          binascii.hexlify(crypto.encodeint(sd.view_sec)).decode("ascii"))

    print("Public spend key:  %s" %
          binascii.hexlify(crypto.encodepoint(sd.spend_pub)).decode("ascii"))
    print("Public view key:   %s\n" %
          binascii.hexlify(crypto.encodepoint(sd.view_pub)).decode("ascii"))

    print("Mainnet Address:   %s" % main_addr.address.decode("ascii"))
    print("Testnet Address:   %s" % test_addr.address.decode("ascii"))
    print("Stagenet Address:  %s" % stage_addr.address.decode("ascii"))

    if args.subs:
        if args.mainnet or (not args.testnet and not args.stagenet):
            print("Mainnet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.MAINNET)
        if args.testnet:
            print("Testnet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.TESTNET)
        if args.stagenet:
            print("Stagenet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.STAGENET)
 def get_trezor_creds(self, idx):
     sd = SeedDerivation.from_mnemonics(self.get_trezor_mnemonics()[idx])
     return sd.creds(monero.NetworkTypes.TESTNET)
Beispiel #8
0
async def amain(args):
    mnems = []
    for w in args.input:
        mnems += w.split(" ")
    mnems = [x.strip().lower() for x in mnems]

    bip44_derived = True
    deriv_args = {}
    if args.slip0010:
        deriv_args["slip0010"] = True
    if args.path:
        deriv_args["path"] = args.path

    if (sum([
            args.electrum_mnemonics, args.wlist_seed, args.monero_master,
            args.seed
    ]) > 1):
        raise ValueError("Conflicting input options")

    if args.electrum_mnemonics:
        if args.slip0010 or args.path:
            raise ValueError(
                "--electrum-mnemonics is conflicting with --slip0010 and --path"
            )
        bip44_derived = False
        sd = SeedDerivation.from_monero_mnemonics(mnems)

    elif args.monero_master:
        if args.slip0010 or args.path:
            raise ValueError(
                "--monero-master is conflicting with --slip0010 and --path")
        bip44_derived = False
        seed = binascii.unhexlify(" ".join(mnems))
        sd = SeedDerivation.from_monero_seed(seed)

    elif args.seed:
        seed = binascii.unhexlify(" ".join(mnems))
        sd = SeedDerivation.from_master_seed(seed, **deriv_args)

    else:
        sd = SeedDerivation.from_mnemonics(mnems, args.wlist_seed,
                                           **deriv_args)

    main_addr = sd.creds(network_type=NetworkTypes.MAINNET)
    test_addr = sd.creds(network_type=NetworkTypes.TESTNET)
    stage_addr = sd.creds(network_type=NetworkTypes.STAGENET)

    if bip44_derived:
        print("Seed bip39 words: %s" % " ".join(mnems))
        print("Seed bip32 b58:   %s\n" %
              binascii.hexlify(sd.master_seed).decode("ascii"))

    if sd.monero_master:
        print("Seed Monero:      %s" %
              binascii.hexlify(sd.monero_master).decode("ascii"))
    if sd.electrum_words:
        print("Seed Monero wrds: %s\n" % sd.electrum_words)

    print("Private spend key: %s" %
          binascii.hexlify(crypto.encodeint(sd.spend_sec)).decode("ascii"))
    print("Private view key:  %s\n" %
          binascii.hexlify(crypto.encodeint(sd.view_sec)).decode("ascii"))

    print("Public spend key:  %s" %
          binascii.hexlify(crypto.encodepoint(sd.spend_pub)).decode("ascii"))
    print("Public view key:   %s\n" %
          binascii.hexlify(crypto.encodepoint(sd.view_pub)).decode("ascii"))

    print("Mainnet Address:   %s" % main_addr.address.decode("ascii"))
    print("Testnet Address:   %s" % test_addr.address.decode("ascii"))
    print("Stagenet Address:  %s" % stage_addr.address.decode("ascii"))

    if args.subs:
        if args.mainnet or (not args.testnet and not args.stagenet):
            print("Mainnet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.MAINNET)
        if args.testnet:
            print("Testnet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.TESTNET)
        if args.stagenet:
            print("Stagenet Sub addresses: ")
            print_sub_addresses(sd, NetworkTypes.STAGENET)