mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-07 14:00:57 +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
|
||||
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 ===
|
||||
# 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:
|
||||
raise DataError("Passphrase provided when it shouldn't be!")
|
||||
@ -99,12 +91,12 @@ if utils.BITCOIN_ONLY:
|
||||
common_seed = mnemonic.get_seed(passphrase)
|
||||
ctx.cache.set(APP_COMMON_SEED, common_seed)
|
||||
|
||||
else:
|
||||
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
|
||||
|
||||
async def derive_and_store_roots(ctx: Context, msg: ThpCreateNewSession) -> None:
|
||||
# We want to derive both the normal seed and the Cardano seed together
|
||||
async def derive_and_store_roots(
|
||||
ctx: Context, msg: ThpCreateNewSession
|
||||
) -> None:
|
||||
|
||||
if msg.passphrase is not None and msg.on_device:
|
||||
raise DataError("Passphrase provided when it shouldn't be!")
|
||||
@ -127,7 +119,27 @@ else:
|
||||
ctx.cache.set_bool(APP_COMMON_DERIVE_CARDANO, True)
|
||||
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:
|
||||
from trezor import wire
|
||||
|
Loading…
Reference in New Issue
Block a user