1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00

apps.wallet: implement GetEntropy

This commit is contained in:
Pavol Rusnak 2017-05-08 22:11:30 +02:00
parent 11154c1ab5
commit 5e410a3b59
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 38 additions and 2 deletions

View File

@ -1,7 +1,9 @@
from trezor.wire import register, protobuf_workflow from trezor.wire import register, protobuf_workflow
from trezor.utils import unimport from trezor.utils import unimport
from trezor.messages.wire_types import \ from trezor.messages.wire_types import \
GetPublicKey, GetAddress, SignTx, EstimateTxSize, \ GetPublicKey, GetAddress, \
GetEntropy, \
SignTx, EstimateTxSize, \
SignMessage, VerifyMessage, \ SignMessage, VerifyMessage, \
SignIdentity, \ SignIdentity, \
CipherKeyValue CipherKeyValue
@ -19,6 +21,12 @@ def dispatch_GetAddress(*args, **kwargs):
return layout_get_address(*args, **kwargs) return layout_get_address(*args, **kwargs)
@unimport
def dispatch_GetEntropy(*args, **kwargs):
from .get_entropy import layout_get_entropy
return layout_get_entropy(*args, **kwargs)
@unimport @unimport
def dispatch_SignTx(*args, **kwargs): def dispatch_SignTx(*args, **kwargs):
from .sign_tx import sign_tx from .sign_tx import sign_tx
@ -61,6 +69,7 @@ def dispatch_CipherKeyValue(*args, **kwargs):
def boot(): def boot():
register(GetPublicKey, protobuf_workflow, dispatch_GetPublicKey) register(GetPublicKey, protobuf_workflow, dispatch_GetPublicKey)
register(GetAddress, protobuf_workflow, dispatch_GetAddress) register(GetAddress, protobuf_workflow, dispatch_GetAddress)
register(GetEntropy, protobuf_workflow, dispatch_GetEntropy)
register(SignTx, protobuf_workflow, dispatch_SignTx) register(SignTx, protobuf_workflow, dispatch_SignTx)
register(EstimateTxSize, protobuf_workflow, dispatch_EstimateTxSize) register(EstimateTxSize, protobuf_workflow, dispatch_EstimateTxSize)
register(SignMessage, protobuf_workflow, dispatch_SignMessage) register(SignMessage, protobuf_workflow, dispatch_SignMessage)

View File

@ -0,0 +1,27 @@
from trezor import wire, ui
from trezor.utils import unimport
@unimport
async def layout_get_entropy(session_id, msg):
from trezor.messages.Entropy import Entropy
from trezor.crypto import random
l = min(msg.size, 1024)
await _show_entropy(session_id)
return Entropy(entropy=random.bytes(l))
async def _show_entropy(session_id):
from trezor.messages.ButtonRequestType import ProtectCall
from trezor.ui.text import Text
from trezor.ui.container import Container
from ..common.confirm import require_confirm
content = Container(
Text('Confirm entropy', ui.ICON_RESET, ui.MONO, 'Do you really want to send entropy?'))
await require_confirm(session_id, content, code=ProtectCall)

View File

@ -31,7 +31,6 @@ not passing:
test_msg_changepin.py \ test_msg_changepin.py \
test_msg_ethereum_signtx.py test_msg_ethereum_signtx.py
test_msg_getaddress_show.py test_msg_getaddress_show.py
test_msg_getentropy.py
test_msg_loaddevice.py test_msg_loaddevice.py
test_msg_ping.py test_msg_ping.py
test_msg_resetdevice.py test_msg_resetdevice.py
@ -50,6 +49,7 @@ for i in \
test_msg_estimatetxsize.py \ test_msg_estimatetxsize.py \
test_msg_ethereum_getaddress.py \ test_msg_ethereum_getaddress.py \
test_msg_getaddress.py \ test_msg_getaddress.py \
test_msg_getentropy.py
test_msg_getpublickey.py \ test_msg_getpublickey.py \
test_msg_signidentity.py \ test_msg_signidentity.py \
test_msg_signmessage.py \ test_msg_signmessage.py \