You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/src/apps/misc/get_entropy.py

25 lines
705 B

from trezor.crypto import random
from trezor.messages import ButtonRequestType
from trezor.messages.Entropy import Entropy
from trezor.ui.layouts import confirm_action
if False:
from trezor.wire import Context
from trezor.messages.GetEntropy import GetEntropy
async def get_entropy(ctx: Context, msg: GetEntropy) -> Entropy:
await confirm_action(
ctx,
"get_entropy",
"Confirm entropy",
action="Do you really want\nto send entropy?",
description="Continue only if you\nknow what you are doing!",
br_code=ButtonRequestType.ProtectCall,
)
size = min(msg.size, 1024)
entropy = random.bytes(size)
return Entropy(entropy=entropy)