1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-30 20:02:34 +00:00
trezor-firmware/core/src/apps/misc/get_entropy.py
grdddj 996fec5aae chore(core): delete newlines in strings where they do not delimit useful info
Done so we can use the same strings for both TT and TR

[no changelog]
2023-02-07 12:26:33 +01:00

27 lines
729 B
Python

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)