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

27 lines
729 B

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