mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
trezorlib: disable encrypt/decrypt message functionality
it is disabled in Trezors and its utility is unclear
This commit is contained in:
parent
7e90e89e69
commit
00617817c3
56
trezorctl
56
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)
|
||||
|
||||
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user