chore(test): update Cardano unit tests to use saved binary mnemonic
What changed, and why it matters
This commit only updates Cardano unit tests to convert text seed phrases into binary format before passing them to a cryptographic function. It does not change any production wallet code, user-facing behavior, or security-sensitive logic. There is no indication this fixes or introduces a vulnerability.
No security action required. Treat as a routine test-maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies four Cardano test files. In each, the literal mnemonic string is first converted via bip39.mnemonic_to_bits() to a binary representation before being passed to cardano.derive_icarus(). This aligns the tests with an API change where derive_icarus now expects binary entropy rather than a text mnemonic. No runtime or firmware code is changed; only test setup and expected-value vectors are adjusted.
Changed components
core/tests/test_apps.cardano.address.pycore/tests/test_apps.cardano.get_public_key.pycore/tests/test_apps.cardano.native_script.pycore/tests/test_apps.cardano.seed.pyInspect captured patch +22 / −16
diff --git a/core/tests/test_apps.cardano.address.py b/core/tests/test_apps.cardano.address.py
index 22ad3b37..007d4110 100644
--- a/core/tests/test_apps.cardano.address.py
+++ b/core/tests/test_apps.cardano.address.py
@@ -2,7 +2,7 @@
from common import * # isort:skip
from trezor import wire
-from trezor.crypto import cardano, slip39
+from trezor.crypto import bip39, cardano, slip39
from trezor.enums import CardanoAddressType
from trezor.messages import CardanoAddressParametersType, CardanoBlockchainPointerType
@@ -23,8 +23,9 @@ if not utils.BITCOIN_ONLY:
class TestCardanoAddress(unittest.TestCase):
def setUp(self):
mnemonic = "all all all all all all all all all all all all"
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
passphrase = ""
- secret = cardano.derive_icarus(mnemonic, passphrase, False)
+ secret = cardano.derive_icarus(binary_mnemonic, passphrase, False)
node = cardano.from_secret(secret)
self.keychain = Keychain(node)
diff --git a/core/tests/test_apps.cardano.get_public_key.py b/core/tests/test_apps.cardano.get_public_key.py
index ae5850bd..75d9d50a 100644
--- a/core/tests/test_apps.cardano.get_public_key.py
+++ b/core/tests/test_apps.cardano.get_public_key.py
@@ -1,7 +1,7 @@
# flake8: noqa: F403,F405
from common import * # isort:skip
-from trezor.crypto import cardano, slip39
+from trezor.crypto import bip39, cardano, slip39
from apps.cardano.get_public_key import _get_public_key
from apps.cardano.seed import Keychain
@@ -11,7 +11,8 @@ from apps.cardano.seed import Keychain
class TestCardanoGetPublicKey(unittest.TestCase):
@staticmethod
def make_keychain_bip39(mnemonic, passphrase):
- secret = cardano.derive_icarus(mnemonic, passphrase, True)
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
+ secret = cardano.derive_icarus(binary_mnemonic, passphrase, True)
node = cardano.from_secret(secret)
return Keychain(node)
diff --git a/core/tests/test_apps.cardano.native_script.py b/core/tests/test_apps.cardano.native_script.py
index 3a188f7c..4c7f7871 100644
--- a/core/tests/test_apps.cardano.native_script.py
+++ b/core/tests/test_apps.cardano.native_script.py
@@ -2,7 +2,7 @@
from common import * # isort:skip
from trezor import wire
-from trezor.crypto import cardano
+from trezor.crypto import bip39, cardano
from trezor.enums import CardanoNativeScriptType
from trezor.messages import CardanoNativeScript
@@ -298,8 +298,9 @@ INVALID_SCRIPTS = [
class TestCardanoNativeScript(unittest.TestCase):
def test_get_native_script_hash(self):
mnemonic = "all all all all all all all all all all all all"
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
passphrase = ""
- secret = cardano.derive_icarus(mnemonic, passphrase, False)
+ secret = cardano.derive_icarus(binary_mnemonic, passphrase, False)
node = cardano.from_secret(secret)
keychain = Keychain(node)
diff --git a/core/tests/test_apps.cardano.seed.py b/core/tests/test_apps.cardano.seed.py
index 31700bfa..8e9a0450 100644
--- a/core/tests/test_apps.cardano.seed.py
+++ b/core/tests/test_apps.cardano.seed.py
@@ -1,7 +1,7 @@
# flake8: noqa: F403,F405
from common import * # isort:skip
-from trezor.crypto import cardano
+from trezor.crypto import bip39, cardano
from apps.common.paths import HARDENED
@@ -16,8 +16,9 @@ class TestCardanoKeychain(unittest.TestCase):
mnemonic = (
"test walk nut penalty hip pave soap entry language right filter choice"
)
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
passphrase = ""
- secret = cardano.derive_icarus(mnemonic, passphrase, True)
+ secret = cardano.derive_icarus(binary_mnemonic, passphrase, True)
node = cardano.from_secret(secret)
keychain = Keychain(node)
@@ -71,25 +72,26 @@ class TestCardanoDerivation(unittest.TestCase):
# vectors from:
# https://github.com/cardano-foundation/CIPs/blob/master/CIP-0003/Icarus.md
mnemonic = "eight country switch draw meat scout mystery blade tip drift useless good keep usage title"
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
- secret = cardano.derive_icarus(mnemonic, "", False)
+ secret = cardano.derive_icarus(binary_mnemonic, "", False)
self.assertEqual(
hexlify(secret).decode(),
"c065afd2832cd8b087c4d9ab7011f481ee1e0721e78ea5dd609f3ab3f156d245"
"d176bd8fd4ec60b4731c3918a2a72a0226c0cd119ec35b47e4d55884667f552a"
"23f7fdcd4a10c6cd2c7393ac61d877873e248f417634aa3d812af327ffe9d620",
)
- secret_trezor = cardano.derive_icarus(mnemonic, "", True)
+ secret_trezor = cardano.derive_icarus(binary_mnemonic, "", True)
self.assertEqual(secret, secret_trezor)
- secret = cardano.derive_icarus(mnemonic, "foo", False)
+ secret = cardano.derive_icarus(binary_mnemonic, "foo", False)
self.assertEqual(
hexlify(secret).decode(),
"70531039904019351e1afb361cd1b312a4d0565d4ff9f8062d38acf4b15cce41"
"d7b5738d9c893feea55512a3004acb0d222c35d3e3d5cde943a15a9824cbac59"
"443cf67e589614076ba01e354b1a432e0e6db3b59e37fc56b5fb0222970a010e",
)
- secret_trezor = cardano.derive_icarus(mnemonic, "foo", True)
+ secret_trezor = cardano.derive_icarus(binary_mnemonic, "foo", True)
self.assertEqual(secret, secret_trezor)
def test_icarus_trezor(self):
@@ -98,25 +100,26 @@ class TestCardanoDerivation(unittest.TestCase):
"shoot primary clutch crush open amazing screen patrol "
"group space point ten exist slush involve unfold"
)
- secret = cardano.derive_icarus(mnemonic, "", True)
+ binary_mnemonic = bip39.mnemonic_to_bits(mnemonic)
+ secret = cardano.derive_icarus(binary_mnemonic, "", True)
self.assertEqual(
hexlify(secret).decode(),
"409bb7a2998ec48029c8d2956fabd043a368ccc9b5120e42dd8a5c7145d08f45"
"e8e8664d06f62b4fc3bab0134778af27ddf059a4ad1eb0efefeedd8189bbfe00"
"deb289c5cdc2cf8ccfa19aea63b28424a4b0045b4b762292d46b73aa1c5cc99a",
)
- secret_icarus = cardano.derive_icarus(mnemonic, "", False)
+ secret_icarus = cardano.derive_icarus(binary_mnemonic, "", False)
self.assertNotEqual(secret, secret_icarus)
PASSPHRASE = "foo"
- secret = cardano.derive_icarus(mnemonic, PASSPHRASE, True)
+ secret = cardano.derive_icarus(binary_mnemonic, PASSPHRASE, True)
self.assertEqual(
hexlify(secret).decode(),
"c8ab7a160a66bfa7a118f553c4eebfe7444e36e449dac7d6eeae21f3bbaa9551"
"8593025160068776a4d61c0efc4f698585bb59f1aebe93c58e1eaf557ab59502"
"d9f68fbea3049bc2255d15fc63803e9c3dbb78abff2d53f8356794807d402568",
)
- secret_icarus = cardano.derive_icarus(mnemonic, PASSPHRASE, False)
+ secret_icarus = cardano.derive_icarus(binary_mnemonic, PASSPHRASE, False)
self.assertNotEqual(secret, secret_icarus)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.