mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
Merge pull request #427 from trezor/bitcoin-only
core: enable Bitcoin-only build
This commit is contained in:
commit
c307d9f14b
35
ci/build.yml
35
ci/build.yml
@ -24,6 +24,20 @@ build core firmware:
|
||||
- core/build/bootloader/bootloader.bin
|
||||
expire_in: 1 week
|
||||
|
||||
build core firmware bitcoinonly:
|
||||
stage: build
|
||||
variables:
|
||||
BITCOIN_ONLY: "1"
|
||||
script:
|
||||
- cd core
|
||||
- pipenv run make build_firmware
|
||||
- mv build/firmware/firmware.bin build/firmware/firmware-bitcoinonly.bin
|
||||
artifacts:
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
paths:
|
||||
- core/build/firmware/firmware-bitcoinonly.bin
|
||||
expire_in: 1 week
|
||||
|
||||
build core unix:
|
||||
stage: build
|
||||
script:
|
||||
@ -42,6 +56,21 @@ build core unix frozen:
|
||||
- core/src/trezor/res/resources.py
|
||||
expire_in: 1 day
|
||||
|
||||
build core unix frozen bitcoinonly:
|
||||
stage: build
|
||||
variables:
|
||||
BITCOIN_ONLY: "1"
|
||||
script:
|
||||
- cd core
|
||||
- pipenv run make build_unix_frozen
|
||||
- mv build/unix/micropython build/unix/micropython-bitcoinonly
|
||||
artifacts:
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
paths:
|
||||
- core/build/unix/micropython-bitcoinonly
|
||||
- core/src/trezor/res/resources.py
|
||||
expire_in: 1 day
|
||||
|
||||
|
||||
# Crypto
|
||||
|
||||
@ -110,3 +139,9 @@ build legacy emu bitcoinonly:
|
||||
script:
|
||||
- cd legacy
|
||||
- pipenv run script/cibuild
|
||||
- mv firmware/trezor.elf firmware/trezor-bitcoinonly.elf
|
||||
artifacts:
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
|
||||
paths:
|
||||
- legacy/firmware/trezor-bitcoinonly.elf
|
||||
expire_in: 1 day
|
||||
|
23
ci/test.yml
23
ci/test.yml
@ -18,6 +18,17 @@ test core unix device:
|
||||
- cd core
|
||||
- pipenv run make test_emu
|
||||
|
||||
test core unix device bitcoinonly:
|
||||
stage: test
|
||||
dependencies:
|
||||
- build core unix frozen bitcoinonly
|
||||
variables:
|
||||
MICROPYTHON: "../build/unix/micropython-bitcoinonly"
|
||||
TREZOR_PYTEST_SKIP_ALTCOINS: 1
|
||||
script:
|
||||
- cd core
|
||||
- pipenv run make test_emu
|
||||
|
||||
test core unix monero:
|
||||
stage: test
|
||||
dependencies:
|
||||
@ -54,6 +65,18 @@ test legacy emu:
|
||||
- cd legacy
|
||||
- pipenv run script/test
|
||||
|
||||
test legacy emu bitcoinonly:
|
||||
stage: test
|
||||
dependencies:
|
||||
- build legacy emu bitcoinonly
|
||||
variables:
|
||||
EMULATOR: "1"
|
||||
EMULATOR_BINARY: "firmware/trezor-bitcoinonly.elf"
|
||||
TREZOR_PYTEST_SKIP_ALTCOINS: 1
|
||||
script:
|
||||
- cd legacy
|
||||
- pipenv run script/test
|
||||
|
||||
|
||||
# Python
|
||||
|
||||
|
@ -18,6 +18,7 @@ CROSS_PORT_OPTS ?=
|
||||
|
||||
PRODUCTION ?= 0
|
||||
PYOPT ?= 1
|
||||
BITCOIN_ONLY ?= 0
|
||||
|
||||
STLINK_VER ?= v2
|
||||
OPENOCD = openocd -f interface/stlink-$(STLINK_VER).cfg -c "transport select hla_swd" -f target/stm32f4x.cfg
|
||||
@ -105,13 +106,13 @@ build_reflash: ## build reflash firmware + reflash image
|
||||
dd if=build/bootloader/bootloader.bin of=$(REFLASH_BUILD_DIR)/sdimage.bin bs=1 seek=49152
|
||||
|
||||
build_firmware: res build_cross ## build firmware with frozen modules
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" $(FIRMWARE_BUILD_DIR)/firmware.bin
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" BITCOIN_ONLY="$(BITCOIN_ONLY)" $(FIRMWARE_BUILD_DIR)/firmware.bin
|
||||
|
||||
build_unix: res ## build unix port
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS)
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) BITCOIN_ONLY="$(BITCOIN_ONLY)"
|
||||
|
||||
build_unix_frozen: res build_cross ## build unix port with frozen modules
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" TREZOR_EMULATOR_FROZEN=1
|
||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
|
||||
|
||||
build_cross: ## build mpy-cross port
|
||||
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
import os
|
||||
|
||||
EVERYTHING = True
|
||||
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
|
||||
EVERYTHING = BITCOIN_ONLY != '1'
|
||||
|
||||
CCFLAGS_MOD = ''
|
||||
CPPPATH_MOD = []
|
||||
@ -326,7 +327,7 @@ SOURCE_TREZORHAL = [
|
||||
|
||||
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_MICROPYTHON_SPEED
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT))
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPRODUCTION=%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), ARGUMENTS.get('PRODUCTION', '0'), PYOPT, BITCOIN_ONLY))
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
@ -365,7 +366,7 @@ env.Replace(
|
||||
'-fstack-protector-all '
|
||||
+ CPU_CCFLAGS + CCFLAGS_MOD,
|
||||
CCFLAGS_QSTR='-DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB',
|
||||
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}.ld -Wl,--gc-sections -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common',
|
||||
LINKFLAGS='-T embed/firmware/memory_${TREZOR_MODEL}%s.ld -Wl,--gc-sections -Wl,-Map=build/firmware/firmware.map -Wl,--warn-common' % ('' if EVERYTHING else '_min'),
|
||||
CPPPATH=[
|
||||
'.',
|
||||
'embed/firmware',
|
||||
@ -504,7 +505,7 @@ if FROZEN:
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py'))
|
||||
|
||||
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR)
|
||||
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR, bitcoin_only=BITCOIN_ONLY)
|
||||
|
||||
source_mpyc = env.FrozenCFile(
|
||||
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
import os
|
||||
|
||||
EVERYTHING = True
|
||||
BITCOIN_ONLY = ARGUMENTS.get('BITCOIN_ONLY', '0')
|
||||
EVERYTHING = BITCOIN_ONLY != '1'
|
||||
|
||||
CCFLAGS_MOD = ''
|
||||
CPPPATH_MOD = []
|
||||
@ -299,7 +300,7 @@ SOURCE_UNIX = [
|
||||
|
||||
SOURCE_QSTR = SOURCE_MOD + SOURCE_MICROPYTHON + SOURCE_UNIX
|
||||
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT))
|
||||
env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s -DBITCOIN_ONLY=%s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY))
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
@ -467,7 +468,7 @@ if FROZEN:
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py'))
|
||||
|
||||
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR)
|
||||
source_mpy = env.FrozenModule(source=SOURCE_PY, source_dir=SOURCE_PY_DIR, bitcoin_only=BITCOIN_ONLY)
|
||||
|
||||
source_mpyc = env.FrozenCFile(
|
||||
target='frozen_mpy.c', source=source_mpy, qstr_header=qstr_preprocessed)
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include "bip39.h"
|
||||
#include "curves.h"
|
||||
#include "memzero.h"
|
||||
#if !BITCOIN_ONLY
|
||||
#include "nem.h"
|
||||
#endif
|
||||
|
||||
/// package: trezorcrypto.bip32
|
||||
|
||||
@ -184,6 +186,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_HDNode_derive_obj,
|
||||
2, 3,
|
||||
mod_trezorcrypto_HDNode_derive);
|
||||
|
||||
#if !BITCOIN_ONLY
|
||||
|
||||
/// def derive_cardano(self, index: int) -> None:
|
||||
/// """
|
||||
/// Derive a BIP0032 child node in place using Cardano algorithm.
|
||||
@ -217,6 +221,8 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_derive_cardano(mp_obj_t self,
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_HDNode_derive_cardano_obj,
|
||||
mod_trezorcrypto_HDNode_derive_cardano);
|
||||
|
||||
#endif
|
||||
|
||||
/// def derive_path(self, path: List[int]) -> None:
|
||||
/// """
|
||||
/// Go through a list of indexes and iteratively derive a child node in
|
||||
@ -409,6 +415,8 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_address(mp_obj_t self,
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_HDNode_address_obj,
|
||||
mod_trezorcrypto_HDNode_address);
|
||||
|
||||
#if !BITCOIN_ONLY
|
||||
|
||||
/// def nem_address(self, network: int) -> str:
|
||||
/// """
|
||||
/// Compute a NEM address string from the HD node.
|
||||
@ -489,6 +497,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(
|
||||
mod_trezorcrypto_HDNode_ethereum_pubkeyhash_obj,
|
||||
mod_trezorcrypto_HDNode_ethereum_pubkeyhash);
|
||||
|
||||
#endif
|
||||
|
||||
/// def __del__(self) -> None:
|
||||
/// """
|
||||
/// Cleans up sensitive memory.
|
||||
@ -507,15 +517,16 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_HDNode_locals_dict_table[] = {
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode___del___obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_derive),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_derive_obj)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_derive_cardano),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_derive_cardano_obj)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_derive_path),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_derive_path_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_serialize_private),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_serialize_private_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_serialize_public),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_serialize_public_obj)},
|
||||
|
||||
{MP_ROM_QSTR(MP_QSTR_clone),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_clone_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_depth),
|
||||
@ -534,12 +545,14 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_HDNode_locals_dict_table[] = {
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_public_key_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_address),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_address_obj)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_nem_address),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_nem_address_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_nem_encrypt),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_nem_encrypt_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_ethereum_pubkeyhash),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_HDNode_ethereum_pubkeyhash_obj)},
|
||||
#endif
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_HDNode_locals_dict,
|
||||
mod_trezorcrypto_HDNode_locals_dict_table);
|
||||
@ -606,8 +619,10 @@ STATIC mp_obj_t mod_trezorcrypto_bip32_from_seed(mp_obj_t seed,
|
||||
int res = 0;
|
||||
if (strcmp(curveb.buf, ED25519_CARDANO_NAME) != 0) {
|
||||
res = hdnode_from_seed(seedb.buf, seedb.len, curveb.buf, &hdnode);
|
||||
#if !BITCOIN_ONLY
|
||||
} else {
|
||||
res = hdnode_from_seed_cardano(seedb.buf, seedb.len, &hdnode);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
@ -623,6 +638,8 @@ STATIC mp_obj_t mod_trezorcrypto_bip32_from_seed(mp_obj_t seed,
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_bip32_from_seed_obj,
|
||||
mod_trezorcrypto_bip32_from_seed);
|
||||
|
||||
#if !BITCOIN_ONLY
|
||||
|
||||
/// def from_mnemonic_cardano(mnemonic: str, passphrase: str) -> bytes:
|
||||
/// """
|
||||
/// Construct a HD node from a BIP-0039 mnemonic using the Icarus derivation
|
||||
@ -661,11 +678,12 @@ STATIC mp_obj_t mod_trezorcrypto_bip32_from_mnemonic_cardano(
|
||||
o->fingerprint = 0;
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(
|
||||
mod_trezorcrypto_bip32_from_mnemonic_cardano_obj,
|
||||
mod_trezorcrypto_bip32_from_mnemonic_cardano);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_trezorcrypto_bip32_globals_table[] = {
|
||||
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bip32)},
|
||||
{MP_ROM_QSTR(MP_QSTR_HDNode), MP_ROM_PTR(&mod_trezorcrypto_HDNode_type)},
|
||||
@ -673,8 +691,10 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_bip32_globals_table[] = {
|
||||
MP_ROM_PTR(&mod_trezorcrypto_bip32_deserialize_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_from_seed),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_bip32_from_seed_obj)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_from_mnemonic_cardano),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_bip32_from_mnemonic_cardano_obj)},
|
||||
#endif
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_bip32_globals,
|
||||
mod_trezorcrypto_bip32_globals_table);
|
||||
|
@ -100,6 +100,8 @@ STATIC mp_obj_t mod_trezorcrypto_ed25519_sign(size_t n_args,
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_ed25519_sign_obj, 2,
|
||||
3, mod_trezorcrypto_ed25519_sign);
|
||||
|
||||
#if !BITCOIN_ONLY
|
||||
|
||||
/// def sign_ext(
|
||||
/// secret_key: bytes, secret_extension: bytes, message: bytes
|
||||
/// ) -> bytes:
|
||||
@ -135,6 +137,8 @@ STATIC mp_obj_t mod_trezorcrypto_ed25519_sign_ext(mp_obj_t secret_key,
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_trezorcrypto_ed25519_sign_ext_obj,
|
||||
mod_trezorcrypto_ed25519_sign_ext);
|
||||
|
||||
#endif
|
||||
|
||||
/// def verify(public_key: bytes, signature: bytes, message: bytes) -> bool:
|
||||
/// """
|
||||
/// Uses public key to verify the signature of the message.
|
||||
@ -282,8 +286,10 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_ed25519_globals_table[] = {
|
||||
{MP_ROM_QSTR(MP_QSTR_publickey),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_ed25519_publickey_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_sign), MP_ROM_PTR(&mod_trezorcrypto_ed25519_sign_obj)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_sign_ext),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_ed25519_sign_ext_obj)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_verify),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_ed25519_verify_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_cosi_combine_publickeys),
|
||||
|
@ -36,15 +36,12 @@
|
||||
#include "modtrezorcrypto-curve25519.h"
|
||||
#include "modtrezorcrypto-ed25519.h"
|
||||
#include "modtrezorcrypto-groestl.h"
|
||||
#include "modtrezorcrypto-monero.h"
|
||||
#include "modtrezorcrypto-nem.h"
|
||||
#include "modtrezorcrypto-nist256p1.h"
|
||||
#include "modtrezorcrypto-pbkdf2.h"
|
||||
#include "modtrezorcrypto-random.h"
|
||||
#include "modtrezorcrypto-rfc6979.h"
|
||||
#include "modtrezorcrypto-ripemd160.h"
|
||||
#include "modtrezorcrypto-secp256k1.h"
|
||||
#include "modtrezorcrypto-secp256k1_zkp.h"
|
||||
#include "modtrezorcrypto-sha1.h"
|
||||
#include "modtrezorcrypto-sha256.h"
|
||||
#include "modtrezorcrypto-sha3-256.h"
|
||||
@ -52,6 +49,11 @@
|
||||
#include "modtrezorcrypto-sha512.h"
|
||||
#include "modtrezorcrypto-shamir.h"
|
||||
#include "modtrezorcrypto-slip39.h"
|
||||
#if !BITCOIN_ONLY
|
||||
#include "modtrezorcrypto-monero.h"
|
||||
#include "modtrezorcrypto-nem.h"
|
||||
#include "modtrezorcrypto-secp256k1_zkp.h"
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_trezorcrypto_globals_table[] = {
|
||||
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_trezorcrypto)},
|
||||
@ -69,12 +71,16 @@ STATIC const mp_rom_map_elem_t mp_module_trezorcrypto_globals_table[] = {
|
||||
MP_ROM_PTR(&mod_trezorcrypto_curve25519_module)},
|
||||
{MP_ROM_QSTR(MP_QSTR_ed25519),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_ed25519_module)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_monero), MP_ROM_PTR(&mod_trezorcrypto_monero_module)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_nist256p1),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_nist256p1_module)},
|
||||
{MP_ROM_QSTR(MP_QSTR_groestl512),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_Groestl512_type)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_nem), MP_ROM_PTR(&mod_trezorcrypto_nem_module)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_pbkdf2), MP_ROM_PTR(&mod_trezorcrypto_Pbkdf2_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mod_trezorcrypto_random_module)},
|
||||
{MP_ROM_QSTR(MP_QSTR_rfc6979), MP_ROM_PTR(&mod_trezorcrypto_Rfc6979_type)},
|
||||
@ -82,8 +88,10 @@ STATIC const mp_rom_map_elem_t mp_module_trezorcrypto_globals_table[] = {
|
||||
MP_ROM_PTR(&mod_trezorcrypto_Ripemd160_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_secp256k1),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_secp256k1_module)},
|
||||
#if !BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_secp256k1_zkp),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_secp256k1_zkp_module)},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_sha1), MP_ROM_PTR(&mod_trezorcrypto_Sha1_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_sha256), MP_ROM_PTR(&mod_trezorcrypto_Sha256_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_sha512), MP_ROM_PTR(&mod_trezorcrypto_Sha512_type)},
|
||||
|
@ -147,6 +147,11 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_EMULATOR), mp_const_false},
|
||||
#endif
|
||||
#if BITCOIN_ONLY
|
||||
{MP_ROM_QSTR(MP_QSTR_BITCOIN_ONLY), mp_const_true},
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_BITCOIN_ONLY), mp_const_false},
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_trezorutils_globals,
|
||||
|
79
core/embed/firmware/memory_T_min.ld
Normal file
79
core/embed/firmware/memory_T_min.ld
Normal file
@ -0,0 +1,79 @@
|
||||
/* TREZORv2 firmware linker script */
|
||||
|
||||
ENTRY(reset_handler)
|
||||
|
||||
MEMORY {
|
||||
FLASH (rx) : ORIGIN = 0x08040000, LENGTH = 768K
|
||||
FLASH2 (r) : ORIGIN = 0x08120000, LENGTH = 896K
|
||||
CCMRAM (wal) : ORIGIN = 0x10000000, LENGTH = 64K
|
||||
SRAM (wal) : ORIGIN = 0x20000000, LENGTH = 192K
|
||||
}
|
||||
|
||||
main_stack_base = ORIGIN(SRAM) + LENGTH(SRAM); /* 8-byte aligned full descending stack */
|
||||
_estack = main_stack_base;
|
||||
|
||||
/* used by the startup code to populate variables used by the C code */
|
||||
data_lma = LOADADDR(.data);
|
||||
data_vma = ADDR(.data);
|
||||
data_size = SIZEOF(.data);
|
||||
|
||||
/* used by the startup code to wipe memory */
|
||||
ccmram_start = ORIGIN(CCMRAM);
|
||||
ccmram_end = ORIGIN(CCMRAM) + LENGTH(CCMRAM);
|
||||
|
||||
/* used by the startup code to wipe memory */
|
||||
sram_start = ORIGIN(SRAM);
|
||||
sram_end = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
_ram_start = sram_start;
|
||||
_ram_end = sram_end;
|
||||
|
||||
_codelen = LENGTH(FLASH) - SIZEOF(.vendorheader) - SIZEOF(.header) + SIZEOF(.flash2);
|
||||
_flash_start = ORIGIN(FLASH);
|
||||
_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
|
||||
_heap_start = ADDR(.heap);
|
||||
_heap_end = ADDR(.heap) + SIZEOF(.heap);
|
||||
|
||||
SECTIONS {
|
||||
.vendorheader : ALIGN(4) {
|
||||
KEEP(*(.vendorheader))
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.header : ALIGN(4) {
|
||||
KEEP(*(.header));
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.flash2 : ALIGN(512) {
|
||||
build/firmware/frozen_mpy.o(.rodata*);
|
||||
. = ALIGN(512);
|
||||
} >FLASH2 AT>FLASH2
|
||||
|
||||
.flash : ALIGN(512) {
|
||||
KEEP(*(.vector_table));
|
||||
. = ALIGN(4);
|
||||
*(.text*);
|
||||
. = ALIGN(4);
|
||||
*(.rodata*);
|
||||
. = ALIGN(4);
|
||||
*(.bootloader*);
|
||||
. = ALIGN(512);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.data : ALIGN(4) {
|
||||
*(.data*);
|
||||
. = ALIGN(512);
|
||||
} >SRAM AT>FLASH
|
||||
|
||||
.bss : ALIGN(4) {
|
||||
*(.bss*);
|
||||
. = ALIGN(4);
|
||||
} >SRAM
|
||||
|
||||
.heap : ALIGN(4) {
|
||||
. = 37K; /* this acts as a build time assertion that at least this much memory is available for heap use */
|
||||
. = ABSOLUTE(sram_end - 16K); /* this explicitly sets the end of the heap effectively giving the stack at most 16K */
|
||||
} >SRAM
|
||||
|
||||
.stack : ALIGN(8) {
|
||||
. = 4K; /* this acts as a build time assertion that at least this much memory is available for stack use */
|
||||
} >SRAM
|
||||
}
|
@ -23,7 +23,10 @@ def generate(env):
|
||||
target = str(target[0])
|
||||
source = str(source[0])
|
||||
source_name = source.replace(env['source_dir'], '')
|
||||
return '$MPY_CROSS -o %s -s %s %s' % (target, source_name, source)
|
||||
# unroll the utils.BITCOIN_ONLY constant
|
||||
btc_only = 'True' if env['bitcoin_only'] == '1' else 'False'
|
||||
interim = "%s.i" % target[:-4] # replace .mpy with .i
|
||||
return '$SED "s:utils\.BITCOIN_ONLY:%s:g" %s > %s && $MPY_CROSS -o %s -s %s %s' % (btc_only, source, interim, target, source_name, interim)
|
||||
|
||||
env['BUILDERS']['FrozenModule'] = SCons.Builder.Builder(
|
||||
generator=generate_frozen_module,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
# generated from coininfo.py.mako
|
||||
# do not edit manually!
|
||||
from trezor import utils
|
||||
from trezor.crypto.base58 import blake256d_32, groestl512d_32, keccak_32, sha256d_32
|
||||
from trezor.crypto.scripts import blake256_ripemd160_digest, sha256_ripemd160_digest
|
||||
|
||||
@ -108,16 +109,33 @@ ATTRIBUTES = (
|
||||
("curve_name", lambda r: repr(r.replace("_", "-"))),
|
||||
("confidential_assets", optional_dict),
|
||||
)
|
||||
|
||||
btc_names = ["Bitcoin", "Testnet", "Regtest"]
|
||||
|
||||
coins_btc = [c for c in supported_on("trezor2", bitcoin) if c.name in btc_names]
|
||||
coins_alt = [c for c in supported_on("trezor2", bitcoin) if c.name not in btc_names]
|
||||
|
||||
%>\
|
||||
def by_name(name: str) -> CoinInfo:
|
||||
if False:
|
||||
pass
|
||||
% for coin in supported_on("trezor2", bitcoin):
|
||||
% for coin in coins_btc:
|
||||
elif name == ${black_repr(coin["coin_name"])}:
|
||||
return CoinInfo(
|
||||
% for attr, func in ATTRIBUTES:
|
||||
${attr}=${func(coin[attr])},
|
||||
% endfor
|
||||
)
|
||||
% endfor
|
||||
if not utils.BITCOIN_ONLY:
|
||||
if False:
|
||||
pass
|
||||
% for coin in coins_alt:
|
||||
elif name == ${black_repr(coin["coin_name"])}:
|
||||
return CoinInfo(
|
||||
% for attr, func in ATTRIBUTES:
|
||||
${attr}=${func(coin[attr])},
|
||||
% endfor
|
||||
)
|
||||
% endfor
|
||||
raise ValueError('Unknown coin name "%s"' % name)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from trezor import config, utils, wire
|
||||
from trezor.messages import MessageType
|
||||
from trezor.messages import Feature, MessageType
|
||||
from trezor.messages.Features import Features
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.wire import register
|
||||
@ -36,6 +36,25 @@ def get_features() -> Features:
|
||||
f.no_backup = storage.device.no_backup()
|
||||
f.flags = storage.device.get_flags()
|
||||
f.recovery_mode = storage.recovery.is_in_progress()
|
||||
if utils.BITCOIN_ONLY:
|
||||
f.features = [Feature.Bitcoin, Feature.Crypto]
|
||||
else:
|
||||
f.features = [
|
||||
Feature.Bitcoin,
|
||||
Feature.Bitcoin_like,
|
||||
Feature.Binance,
|
||||
Feature.Cardano,
|
||||
Feature.Crypto,
|
||||
Feature.EOS,
|
||||
Feature.Ethereum,
|
||||
Feature.Lisk,
|
||||
Feature.Monero,
|
||||
Feature.NEM,
|
||||
Feature.Ripple,
|
||||
Feature.Stellar,
|
||||
Feature.Tezos,
|
||||
Feature.U2F,
|
||||
]
|
||||
return f
|
||||
|
||||
|
||||
|
@ -32,40 +32,45 @@ def _boot_default() -> None:
|
||||
import apps.homescreen
|
||||
import apps.management
|
||||
import apps.wallet
|
||||
import apps.ethereum
|
||||
import apps.lisk
|
||||
import apps.monero
|
||||
import apps.nem
|
||||
import apps.stellar
|
||||
import apps.ripple
|
||||
import apps.cardano
|
||||
import apps.tezos
|
||||
import apps.eos
|
||||
import apps.binance
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
import apps.ethereum
|
||||
import apps.lisk
|
||||
import apps.monero
|
||||
import apps.nem
|
||||
import apps.stellar
|
||||
import apps.ripple
|
||||
import apps.cardano
|
||||
import apps.tezos
|
||||
import apps.eos
|
||||
import apps.binance
|
||||
|
||||
if __debug__:
|
||||
import apps.debug
|
||||
else:
|
||||
import apps.webauthn
|
||||
if not utils.BITCOIN_ONLY:
|
||||
import apps.webauthn
|
||||
|
||||
# boot applications
|
||||
apps.homescreen.boot()
|
||||
apps.management.boot()
|
||||
apps.wallet.boot()
|
||||
apps.ethereum.boot()
|
||||
apps.lisk.boot()
|
||||
apps.monero.boot()
|
||||
apps.nem.boot()
|
||||
apps.stellar.boot()
|
||||
apps.ripple.boot()
|
||||
apps.cardano.boot()
|
||||
apps.tezos.boot()
|
||||
apps.eos.boot()
|
||||
apps.binance.boot()
|
||||
if not utils.BITCOIN_ONLY:
|
||||
apps.ethereum.boot()
|
||||
apps.lisk.boot()
|
||||
apps.monero.boot()
|
||||
apps.nem.boot()
|
||||
apps.stellar.boot()
|
||||
apps.ripple.boot()
|
||||
apps.cardano.boot()
|
||||
apps.tezos.boot()
|
||||
apps.eos.boot()
|
||||
apps.binance.boot()
|
||||
if __debug__:
|
||||
apps.debug.boot()
|
||||
else:
|
||||
apps.webauthn.boot(usb.iface_webauthn)
|
||||
if not utils.BITCOIN_ONLY:
|
||||
apps.webauthn.boot(usb.iface_webauthn)
|
||||
|
||||
# run main event loop and specify which screen is the default
|
||||
from apps.homescreen.homescreen import homescreen
|
||||
|
@ -1,12 +1,14 @@
|
||||
from trezor import utils
|
||||
from trezorcrypto import ( # noqa: F401
|
||||
aes,
|
||||
bip32,
|
||||
bip39,
|
||||
chacha20poly1305,
|
||||
crc,
|
||||
monero,
|
||||
nem,
|
||||
pbkdf2,
|
||||
random,
|
||||
rfc6979,
|
||||
)
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
from trezorcrypto import monero, nem # noqa: F401
|
||||
|
@ -1,7 +1,5 @@
|
||||
from trezorcrypto import ( # noqa: F401
|
||||
curve25519,
|
||||
ed25519,
|
||||
nist256p1,
|
||||
secp256k1,
|
||||
secp256k1_zkp,
|
||||
)
|
||||
from trezor import utils
|
||||
from trezorcrypto import curve25519, ed25519, nist256p1, secp256k1 # noqa: F401
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
from trezorcrypto import secp256k1_zkp # noqa: F401
|
||||
|
@ -1,6 +1,7 @@
|
||||
import gc
|
||||
import sys
|
||||
from trezorutils import ( # noqa: F401
|
||||
BITCOIN_ONLY,
|
||||
EMULATOR,
|
||||
GITREV,
|
||||
MODEL,
|
||||
|
@ -83,6 +83,22 @@ void fsm_msgGetFeatures(const GetFeatures *msg) {
|
||||
resp->has_model = true;
|
||||
strlcpy(resp->model, "1", sizeof(resp->model));
|
||||
|
||||
#if BITCOIN_ONLY
|
||||
resp->features_count = 2;
|
||||
resp->features[0] = Feature_Feature_Bitcoin;
|
||||
resp->features[1] = Feature_Feature_Crypto;
|
||||
#else
|
||||
resp->features_count = 8;
|
||||
resp->features[0] = Feature_Feature_Bitcoin;
|
||||
resp->features[1] = Feature_Feature_Bitcoin_like;
|
||||
resp->features[2] = Feature_Feature_Crypto;
|
||||
resp->features[3] = Feature_Feature_Ethereum;
|
||||
resp->features[4] = Feature_Feature_Lisk;
|
||||
resp->features[5] = Feature_Feature_NEM;
|
||||
resp->features[6] = Feature_Feature_Stellar;
|
||||
resp->features[7] = Feature_Feature_U2F;
|
||||
#endif
|
||||
|
||||
msg_write(MessageType_MessageType_Features, resp);
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,10 @@ def pytest_runtest_setup(item):
|
||||
if item.get_closest_marker("skip_t1") and item.get_closest_marker("skip_t2"):
|
||||
pytest.fail("Don't skip tests for both trezors!")
|
||||
|
||||
if item.get_closest_marker("altcoin") and os.environ.get(
|
||||
"TREZOR_PYTEST_SKIP_ALTCOINS", 0
|
||||
):
|
||||
pytest.skip("Skipping altcoin test")
|
||||
if item.get_closest_marker("skip_t2") and TREZOR_VERSION == 2:
|
||||
pytest.skip("Test excluded on Trezor T")
|
||||
if item.get_closest_marker("skip_t1") and TREZOR_VERSION == 1:
|
||||
|
Loading…
Reference in New Issue
Block a user