From cb9a85648400bba07d2f4976291abeb7f066d56c Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 23 May 2017 12:44:36 +0200 Subject: [PATCH] apps.common.seed: add get_root_without_passphrase TODO: decomplect storage/seed/workflows after introducing storage classes (session/request/persistent) --- src/apps/common/seed.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/apps/common/seed.py b/src/apps/common/seed.py index 069d6beb1..42f782bd7 100644 --- a/src/apps/common/seed.py +++ b/src/apps/common/seed.py @@ -31,3 +31,14 @@ async def compute_seed(session_id: int) -> bytes: passphrase = await protect_by_passphrase(session_id) return bip39.seed(storage.get_mnemonic(), passphrase) + + +def get_root_without_passphrase(curve_name=_DEFAULT_CURVE): + from . import storage + if not storage.is_initialized(): + raise Exception('Device is not initialized') + if storage.is_locked(): + raise Exception('Unlock first') + seed = bip39.seed(storage.get_mnemonic(), '') + root = bip32.from_seed(seed, curve_name) + return root