mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-08 14:31:06 +00:00
fix(core): update structure of common seed so it works on BTC_ONLY
[no changelog]
This commit is contained in:
parent
c89106656f
commit
2b51be1eab
@ -68,21 +68,13 @@ if utils.USE_THP:
|
|||||||
assert common_seed is not None
|
assert common_seed is not None
|
||||||
return common_seed
|
return common_seed
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
@cache.stored_async(APP_COMMON_SEED)
|
|
||||||
async def get_seed() -> bytes:
|
|
||||||
await derive_and_store_roots_legacy()
|
|
||||||
common_seed = context.cache_get(APP_COMMON_SEED)
|
|
||||||
assert common_seed is not None
|
|
||||||
return common_seed
|
|
||||||
|
|
||||||
|
|
||||||
if utils.BITCOIN_ONLY:
|
if utils.BITCOIN_ONLY:
|
||||||
# === Bitcoin_only variant ===
|
# === Bitcoin_only variant ===
|
||||||
# We want to derive the normal seed ONLY
|
# We want to derive the normal seed ONLY
|
||||||
|
|
||||||
async def derive_and_store_roots(ctx: Context, msg: ThpCreateNewSession) -> None:
|
async def derive_and_store_roots(
|
||||||
|
ctx: Context, msg: ThpCreateNewSession
|
||||||
|
) -> None:
|
||||||
|
|
||||||
if msg.passphrase is not None and msg.on_device:
|
if msg.passphrase is not None and msg.on_device:
|
||||||
raise DataError("Passphrase provided when it shouldn't be!")
|
raise DataError("Passphrase provided when it shouldn't be!")
|
||||||
@ -101,10 +93,10 @@ if utils.BITCOIN_ONLY:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# === Cardano variant ===
|
# === Cardano variant ===
|
||||||
# We want to derive both the normal seed and the Cardano seed together, AND
|
# We want to derive both the normal seed and the Cardano seed together
|
||||||
# expose a method for Cardano to do the same
|
async def derive_and_store_roots(
|
||||||
|
ctx: Context, msg: ThpCreateNewSession
|
||||||
async def derive_and_store_roots(ctx: Context, msg: ThpCreateNewSession) -> None:
|
) -> None:
|
||||||
|
|
||||||
if msg.passphrase is not None and msg.on_device:
|
if msg.passphrase is not None and msg.on_device:
|
||||||
raise DataError("Passphrase provided when it shouldn't be!")
|
raise DataError("Passphrase provided when it shouldn't be!")
|
||||||
@ -127,7 +119,27 @@ else:
|
|||||||
ctx.cache.set_bool(APP_COMMON_DERIVE_CARDANO, True)
|
ctx.cache.set_bool(APP_COMMON_DERIVE_CARDANO, True)
|
||||||
derive_and_store_secrets(ctx, passphrase)
|
derive_and_store_secrets(ctx, passphrase)
|
||||||
|
|
||||||
if not utils.USE_THP:
|
else:
|
||||||
|
if utils.BITCOIN_ONLY:
|
||||||
|
# === Bitcoin-only variant ===
|
||||||
|
# We use the simple version of `get_seed` that never needs to derive anything else.
|
||||||
|
|
||||||
|
@cache.stored_async(APP_COMMON_SEED)
|
||||||
|
async def get_seed() -> bytes:
|
||||||
|
passphrase = await get_passphrase_legacy()
|
||||||
|
return mnemonic.get_seed(passphrase=passphrase)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# === Cardano variant ===
|
||||||
|
# We want to derive both the normal seed and the Cardano seed together, AND
|
||||||
|
# expose a method for Cardano to do the same
|
||||||
|
|
||||||
|
@cache.stored_async(APP_COMMON_SEED)
|
||||||
|
async def get_seed() -> bytes:
|
||||||
|
await derive_and_store_roots_legacy()
|
||||||
|
common_seed = context.cache_get(APP_COMMON_SEED)
|
||||||
|
assert common_seed is not None
|
||||||
|
return common_seed
|
||||||
|
|
||||||
async def derive_and_store_roots_legacy() -> None:
|
async def derive_and_store_roots_legacy() -> None:
|
||||||
from trezor import wire
|
from trezor import wire
|
||||||
|
Loading…
Reference in New Issue
Block a user