From 00617817c3d64f5d71c417aae1385c507a879fe4 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 14 Jun 2018 16:09:19 +0200 Subject: [PATCH] trezorlib: disable encrypt/decrypt message functionality it is disabled in Trezors and its utility is unclear --- trezorctl | 56 ++++++++++++++++++++++----------------------- trezorlib/btc.py | 18 +++++++-------- trezorlib/client.py | 4 ++-- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/trezorctl b/trezorctl index 71afb30e13..01afc1e355 100755 --- a/trezorctl +++ b/trezorctl @@ -716,36 +716,36 @@ def decrypt_keyvalue(connect, address, key, value): return client.decrypt_keyvalue(address_n, key, binascii.unhexlify(value)) -@cli.command(help='Encrypt message.') -@click.option('-c', '--coin', default='Bitcoin') -@click.option('-d', '--display-only', is_flag=True) -@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") -@click.argument('pubkey') -@click.argument('message') -@click.pass_obj -def encrypt_message(connect, coin, display_only, address, pubkey, message): - client = connect() - pubkey = binascii.unhexlify(pubkey) - address_n = tools.parse_path(address) - res = client.encrypt_message(pubkey, message, display_only, coin, address_n) - return { - 'nonce': binascii.hexlify(res.nonce), - 'message': binascii.hexlify(res.message), - 'hmac': binascii.hexlify(res.hmac), - 'payload': base64.b64encode(res.nonce + res.message + res.hmac), - } +# @cli.command(help='Encrypt message.') +# @click.option('-c', '--coin', default='Bitcoin') +# @click.option('-d', '--display-only', is_flag=True) +# @click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") +# @click.argument('pubkey') +# @click.argument('message') +# @click.pass_obj +# def encrypt_message(connect, coin, display_only, address, pubkey, message): +# client = connect() +# pubkey = binascii.unhexlify(pubkey) +# address_n = tools.parse_path(address) +# res = client.encrypt_message(pubkey, message, display_only, coin, address_n) +# return { +# 'nonce': binascii.hexlify(res.nonce), +# 'message': binascii.hexlify(res.message), +# 'hmac': binascii.hexlify(res.hmac), +# 'payload': base64.b64encode(res.nonce + res.message + res.hmac), +# } -@cli.command(help='Decrypt message.') -@click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") -@click.argument('payload') -@click.pass_obj -def decrypt_message(connect, address, payload): - client = connect() - address_n = tools.parse_path(address) - payload = base64.b64decode(payload) - nonce, message, msg_hmac = payload[:33], payload[33:-8], payload[-8:] - return client.decrypt_message(address_n, nonce, message, msg_hmac) +# @cli.command(help='Decrypt message.') +# @click.option('-n', '--address', required=True, help="BIP-32 path, e.g. m/44'/0'/0'/0/0") +# @click.argument('payload') +# @click.pass_obj +# def decrypt_message(connect, address, payload): +# client = connect() +# address_n = tools.parse_path(address) +# payload = base64.b64decode(payload) +# nonce, message, msg_hmac = payload[:33], payload[33:-8], payload[-8:] +# return client.decrypt_message(address_n, nonce, message, msg_hmac) # diff --git a/trezorlib/btc.py b/trezorlib/btc.py index 98502733ac..4b72de5682 100644 --- a/trezorlib/btc.py +++ b/trezorlib/btc.py @@ -33,17 +33,17 @@ def verify_message(client, coin_name, address, signature, message): return isinstance(resp, proto.Success) -@expect(proto.EncryptedMessage) -def encrypt_message(client, pubkey, message, display_only, coin_name, n): - if coin_name and n: - return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only, coin_name=coin_name, address_n=n)) - else: - return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only)) +# @expect(proto.EncryptedMessage) +# def encrypt_message(client, pubkey, message, display_only, coin_name, n): +# if coin_name and n: +# return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only, coin_name=coin_name, address_n=n)) +# else: +# return client.call(proto.EncryptMessage(pubkey=pubkey, message=message, display_only=display_only)) -@expect(proto.DecryptedMessage) -def decrypt_message(client, n, nonce, message, msg_hmac): - return client.call(proto.DecryptMessage(address_n=n, nonce=nonce, message=message, hmac=msg_hmac)) +# @expect(proto.DecryptedMessage) +# def decrypt_message(client, n, nonce, message, msg_hmac): +# return client.call(proto.DecryptMessage(address_n=n, nonce=nonce, message=message, hmac=msg_hmac)) @session diff --git a/trezorlib/client.py b/trezorlib/client.py index 4d4780528d..8e9eb004e6 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -481,8 +481,8 @@ class ProtocolMixin(object): sign_tx = MovedTo(btc.sign_tx) sign_message = MovedTo(btc.sign_message) verify_message = MovedTo(btc.verify_message) - encrypt_message = MovedTo(btc.encrypt_message) - decrypt_message = MovedTo(btc.decrypt_message) + # encrypt_message = MovedTo(btc.encrypt_message) + # decrypt_message = MovedTo(btc.decrypt_message) # CoSi functionality cosi_commit = MovedTo(cosi.commit)