mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-20 14:39:22 +00:00
feat(core): allow secp256k1-zkp for bitcoin-only build
(but keep it disabled)
This commit is contained in:
parent
1dad3b548c
commit
4649b80b44
@ -107,7 +107,7 @@ if EVERYTHING:
|
||||
]
|
||||
|
||||
# libsecp256k1-zkp
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
CPPPATH_MOD += [
|
||||
'vendor/secp256k1-zkp',
|
||||
'vendor/secp256k1-zkp/src',
|
||||
@ -393,7 +393,7 @@ if TREZOR_MODEL == 'T':
|
||||
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16'
|
||||
CPU_CCFLAGS = '-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mtune=cortex-m4 '
|
||||
CPU_MODEL = 'STM32F427xx'
|
||||
LD_VARIANT = '_zkp' if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"] else ''
|
||||
LD_VARIANT = '_zkp' if FEATURE_FLAGS["SECP256K1_ZKP"] else ''
|
||||
elif TREZOR_MODEL == '1':
|
||||
CPU_ASFLAGS = '-mthumb -mcpu=cortex-m3 -mfloat-abi=soft'
|
||||
CPU_CCFLAGS = '-mthumb -mtune=cortex-m3 -mcpu=cortex-m3 -mfloat-abi=soft '
|
||||
@ -599,7 +599,7 @@ if FROZEN:
|
||||
#
|
||||
# static secp256-zkp ecmult context
|
||||
#
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
host_env = Environment(ENV=os.environ)
|
||||
host_env.Replace(
|
||||
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
||||
@ -622,7 +622,7 @@ if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
|
||||
obj_program = []
|
||||
obj_program.extend(env.Object(source=SOURCE_MOD))
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
|
||||
obj_program.extend(env.Object(source=SOURCE_FIRMWARE))
|
||||
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
||||
@ -651,7 +651,7 @@ obj_program.extend(
|
||||
' $SOURCE $TARGET', ))
|
||||
|
||||
env.Depends(obj_program, qstr_generated)
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
|
||||
|
||||
program_elf = env.Command(
|
||||
|
@ -105,7 +105,7 @@ if EVERYTHING:
|
||||
]
|
||||
|
||||
# libsecp256k1-zkp
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
CPPPATH_MOD += [
|
||||
'vendor/secp256k1-zkp',
|
||||
'vendor/secp256k1-zkp/src',
|
||||
@ -550,7 +550,7 @@ if FROZEN:
|
||||
#
|
||||
# static secp256-zkp ecmult context
|
||||
#
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
host_env = Environment(ENV=os.environ)
|
||||
host_env.Replace(
|
||||
CC=os.getenv('CC_FOR_BUILD') or 'gcc',
|
||||
@ -573,7 +573,7 @@ if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
|
||||
obj_program = []
|
||||
obj_program.extend(env.Object(source=SOURCE_MOD))
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
obj_program.extend(env.Object(source=SOURCE_MOD_SECP256K1_ZKP, CCFLAGS='$CCFLAGS -Wno-unused-function'))
|
||||
obj_program.extend(env.Object(source=SOURCE_MICROPYTHON))
|
||||
obj_program.extend(env.Object(source=SOURCE_UNIX))
|
||||
@ -581,7 +581,7 @@ if FROZEN:
|
||||
obj_program.extend(env.Object(source=source_mpyc))
|
||||
|
||||
env.Depends(obj_program, qstr_generated)
|
||||
if EVERYTHING and FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
if FEATURE_FLAGS["SECP256K1_ZKP"]:
|
||||
env.Depends(obj_program, secp256k1_zkp_ecmult_static_context)
|
||||
|
||||
program = env.Command(
|
||||
|
@ -42,6 +42,9 @@
|
||||
#include "modtrezorcrypto-random.h"
|
||||
#include "modtrezorcrypto-ripemd160.h"
|
||||
#include "modtrezorcrypto-secp256k1.h"
|
||||
#ifdef SECP256K1_BUILD
|
||||
#include "modtrezorcrypto-secp256k1_zkp.h"
|
||||
#endif
|
||||
#include "modtrezorcrypto-sha1.h"
|
||||
#include "modtrezorcrypto-sha256.h"
|
||||
#include "modtrezorcrypto-sha3-256.h"
|
||||
@ -52,9 +55,6 @@
|
||||
#if !BITCOIN_ONLY
|
||||
#include "modtrezorcrypto-monero.h"
|
||||
#include "modtrezorcrypto-nem.h"
|
||||
#ifdef SECP256K1_BUILD
|
||||
#include "modtrezorcrypto-secp256k1_zkp.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_trezorcrypto_globals_table[] = {
|
||||
@ -90,11 +90,9 @@ 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
|
||||
#ifdef SECP256K1_BUILD
|
||||
{MP_ROM_QSTR(MP_QSTR_secp256k1_zkp),
|
||||
MP_ROM_PTR(&mod_trezorcrypto_secp256k1_zkp_module)},
|
||||
#endif
|
||||
#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)},
|
||||
|
@ -1,9 +1,6 @@
|
||||
from trezorcrypto import curve25519, ed25519, nist256p1, secp256k1 # noqa: F401
|
||||
|
||||
from trezor import utils
|
||||
|
||||
if not utils.BITCOIN_ONLY:
|
||||
try:
|
||||
from trezorcrypto import secp256k1_zkp # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from trezorcrypto import secp256k1_zkp # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user