python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
import click
|
|
|
|
|
|
|
|
from .. import misc, tools
|
2020-03-24 15:02:48 +00:00
|
|
|
from . import with_client
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@click.group(name="crypto")
|
|
|
|
def cli():
|
|
|
|
"""Miscellaneous cryptography features."""
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.argument("size", type=int)
|
2020-03-24 15:02:48 +00:00
|
|
|
@with_client
|
|
|
|
def get_entropy(client, size):
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
"""Get random bytes from device."""
|
2020-03-24 15:02:48 +00:00
|
|
|
return misc.get_entropy(client, size).hex()
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016'/0")
|
|
|
|
@click.argument("key")
|
|
|
|
@click.argument("value")
|
2020-03-24 15:02:48 +00:00
|
|
|
@with_client
|
|
|
|
def encrypt_keyvalue(client, address, key, value):
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
"""Encrypt value by given key and path."""
|
|
|
|
address_n = tools.parse_path(address)
|
2020-03-24 15:02:48 +00:00
|
|
|
return misc.encrypt_keyvalue(client, address_n, key, value.encode()).hex()
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016'/0")
|
|
|
|
@click.argument("key")
|
|
|
|
@click.argument("value")
|
2020-03-24 15:02:48 +00:00
|
|
|
@with_client
|
|
|
|
def decrypt_keyvalue(client, address, key, value):
|
python/trezorctl: split trezorctl into separate modules
Instead of all commands (like `load-device`, `change-pin`,
`tezos-sign-tx`, `ethereum-verify-message`...) living in trezorctl.py,
each functional group is now defined in a separate file.
With that, better structuring of the trezorctl command becomes
available:
- instead of `trezorctl set-label`, use `trezorctl set label`
- instead of `trezorctl change-pin`, use `trezorctl set pin`
- instead of `trezorctl enable-passphrase`, use `trezorctl set
passphrase enabled`
For common commands, such as `sign-tx`, it is possible to use the
currency name or shortcut:
- `trezorctl btc sign-tx`
- `trezorctl ethereum sign-tx`
- `trezorctl xtz sign-tx`
- `trezorctl doge sign-tx`
etc.
Some aliases have been retained for better compatibility. For others,
refer to `trezorctl --help` and `trezorctl <command> --help`.
2019-09-10 13:00:27 +00:00
|
|
|
"""Decrypt value by given key and path."""
|
|
|
|
address_n = tools.parse_path(address)
|
|
|
|
return misc.decrypt_keyvalue(client, address_n, key, bytes.fromhex(value))
|