From 47890a11e945572c388c7f3353ed4754d37d05ad Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sat, 11 Mar 2023 17:34:13 -0700 Subject: [PATCH 01/15] making crypto code a private lib --- application.fam | 5 +++++ flipbip.c | 5 +++-- helpers/flipbip_file.c | 9 ++++----- helpers/flipbip_led.h | 3 --- helpers/flipbip_string.c | 6 +++--- {crypto => lib/crypto}/AUTHORS | 0 {crypto => lib/crypto}/CONTRIBUTORS | 0 {crypto => lib/crypto}/LICENSE | 0 {crypto => lib/crypto}/Makefile | 0 {crypto => lib/crypto}/README.md | 0 {crypto => lib/crypto}/address.c | 0 {crypto => lib/crypto}/address.h | 0 {crypto => lib/crypto}/aes/aes.h | 0 {crypto => lib/crypto}/aes/aes_modes.c | 0 {crypto => lib/crypto}/aes/aescrypt.c | 0 {crypto => lib/crypto}/aes/aeskey.c | 0 {crypto => lib/crypto}/aes/aesopt.h | 0 {crypto => lib/crypto}/aes/aestab.c | 0 {crypto => lib/crypto}/aes/aestab.h | 0 {crypto => lib/crypto}/aes/aestst.c | 0 {crypto => lib/crypto}/aes/aestst.h | 0 {crypto => lib/crypto}/base32.c | 0 {crypto => lib/crypto}/base32.h | 0 {crypto => lib/crypto}/base58.c | 0 {crypto => lib/crypto}/base58.h | 0 {crypto => lib/crypto}/bignum.c | 0 {crypto => lib/crypto}/bignum.h | 0 {crypto => lib/crypto}/bip32.c | 0 {crypto => lib/crypto}/bip32.h | 0 {crypto => lib/crypto}/bip39.c | 0 {crypto => lib/crypto}/bip39.h | 0 {crypto => lib/crypto}/bip39_english.c | 0 {crypto => lib/crypto}/blake256.c | 0 {crypto => lib/crypto}/blake256.h | 0 {crypto => lib/crypto}/blake2_common.h | 0 {crypto => lib/crypto}/blake2b.c | 0 {crypto => lib/crypto}/blake2b.h | 0 {crypto => lib/crypto}/blake2s.c | 0 {crypto => lib/crypto}/blake2s.h | 0 {crypto => lib/crypto}/byte_order.h | 0 {crypto => lib/crypto}/cardano.c | 0 {crypto => lib/crypto}/cardano.h | 0 {crypto => lib/crypto}/cash_addr.c | 0 {crypto => lib/crypto}/cash_addr.h | 0 {crypto => lib/crypto}/chacha20poly1305/LICENSE | 0 .../crypto}/chacha20poly1305/chacha20poly1305.c | 0 .../crypto}/chacha20poly1305/chacha20poly1305.h | 0 .../crypto}/chacha20poly1305/chacha_merged.c | 0 .../crypto}/chacha20poly1305/ecrypt_config.h | 0 .../crypto}/chacha20poly1305/ecrypt_machine.h | 0 .../crypto}/chacha20poly1305/ecrypt_portable.h | 0 .../crypto}/chacha20poly1305/ecrypt_sync.h | 0 .../crypto}/chacha20poly1305/ecrypt_types.h | 0 .../crypto}/chacha20poly1305/poly1305_donna.c | 0 .../crypto}/chacha20poly1305/poly1305_donna.h | 0 .../crypto}/chacha20poly1305/poly1305_donna_32.h | 0 {crypto => lib/crypto}/chacha20poly1305/rfc7539.c | 0 {crypto => lib/crypto}/chacha20poly1305/rfc7539.h | 0 {crypto => lib/crypto}/chacha_drbg.c | 0 {crypto => lib/crypto}/chacha_drbg.h | 0 {crypto => lib/crypto}/check_mem.h | 0 {crypto => lib/crypto}/curves.c | 0 {crypto => lib/crypto}/curves.h | 0 {crypto => lib/crypto}/ecdsa.c | 0 {crypto => lib/crypto}/ecdsa.h | 0 {crypto => lib/crypto}/ed25519_donna/README.md | 0 .../crypto}/ed25519_donna/curve25519_donna_32bit.c | 0 .../crypto}/ed25519_donna/curve25519_donna_32bit.h | 0 .../ed25519_donna/curve25519_donna_helpers.c | 0 .../ed25519_donna/curve25519_donna_helpers.h | 0 .../curve25519_donna_scalarmult_base.c | 0 .../curve25519_donna_scalarmult_base.h | 0 {crypto => lib/crypto}/ed25519_donna/ed25519.c | 0 {crypto => lib/crypto}/ed25519_donna/ed25519.h | 0 .../crypto}/ed25519_donna/ed25519_donna.h | 0 .../ed25519_donna/ed25519_donna_32bit_tables.c | 0 .../ed25519_donna/ed25519_donna_32bit_tables.h | 0 .../ed25519_donna/ed25519_donna_basepoint_table.c | 0 .../ed25519_donna/ed25519_donna_basepoint_table.h | 0 .../ed25519_donna/ed25519_donna_impl_base.c | 0 .../ed25519_donna/ed25519_donna_impl_base.h | 0 .../crypto}/ed25519_donna/ed25519_donna_portable.h | 0 .../crypto}/ed25519_donna/ed25519_hash_custom.h | 0 .../ed25519_donna/ed25519_hash_custom_keccak.h | 0 .../ed25519_donna/ed25519_hash_custom_sha3.h | 0 .../crypto}/ed25519_donna/ed25519_keccak.c | 0 .../crypto}/ed25519_donna/ed25519_keccak.h | 0 .../crypto}/ed25519_donna/ed25519_sha3.c | 0 .../crypto}/ed25519_donna/ed25519_sha3.h | 0 .../crypto}/ed25519_donna/modm_donna_32bit.c | 0 .../crypto}/ed25519_donna/modm_donna_32bit.h | 0 {crypto => lib/crypto}/groestl.c | 0 {crypto => lib/crypto}/groestl.h | 0 {crypto => lib/crypto}/groestl_internal.h | 0 {crypto => lib/crypto}/hasher.c | 0 {crypto => lib/crypto}/hasher.h | 0 {crypto => lib/crypto}/hmac.c | 0 {crypto => lib/crypto}/hmac.h | 0 {crypto => lib/crypto}/hmac_drbg.c | 0 {crypto => lib/crypto}/hmac_drbg.h | 0 {crypto => lib/crypto}/memzero.c | 0 {crypto => lib/crypto}/memzero.h | 0 {crypto => lib/crypto}/monero/base58.c | 0 {crypto => lib/crypto}/monero/base58.h | 0 {crypto => lib/crypto}/monero/int_util.h | 0 {crypto => lib/crypto}/monero/monero.h | 0 {crypto => lib/crypto}/monero/serialize.c | 0 {crypto => lib/crypto}/monero/serialize.h | 0 {crypto => lib/crypto}/monero/xmr.c | 0 {crypto => lib/crypto}/monero/xmr.h | 0 {crypto => lib/crypto}/nem.c | 0 {crypto => lib/crypto}/nem.h | 0 {crypto => lib/crypto}/nist256p1.c | 0 {crypto => lib/crypto}/nist256p1.h | 0 {crypto => lib/crypto}/nist256p1.table | 0 {crypto => lib/crypto}/options.h | 0 {crypto => lib/crypto}/pbkdf2.c | 0 {crypto => lib/crypto}/pbkdf2.h | 0 {crypto => lib/crypto}/rand.c | 0 {crypto => lib/crypto}/rand.h | 0 {crypto => lib/crypto}/rc4.c | 0 {crypto => lib/crypto}/rc4.h | 0 {crypto => lib/crypto}/rfc6979.c | 0 {crypto => lib/crypto}/rfc6979.h | 0 {crypto => lib/crypto}/ripemd160.c | 0 {crypto => lib/crypto}/ripemd160.h | 0 {crypto => lib/crypto}/script.c | 0 {crypto => lib/crypto}/script.h | 0 {crypto => lib/crypto}/secp256k1.c | 0 {crypto => lib/crypto}/secp256k1.h | 0 {crypto => lib/crypto}/secp256k1.table | 0 {crypto => lib/crypto}/segwit_addr.c | 0 {crypto => lib/crypto}/segwit_addr.h | 0 {crypto => lib/crypto}/setup.py | 0 {crypto => lib/crypto}/sha2.c | 0 {crypto => lib/crypto}/sha2.h | 0 {crypto => lib/crypto}/sha3.c | 0 {crypto => lib/crypto}/sha3.h | 0 {crypto => lib/crypto}/shamir.c | 0 {crypto => lib/crypto}/shamir.h | 0 {crypto => lib/crypto}/slip39.c | 0 {crypto => lib/crypto}/slip39.h | 0 {crypto => lib/crypto}/slip39_wordlist.h | 0 scenes/flipbip_scene_settings.c | 3 ++- views/flipbip_scene_1.c | 14 +++++++------- 145 files changed, 24 insertions(+), 21 deletions(-) rename {crypto => lib/crypto}/AUTHORS (100%) rename {crypto => lib/crypto}/CONTRIBUTORS (100%) rename {crypto => lib/crypto}/LICENSE (100%) rename {crypto => lib/crypto}/Makefile (100%) rename {crypto => lib/crypto}/README.md (100%) rename {crypto => lib/crypto}/address.c (100%) rename {crypto => lib/crypto}/address.h (100%) rename {crypto => lib/crypto}/aes/aes.h (100%) rename {crypto => lib/crypto}/aes/aes_modes.c (100%) rename {crypto => lib/crypto}/aes/aescrypt.c (100%) rename {crypto => lib/crypto}/aes/aeskey.c (100%) rename {crypto => lib/crypto}/aes/aesopt.h (100%) rename {crypto => lib/crypto}/aes/aestab.c (100%) rename {crypto => lib/crypto}/aes/aestab.h (100%) rename {crypto => lib/crypto}/aes/aestst.c (100%) rename {crypto => lib/crypto}/aes/aestst.h (100%) rename {crypto => lib/crypto}/base32.c (100%) rename {crypto => lib/crypto}/base32.h (100%) rename {crypto => lib/crypto}/base58.c (100%) rename {crypto => lib/crypto}/base58.h (100%) rename {crypto => lib/crypto}/bignum.c (100%) rename {crypto => lib/crypto}/bignum.h (100%) rename {crypto => lib/crypto}/bip32.c (100%) rename {crypto => lib/crypto}/bip32.h (100%) rename {crypto => lib/crypto}/bip39.c (100%) rename {crypto => lib/crypto}/bip39.h (100%) rename {crypto => lib/crypto}/bip39_english.c (100%) rename {crypto => lib/crypto}/blake256.c (100%) rename {crypto => lib/crypto}/blake256.h (100%) rename {crypto => lib/crypto}/blake2_common.h (100%) rename {crypto => lib/crypto}/blake2b.c (100%) rename {crypto => lib/crypto}/blake2b.h (100%) rename {crypto => lib/crypto}/blake2s.c (100%) rename {crypto => lib/crypto}/blake2s.h (100%) rename {crypto => lib/crypto}/byte_order.h (100%) rename {crypto => lib/crypto}/cardano.c (100%) rename {crypto => lib/crypto}/cardano.h (100%) rename {crypto => lib/crypto}/cash_addr.c (100%) rename {crypto => lib/crypto}/cash_addr.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/LICENSE (100%) rename {crypto => lib/crypto}/chacha20poly1305/chacha20poly1305.c (100%) rename {crypto => lib/crypto}/chacha20poly1305/chacha20poly1305.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/chacha_merged.c (100%) rename {crypto => lib/crypto}/chacha20poly1305/ecrypt_config.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/ecrypt_machine.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/ecrypt_portable.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/ecrypt_sync.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/ecrypt_types.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/poly1305_donna.c (100%) rename {crypto => lib/crypto}/chacha20poly1305/poly1305_donna.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/poly1305_donna_32.h (100%) rename {crypto => lib/crypto}/chacha20poly1305/rfc7539.c (100%) rename {crypto => lib/crypto}/chacha20poly1305/rfc7539.h (100%) rename {crypto => lib/crypto}/chacha_drbg.c (100%) rename {crypto => lib/crypto}/chacha_drbg.h (100%) rename {crypto => lib/crypto}/check_mem.h (100%) rename {crypto => lib/crypto}/curves.c (100%) rename {crypto => lib/crypto}/curves.h (100%) rename {crypto => lib/crypto}/ecdsa.c (100%) rename {crypto => lib/crypto}/ecdsa.h (100%) rename {crypto => lib/crypto}/ed25519_donna/README.md (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_32bit.c (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_32bit.h (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_helpers.c (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_helpers.h (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_scalarmult_base.c (100%) rename {crypto => lib/crypto}/ed25519_donna/curve25519_donna_scalarmult_base.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_32bit_tables.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_32bit_tables.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_basepoint_table.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_basepoint_table.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_impl_base.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_impl_base.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_donna_portable.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_hash_custom.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_hash_custom_keccak.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_hash_custom_sha3.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_keccak.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_keccak.h (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_sha3.c (100%) rename {crypto => lib/crypto}/ed25519_donna/ed25519_sha3.h (100%) rename {crypto => lib/crypto}/ed25519_donna/modm_donna_32bit.c (100%) rename {crypto => lib/crypto}/ed25519_donna/modm_donna_32bit.h (100%) rename {crypto => lib/crypto}/groestl.c (100%) rename {crypto => lib/crypto}/groestl.h (100%) rename {crypto => lib/crypto}/groestl_internal.h (100%) rename {crypto => lib/crypto}/hasher.c (100%) rename {crypto => lib/crypto}/hasher.h (100%) rename {crypto => lib/crypto}/hmac.c (100%) rename {crypto => lib/crypto}/hmac.h (100%) rename {crypto => lib/crypto}/hmac_drbg.c (100%) rename {crypto => lib/crypto}/hmac_drbg.h (100%) rename {crypto => lib/crypto}/memzero.c (100%) rename {crypto => lib/crypto}/memzero.h (100%) rename {crypto => lib/crypto}/monero/base58.c (100%) rename {crypto => lib/crypto}/monero/base58.h (100%) rename {crypto => lib/crypto}/monero/int_util.h (100%) rename {crypto => lib/crypto}/monero/monero.h (100%) rename {crypto => lib/crypto}/monero/serialize.c (100%) rename {crypto => lib/crypto}/monero/serialize.h (100%) rename {crypto => lib/crypto}/monero/xmr.c (100%) rename {crypto => lib/crypto}/monero/xmr.h (100%) rename {crypto => lib/crypto}/nem.c (100%) rename {crypto => lib/crypto}/nem.h (100%) rename {crypto => lib/crypto}/nist256p1.c (100%) rename {crypto => lib/crypto}/nist256p1.h (100%) rename {crypto => lib/crypto}/nist256p1.table (100%) rename {crypto => lib/crypto}/options.h (100%) rename {crypto => lib/crypto}/pbkdf2.c (100%) rename {crypto => lib/crypto}/pbkdf2.h (100%) rename {crypto => lib/crypto}/rand.c (100%) rename {crypto => lib/crypto}/rand.h (100%) rename {crypto => lib/crypto}/rc4.c (100%) rename {crypto => lib/crypto}/rc4.h (100%) rename {crypto => lib/crypto}/rfc6979.c (100%) rename {crypto => lib/crypto}/rfc6979.h (100%) rename {crypto => lib/crypto}/ripemd160.c (100%) rename {crypto => lib/crypto}/ripemd160.h (100%) rename {crypto => lib/crypto}/script.c (100%) rename {crypto => lib/crypto}/script.h (100%) rename {crypto => lib/crypto}/secp256k1.c (100%) rename {crypto => lib/crypto}/secp256k1.h (100%) rename {crypto => lib/crypto}/secp256k1.table (100%) rename {crypto => lib/crypto}/segwit_addr.c (100%) rename {crypto => lib/crypto}/segwit_addr.h (100%) rename {crypto => lib/crypto}/setup.py (100%) rename {crypto => lib/crypto}/sha2.c (100%) rename {crypto => lib/crypto}/sha2.h (100%) rename {crypto => lib/crypto}/sha3.c (100%) rename {crypto => lib/crypto}/sha3.h (100%) rename {crypto => lib/crypto}/shamir.c (100%) rename {crypto => lib/crypto}/shamir.h (100%) rename {crypto => lib/crypto}/slip39.c (100%) rename {crypto => lib/crypto}/slip39.h (100%) rename {crypto => lib/crypto}/slip39_wordlist.h (100%) diff --git a/application.fam b/application.fam index 019865ecf82..c539e9b0b8a 100644 --- a/application.fam +++ b/application.fam @@ -11,6 +11,11 @@ App( order=10, fap_icon="flipbip_10px.png", fap_icon_assets="icons", + fap_private_libs=[ + Lib( + name="crypto", + ), + ], fap_category="Misc", fap_description="Crypto toolkit for Flipper", fap_author="Struan Clark (xtruan)", diff --git a/flipbip.c b/flipbip.c index 9678e0c42a0..2682ac2e10b 100644 --- a/flipbip.c +++ b/flipbip.c @@ -1,8 +1,9 @@ #include "flipbip.h" -#include "crypto/memzero.h" -#include "crypto/bip39.h" #include "helpers/flipbip_file.h" #include "helpers/flipbip_haptic.h" +// From: lib/crypto +#include +#include bool flipbip_custom_event_callback(void* context, uint32_t event) { furi_assert(context); diff --git a/helpers/flipbip_file.c b/helpers/flipbip_file.c index bb8e6aa9583..4d973999fc8 100644 --- a/helpers/flipbip_file.c +++ b/helpers/flipbip_file.c @@ -1,10 +1,9 @@ #include "flipbip_file.h" -#include "../helpers/flipbip_string.h" - -#include "../crypto/memzero.h" -#include "../crypto/rand.h" - #include +#include "../helpers/flipbip_string.h" +// From: lib/crypto +#include +#include #define FLIPBIP_APP_BASE_FOLDER EXT_PATH("apps_data/flipbip") #define FLIPBIP_DAT_FILE_NAME ".flipbip.dat" diff --git a/helpers/flipbip_led.h b/helpers/flipbip_led.h index ba662d26a98..bbacc976b6a 100644 --- a/helpers/flipbip_led.h +++ b/helpers/flipbip_led.h @@ -1,5 +1,2 @@ - - void flipbip_led_set_rgb(void* context, int red, int green, int blue); - void flipbip_led_reset(void* context); diff --git a/helpers/flipbip_string.c b/helpers/flipbip_string.c index 3b2ea81c4f5..99982064698 100644 --- a/helpers/flipbip_string.c +++ b/helpers/flipbip_string.c @@ -30,9 +30,9 @@ #include #include #include - -#include "../crypto/memzero.h" -#include "../crypto/rc4.h" +// From: lib/crypto +#include +#include char* flipbip_strtok(char* s, const char* delim) { static char* last; diff --git a/crypto/AUTHORS b/lib/crypto/AUTHORS similarity index 100% rename from crypto/AUTHORS rename to lib/crypto/AUTHORS diff --git a/crypto/CONTRIBUTORS b/lib/crypto/CONTRIBUTORS similarity index 100% rename from crypto/CONTRIBUTORS rename to lib/crypto/CONTRIBUTORS diff --git a/crypto/LICENSE b/lib/crypto/LICENSE similarity index 100% rename from crypto/LICENSE rename to lib/crypto/LICENSE diff --git a/crypto/Makefile b/lib/crypto/Makefile similarity index 100% rename from crypto/Makefile rename to lib/crypto/Makefile diff --git a/crypto/README.md b/lib/crypto/README.md similarity index 100% rename from crypto/README.md rename to lib/crypto/README.md diff --git a/crypto/address.c b/lib/crypto/address.c similarity index 100% rename from crypto/address.c rename to lib/crypto/address.c diff --git a/crypto/address.h b/lib/crypto/address.h similarity index 100% rename from crypto/address.h rename to lib/crypto/address.h diff --git a/crypto/aes/aes.h b/lib/crypto/aes/aes.h similarity index 100% rename from crypto/aes/aes.h rename to lib/crypto/aes/aes.h diff --git a/crypto/aes/aes_modes.c b/lib/crypto/aes/aes_modes.c similarity index 100% rename from crypto/aes/aes_modes.c rename to lib/crypto/aes/aes_modes.c diff --git a/crypto/aes/aescrypt.c b/lib/crypto/aes/aescrypt.c similarity index 100% rename from crypto/aes/aescrypt.c rename to lib/crypto/aes/aescrypt.c diff --git a/crypto/aes/aeskey.c b/lib/crypto/aes/aeskey.c similarity index 100% rename from crypto/aes/aeskey.c rename to lib/crypto/aes/aeskey.c diff --git a/crypto/aes/aesopt.h b/lib/crypto/aes/aesopt.h similarity index 100% rename from crypto/aes/aesopt.h rename to lib/crypto/aes/aesopt.h diff --git a/crypto/aes/aestab.c b/lib/crypto/aes/aestab.c similarity index 100% rename from crypto/aes/aestab.c rename to lib/crypto/aes/aestab.c diff --git a/crypto/aes/aestab.h b/lib/crypto/aes/aestab.h similarity index 100% rename from crypto/aes/aestab.h rename to lib/crypto/aes/aestab.h diff --git a/crypto/aes/aestst.c b/lib/crypto/aes/aestst.c similarity index 100% rename from crypto/aes/aestst.c rename to lib/crypto/aes/aestst.c diff --git a/crypto/aes/aestst.h b/lib/crypto/aes/aestst.h similarity index 100% rename from crypto/aes/aestst.h rename to lib/crypto/aes/aestst.h diff --git a/crypto/base32.c b/lib/crypto/base32.c similarity index 100% rename from crypto/base32.c rename to lib/crypto/base32.c diff --git a/crypto/base32.h b/lib/crypto/base32.h similarity index 100% rename from crypto/base32.h rename to lib/crypto/base32.h diff --git a/crypto/base58.c b/lib/crypto/base58.c similarity index 100% rename from crypto/base58.c rename to lib/crypto/base58.c diff --git a/crypto/base58.h b/lib/crypto/base58.h similarity index 100% rename from crypto/base58.h rename to lib/crypto/base58.h diff --git a/crypto/bignum.c b/lib/crypto/bignum.c similarity index 100% rename from crypto/bignum.c rename to lib/crypto/bignum.c diff --git a/crypto/bignum.h b/lib/crypto/bignum.h similarity index 100% rename from crypto/bignum.h rename to lib/crypto/bignum.h diff --git a/crypto/bip32.c b/lib/crypto/bip32.c similarity index 100% rename from crypto/bip32.c rename to lib/crypto/bip32.c diff --git a/crypto/bip32.h b/lib/crypto/bip32.h similarity index 100% rename from crypto/bip32.h rename to lib/crypto/bip32.h diff --git a/crypto/bip39.c b/lib/crypto/bip39.c similarity index 100% rename from crypto/bip39.c rename to lib/crypto/bip39.c diff --git a/crypto/bip39.h b/lib/crypto/bip39.h similarity index 100% rename from crypto/bip39.h rename to lib/crypto/bip39.h diff --git a/crypto/bip39_english.c b/lib/crypto/bip39_english.c similarity index 100% rename from crypto/bip39_english.c rename to lib/crypto/bip39_english.c diff --git a/crypto/blake256.c b/lib/crypto/blake256.c similarity index 100% rename from crypto/blake256.c rename to lib/crypto/blake256.c diff --git a/crypto/blake256.h b/lib/crypto/blake256.h similarity index 100% rename from crypto/blake256.h rename to lib/crypto/blake256.h diff --git a/crypto/blake2_common.h b/lib/crypto/blake2_common.h similarity index 100% rename from crypto/blake2_common.h rename to lib/crypto/blake2_common.h diff --git a/crypto/blake2b.c b/lib/crypto/blake2b.c similarity index 100% rename from crypto/blake2b.c rename to lib/crypto/blake2b.c diff --git a/crypto/blake2b.h b/lib/crypto/blake2b.h similarity index 100% rename from crypto/blake2b.h rename to lib/crypto/blake2b.h diff --git a/crypto/blake2s.c b/lib/crypto/blake2s.c similarity index 100% rename from crypto/blake2s.c rename to lib/crypto/blake2s.c diff --git a/crypto/blake2s.h b/lib/crypto/blake2s.h similarity index 100% rename from crypto/blake2s.h rename to lib/crypto/blake2s.h diff --git a/crypto/byte_order.h b/lib/crypto/byte_order.h similarity index 100% rename from crypto/byte_order.h rename to lib/crypto/byte_order.h diff --git a/crypto/cardano.c b/lib/crypto/cardano.c similarity index 100% rename from crypto/cardano.c rename to lib/crypto/cardano.c diff --git a/crypto/cardano.h b/lib/crypto/cardano.h similarity index 100% rename from crypto/cardano.h rename to lib/crypto/cardano.h diff --git a/crypto/cash_addr.c b/lib/crypto/cash_addr.c similarity index 100% rename from crypto/cash_addr.c rename to lib/crypto/cash_addr.c diff --git a/crypto/cash_addr.h b/lib/crypto/cash_addr.h similarity index 100% rename from crypto/cash_addr.h rename to lib/crypto/cash_addr.h diff --git a/crypto/chacha20poly1305/LICENSE b/lib/crypto/chacha20poly1305/LICENSE similarity index 100% rename from crypto/chacha20poly1305/LICENSE rename to lib/crypto/chacha20poly1305/LICENSE diff --git a/crypto/chacha20poly1305/chacha20poly1305.c b/lib/crypto/chacha20poly1305/chacha20poly1305.c similarity index 100% rename from crypto/chacha20poly1305/chacha20poly1305.c rename to lib/crypto/chacha20poly1305/chacha20poly1305.c diff --git a/crypto/chacha20poly1305/chacha20poly1305.h b/lib/crypto/chacha20poly1305/chacha20poly1305.h similarity index 100% rename from crypto/chacha20poly1305/chacha20poly1305.h rename to lib/crypto/chacha20poly1305/chacha20poly1305.h diff --git a/crypto/chacha20poly1305/chacha_merged.c b/lib/crypto/chacha20poly1305/chacha_merged.c similarity index 100% rename from crypto/chacha20poly1305/chacha_merged.c rename to lib/crypto/chacha20poly1305/chacha_merged.c diff --git a/crypto/chacha20poly1305/ecrypt_config.h b/lib/crypto/chacha20poly1305/ecrypt_config.h similarity index 100% rename from crypto/chacha20poly1305/ecrypt_config.h rename to lib/crypto/chacha20poly1305/ecrypt_config.h diff --git a/crypto/chacha20poly1305/ecrypt_machine.h b/lib/crypto/chacha20poly1305/ecrypt_machine.h similarity index 100% rename from crypto/chacha20poly1305/ecrypt_machine.h rename to lib/crypto/chacha20poly1305/ecrypt_machine.h diff --git a/crypto/chacha20poly1305/ecrypt_portable.h b/lib/crypto/chacha20poly1305/ecrypt_portable.h similarity index 100% rename from crypto/chacha20poly1305/ecrypt_portable.h rename to lib/crypto/chacha20poly1305/ecrypt_portable.h diff --git a/crypto/chacha20poly1305/ecrypt_sync.h b/lib/crypto/chacha20poly1305/ecrypt_sync.h similarity index 100% rename from crypto/chacha20poly1305/ecrypt_sync.h rename to lib/crypto/chacha20poly1305/ecrypt_sync.h diff --git a/crypto/chacha20poly1305/ecrypt_types.h b/lib/crypto/chacha20poly1305/ecrypt_types.h similarity index 100% rename from crypto/chacha20poly1305/ecrypt_types.h rename to lib/crypto/chacha20poly1305/ecrypt_types.h diff --git a/crypto/chacha20poly1305/poly1305_donna.c b/lib/crypto/chacha20poly1305/poly1305_donna.c similarity index 100% rename from crypto/chacha20poly1305/poly1305_donna.c rename to lib/crypto/chacha20poly1305/poly1305_donna.c diff --git a/crypto/chacha20poly1305/poly1305_donna.h b/lib/crypto/chacha20poly1305/poly1305_donna.h similarity index 100% rename from crypto/chacha20poly1305/poly1305_donna.h rename to lib/crypto/chacha20poly1305/poly1305_donna.h diff --git a/crypto/chacha20poly1305/poly1305_donna_32.h b/lib/crypto/chacha20poly1305/poly1305_donna_32.h similarity index 100% rename from crypto/chacha20poly1305/poly1305_donna_32.h rename to lib/crypto/chacha20poly1305/poly1305_donna_32.h diff --git a/crypto/chacha20poly1305/rfc7539.c b/lib/crypto/chacha20poly1305/rfc7539.c similarity index 100% rename from crypto/chacha20poly1305/rfc7539.c rename to lib/crypto/chacha20poly1305/rfc7539.c diff --git a/crypto/chacha20poly1305/rfc7539.h b/lib/crypto/chacha20poly1305/rfc7539.h similarity index 100% rename from crypto/chacha20poly1305/rfc7539.h rename to lib/crypto/chacha20poly1305/rfc7539.h diff --git a/crypto/chacha_drbg.c b/lib/crypto/chacha_drbg.c similarity index 100% rename from crypto/chacha_drbg.c rename to lib/crypto/chacha_drbg.c diff --git a/crypto/chacha_drbg.h b/lib/crypto/chacha_drbg.h similarity index 100% rename from crypto/chacha_drbg.h rename to lib/crypto/chacha_drbg.h diff --git a/crypto/check_mem.h b/lib/crypto/check_mem.h similarity index 100% rename from crypto/check_mem.h rename to lib/crypto/check_mem.h diff --git a/crypto/curves.c b/lib/crypto/curves.c similarity index 100% rename from crypto/curves.c rename to lib/crypto/curves.c diff --git a/crypto/curves.h b/lib/crypto/curves.h similarity index 100% rename from crypto/curves.h rename to lib/crypto/curves.h diff --git a/crypto/ecdsa.c b/lib/crypto/ecdsa.c similarity index 100% rename from crypto/ecdsa.c rename to lib/crypto/ecdsa.c diff --git a/crypto/ecdsa.h b/lib/crypto/ecdsa.h similarity index 100% rename from crypto/ecdsa.h rename to lib/crypto/ecdsa.h diff --git a/crypto/ed25519_donna/README.md b/lib/crypto/ed25519_donna/README.md similarity index 100% rename from crypto/ed25519_donna/README.md rename to lib/crypto/ed25519_donna/README.md diff --git a/crypto/ed25519_donna/curve25519_donna_32bit.c b/lib/crypto/ed25519_donna/curve25519_donna_32bit.c similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_32bit.c rename to lib/crypto/ed25519_donna/curve25519_donna_32bit.c diff --git a/crypto/ed25519_donna/curve25519_donna_32bit.h b/lib/crypto/ed25519_donna/curve25519_donna_32bit.h similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_32bit.h rename to lib/crypto/ed25519_donna/curve25519_donna_32bit.h diff --git a/crypto/ed25519_donna/curve25519_donna_helpers.c b/lib/crypto/ed25519_donna/curve25519_donna_helpers.c similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_helpers.c rename to lib/crypto/ed25519_donna/curve25519_donna_helpers.c diff --git a/crypto/ed25519_donna/curve25519_donna_helpers.h b/lib/crypto/ed25519_donna/curve25519_donna_helpers.h similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_helpers.h rename to lib/crypto/ed25519_donna/curve25519_donna_helpers.h diff --git a/crypto/ed25519_donna/curve25519_donna_scalarmult_base.c b/lib/crypto/ed25519_donna/curve25519_donna_scalarmult_base.c similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_scalarmult_base.c rename to lib/crypto/ed25519_donna/curve25519_donna_scalarmult_base.c diff --git a/crypto/ed25519_donna/curve25519_donna_scalarmult_base.h b/lib/crypto/ed25519_donna/curve25519_donna_scalarmult_base.h similarity index 100% rename from crypto/ed25519_donna/curve25519_donna_scalarmult_base.h rename to lib/crypto/ed25519_donna/curve25519_donna_scalarmult_base.h diff --git a/crypto/ed25519_donna/ed25519.c b/lib/crypto/ed25519_donna/ed25519.c similarity index 100% rename from crypto/ed25519_donna/ed25519.c rename to lib/crypto/ed25519_donna/ed25519.c diff --git a/crypto/ed25519_donna/ed25519.h b/lib/crypto/ed25519_donna/ed25519.h similarity index 100% rename from crypto/ed25519_donna/ed25519.h rename to lib/crypto/ed25519_donna/ed25519.h diff --git a/crypto/ed25519_donna/ed25519_donna.h b/lib/crypto/ed25519_donna/ed25519_donna.h similarity index 100% rename from crypto/ed25519_donna/ed25519_donna.h rename to lib/crypto/ed25519_donna/ed25519_donna.h diff --git a/crypto/ed25519_donna/ed25519_donna_32bit_tables.c b/lib/crypto/ed25519_donna/ed25519_donna_32bit_tables.c similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_32bit_tables.c rename to lib/crypto/ed25519_donna/ed25519_donna_32bit_tables.c diff --git a/crypto/ed25519_donna/ed25519_donna_32bit_tables.h b/lib/crypto/ed25519_donna/ed25519_donna_32bit_tables.h similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_32bit_tables.h rename to lib/crypto/ed25519_donna/ed25519_donna_32bit_tables.h diff --git a/crypto/ed25519_donna/ed25519_donna_basepoint_table.c b/lib/crypto/ed25519_donna/ed25519_donna_basepoint_table.c similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_basepoint_table.c rename to lib/crypto/ed25519_donna/ed25519_donna_basepoint_table.c diff --git a/crypto/ed25519_donna/ed25519_donna_basepoint_table.h b/lib/crypto/ed25519_donna/ed25519_donna_basepoint_table.h similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_basepoint_table.h rename to lib/crypto/ed25519_donna/ed25519_donna_basepoint_table.h diff --git a/crypto/ed25519_donna/ed25519_donna_impl_base.c b/lib/crypto/ed25519_donna/ed25519_donna_impl_base.c similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_impl_base.c rename to lib/crypto/ed25519_donna/ed25519_donna_impl_base.c diff --git a/crypto/ed25519_donna/ed25519_donna_impl_base.h b/lib/crypto/ed25519_donna/ed25519_donna_impl_base.h similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_impl_base.h rename to lib/crypto/ed25519_donna/ed25519_donna_impl_base.h diff --git a/crypto/ed25519_donna/ed25519_donna_portable.h b/lib/crypto/ed25519_donna/ed25519_donna_portable.h similarity index 100% rename from crypto/ed25519_donna/ed25519_donna_portable.h rename to lib/crypto/ed25519_donna/ed25519_donna_portable.h diff --git a/crypto/ed25519_donna/ed25519_hash_custom.h b/lib/crypto/ed25519_donna/ed25519_hash_custom.h similarity index 100% rename from crypto/ed25519_donna/ed25519_hash_custom.h rename to lib/crypto/ed25519_donna/ed25519_hash_custom.h diff --git a/crypto/ed25519_donna/ed25519_hash_custom_keccak.h b/lib/crypto/ed25519_donna/ed25519_hash_custom_keccak.h similarity index 100% rename from crypto/ed25519_donna/ed25519_hash_custom_keccak.h rename to lib/crypto/ed25519_donna/ed25519_hash_custom_keccak.h diff --git a/crypto/ed25519_donna/ed25519_hash_custom_sha3.h b/lib/crypto/ed25519_donna/ed25519_hash_custom_sha3.h similarity index 100% rename from crypto/ed25519_donna/ed25519_hash_custom_sha3.h rename to lib/crypto/ed25519_donna/ed25519_hash_custom_sha3.h diff --git a/crypto/ed25519_donna/ed25519_keccak.c b/lib/crypto/ed25519_donna/ed25519_keccak.c similarity index 100% rename from crypto/ed25519_donna/ed25519_keccak.c rename to lib/crypto/ed25519_donna/ed25519_keccak.c diff --git a/crypto/ed25519_donna/ed25519_keccak.h b/lib/crypto/ed25519_donna/ed25519_keccak.h similarity index 100% rename from crypto/ed25519_donna/ed25519_keccak.h rename to lib/crypto/ed25519_donna/ed25519_keccak.h diff --git a/crypto/ed25519_donna/ed25519_sha3.c b/lib/crypto/ed25519_donna/ed25519_sha3.c similarity index 100% rename from crypto/ed25519_donna/ed25519_sha3.c rename to lib/crypto/ed25519_donna/ed25519_sha3.c diff --git a/crypto/ed25519_donna/ed25519_sha3.h b/lib/crypto/ed25519_donna/ed25519_sha3.h similarity index 100% rename from crypto/ed25519_donna/ed25519_sha3.h rename to lib/crypto/ed25519_donna/ed25519_sha3.h diff --git a/crypto/ed25519_donna/modm_donna_32bit.c b/lib/crypto/ed25519_donna/modm_donna_32bit.c similarity index 100% rename from crypto/ed25519_donna/modm_donna_32bit.c rename to lib/crypto/ed25519_donna/modm_donna_32bit.c diff --git a/crypto/ed25519_donna/modm_donna_32bit.h b/lib/crypto/ed25519_donna/modm_donna_32bit.h similarity index 100% rename from crypto/ed25519_donna/modm_donna_32bit.h rename to lib/crypto/ed25519_donna/modm_donna_32bit.h diff --git a/crypto/groestl.c b/lib/crypto/groestl.c similarity index 100% rename from crypto/groestl.c rename to lib/crypto/groestl.c diff --git a/crypto/groestl.h b/lib/crypto/groestl.h similarity index 100% rename from crypto/groestl.h rename to lib/crypto/groestl.h diff --git a/crypto/groestl_internal.h b/lib/crypto/groestl_internal.h similarity index 100% rename from crypto/groestl_internal.h rename to lib/crypto/groestl_internal.h diff --git a/crypto/hasher.c b/lib/crypto/hasher.c similarity index 100% rename from crypto/hasher.c rename to lib/crypto/hasher.c diff --git a/crypto/hasher.h b/lib/crypto/hasher.h similarity index 100% rename from crypto/hasher.h rename to lib/crypto/hasher.h diff --git a/crypto/hmac.c b/lib/crypto/hmac.c similarity index 100% rename from crypto/hmac.c rename to lib/crypto/hmac.c diff --git a/crypto/hmac.h b/lib/crypto/hmac.h similarity index 100% rename from crypto/hmac.h rename to lib/crypto/hmac.h diff --git a/crypto/hmac_drbg.c b/lib/crypto/hmac_drbg.c similarity index 100% rename from crypto/hmac_drbg.c rename to lib/crypto/hmac_drbg.c diff --git a/crypto/hmac_drbg.h b/lib/crypto/hmac_drbg.h similarity index 100% rename from crypto/hmac_drbg.h rename to lib/crypto/hmac_drbg.h diff --git a/crypto/memzero.c b/lib/crypto/memzero.c similarity index 100% rename from crypto/memzero.c rename to lib/crypto/memzero.c diff --git a/crypto/memzero.h b/lib/crypto/memzero.h similarity index 100% rename from crypto/memzero.h rename to lib/crypto/memzero.h diff --git a/crypto/monero/base58.c b/lib/crypto/monero/base58.c similarity index 100% rename from crypto/monero/base58.c rename to lib/crypto/monero/base58.c diff --git a/crypto/monero/base58.h b/lib/crypto/monero/base58.h similarity index 100% rename from crypto/monero/base58.h rename to lib/crypto/monero/base58.h diff --git a/crypto/monero/int_util.h b/lib/crypto/monero/int_util.h similarity index 100% rename from crypto/monero/int_util.h rename to lib/crypto/monero/int_util.h diff --git a/crypto/monero/monero.h b/lib/crypto/monero/monero.h similarity index 100% rename from crypto/monero/monero.h rename to lib/crypto/monero/monero.h diff --git a/crypto/monero/serialize.c b/lib/crypto/monero/serialize.c similarity index 100% rename from crypto/monero/serialize.c rename to lib/crypto/monero/serialize.c diff --git a/crypto/monero/serialize.h b/lib/crypto/monero/serialize.h similarity index 100% rename from crypto/monero/serialize.h rename to lib/crypto/monero/serialize.h diff --git a/crypto/monero/xmr.c b/lib/crypto/monero/xmr.c similarity index 100% rename from crypto/monero/xmr.c rename to lib/crypto/monero/xmr.c diff --git a/crypto/monero/xmr.h b/lib/crypto/monero/xmr.h similarity index 100% rename from crypto/monero/xmr.h rename to lib/crypto/monero/xmr.h diff --git a/crypto/nem.c b/lib/crypto/nem.c similarity index 100% rename from crypto/nem.c rename to lib/crypto/nem.c diff --git a/crypto/nem.h b/lib/crypto/nem.h similarity index 100% rename from crypto/nem.h rename to lib/crypto/nem.h diff --git a/crypto/nist256p1.c b/lib/crypto/nist256p1.c similarity index 100% rename from crypto/nist256p1.c rename to lib/crypto/nist256p1.c diff --git a/crypto/nist256p1.h b/lib/crypto/nist256p1.h similarity index 100% rename from crypto/nist256p1.h rename to lib/crypto/nist256p1.h diff --git a/crypto/nist256p1.table b/lib/crypto/nist256p1.table similarity index 100% rename from crypto/nist256p1.table rename to lib/crypto/nist256p1.table diff --git a/crypto/options.h b/lib/crypto/options.h similarity index 100% rename from crypto/options.h rename to lib/crypto/options.h diff --git a/crypto/pbkdf2.c b/lib/crypto/pbkdf2.c similarity index 100% rename from crypto/pbkdf2.c rename to lib/crypto/pbkdf2.c diff --git a/crypto/pbkdf2.h b/lib/crypto/pbkdf2.h similarity index 100% rename from crypto/pbkdf2.h rename to lib/crypto/pbkdf2.h diff --git a/crypto/rand.c b/lib/crypto/rand.c similarity index 100% rename from crypto/rand.c rename to lib/crypto/rand.c diff --git a/crypto/rand.h b/lib/crypto/rand.h similarity index 100% rename from crypto/rand.h rename to lib/crypto/rand.h diff --git a/crypto/rc4.c b/lib/crypto/rc4.c similarity index 100% rename from crypto/rc4.c rename to lib/crypto/rc4.c diff --git a/crypto/rc4.h b/lib/crypto/rc4.h similarity index 100% rename from crypto/rc4.h rename to lib/crypto/rc4.h diff --git a/crypto/rfc6979.c b/lib/crypto/rfc6979.c similarity index 100% rename from crypto/rfc6979.c rename to lib/crypto/rfc6979.c diff --git a/crypto/rfc6979.h b/lib/crypto/rfc6979.h similarity index 100% rename from crypto/rfc6979.h rename to lib/crypto/rfc6979.h diff --git a/crypto/ripemd160.c b/lib/crypto/ripemd160.c similarity index 100% rename from crypto/ripemd160.c rename to lib/crypto/ripemd160.c diff --git a/crypto/ripemd160.h b/lib/crypto/ripemd160.h similarity index 100% rename from crypto/ripemd160.h rename to lib/crypto/ripemd160.h diff --git a/crypto/script.c b/lib/crypto/script.c similarity index 100% rename from crypto/script.c rename to lib/crypto/script.c diff --git a/crypto/script.h b/lib/crypto/script.h similarity index 100% rename from crypto/script.h rename to lib/crypto/script.h diff --git a/crypto/secp256k1.c b/lib/crypto/secp256k1.c similarity index 100% rename from crypto/secp256k1.c rename to lib/crypto/secp256k1.c diff --git a/crypto/secp256k1.h b/lib/crypto/secp256k1.h similarity index 100% rename from crypto/secp256k1.h rename to lib/crypto/secp256k1.h diff --git a/crypto/secp256k1.table b/lib/crypto/secp256k1.table similarity index 100% rename from crypto/secp256k1.table rename to lib/crypto/secp256k1.table diff --git a/crypto/segwit_addr.c b/lib/crypto/segwit_addr.c similarity index 100% rename from crypto/segwit_addr.c rename to lib/crypto/segwit_addr.c diff --git a/crypto/segwit_addr.h b/lib/crypto/segwit_addr.h similarity index 100% rename from crypto/segwit_addr.h rename to lib/crypto/segwit_addr.h diff --git a/crypto/setup.py b/lib/crypto/setup.py similarity index 100% rename from crypto/setup.py rename to lib/crypto/setup.py diff --git a/crypto/sha2.c b/lib/crypto/sha2.c similarity index 100% rename from crypto/sha2.c rename to lib/crypto/sha2.c diff --git a/crypto/sha2.h b/lib/crypto/sha2.h similarity index 100% rename from crypto/sha2.h rename to lib/crypto/sha2.h diff --git a/crypto/sha3.c b/lib/crypto/sha3.c similarity index 100% rename from crypto/sha3.c rename to lib/crypto/sha3.c diff --git a/crypto/sha3.h b/lib/crypto/sha3.h similarity index 100% rename from crypto/sha3.h rename to lib/crypto/sha3.h diff --git a/crypto/shamir.c b/lib/crypto/shamir.c similarity index 100% rename from crypto/shamir.c rename to lib/crypto/shamir.c diff --git a/crypto/shamir.h b/lib/crypto/shamir.h similarity index 100% rename from crypto/shamir.h rename to lib/crypto/shamir.h diff --git a/crypto/slip39.c b/lib/crypto/slip39.c similarity index 100% rename from crypto/slip39.c rename to lib/crypto/slip39.c diff --git a/crypto/slip39.h b/lib/crypto/slip39.h similarity index 100% rename from crypto/slip39.h rename to lib/crypto/slip39.h diff --git a/crypto/slip39_wordlist.h b/lib/crypto/slip39_wordlist.h similarity index 100% rename from crypto/slip39_wordlist.h rename to lib/crypto/slip39_wordlist.h diff --git a/scenes/flipbip_scene_settings.c b/scenes/flipbip_scene_settings.c index c93c6d76c44..d858dc44cab 100644 --- a/scenes/flipbip_scene_settings.c +++ b/scenes/flipbip_scene_settings.c @@ -1,6 +1,7 @@ #include "../flipbip.h" -#include "../crypto/memzero.h" #include +// From: lib/crypto +#include const char* const haptic_text[2] = { "OFF", diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 6320d69e55b..374bcde19d0 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -5,18 +5,18 @@ #include //#include #include +#include #include "FlipBIP_icons.h" #include "../helpers/flipbip_haptic.h" #include "../helpers/flipbip_led.h" #include "../helpers/flipbip_string.h" #include "../helpers/flipbip_file.h" - -#include -#include "../crypto/rand.h" -#include "../crypto/bip32.h" -#include "../crypto/bip39.h" -#include "../crypto/curves.h" -#include "../crypto/memzero.h" +// From: /lib/crypto +#include +#include +#include +#include +#include #define DERIV_PURPOSE 44 #define DERIV_ACCOUNT 0 From c9aa93266d6ec19468bdfafa01422f0bc0da99ea Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sat, 11 Mar 2023 22:59:44 -0700 Subject: [PATCH 02/15] bump version --- flipbip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flipbip.h b/flipbip.h index 7460e996cac..6cf8f5fb805 100644 --- a/flipbip.h +++ b/flipbip.h @@ -15,7 +15,7 @@ #include "views/flipbip_startscreen.h" #include "views/flipbip_scene_1.h" -#define FLIPBIP_VERSION "v0.0.6" +#define FLIPBIP_VERSION "v0.0.7" #define COIN_BTC 0 #define COIN_DOGE 3 From d9407ea6d37d453e3f70dda0fd35989c98cb8a3a Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 00:35:16 -0700 Subject: [PATCH 03/15] qr gen prototype --- flipbip.h | 2 +- helpers/flipbip_file.c | 73 +++++++++++++++++++++++++------------ helpers/flipbip_file.h | 16 ++++++-- scenes/flipbip_scene_menu.c | 2 +- views/flipbip_scene_1.c | 61 +++++++++++++++++++++++-------- 5 files changed, 111 insertions(+), 43 deletions(-) diff --git a/flipbip.h b/flipbip.h index 6cf8f5fb805..08b173a8c9c 100644 --- a/flipbip.h +++ b/flipbip.h @@ -96,4 +96,4 @@ typedef enum { FlipBipStatusLoadError = 11, FlipBipStatusSaveError = 12, FlipBipStatusMnemonicCheckError = 13, -} FlipBipStatus; \ No newline at end of file +} FlipBipStatus; diff --git a/helpers/flipbip_file.c b/helpers/flipbip_file.c index 4d973999fc8..b7f060554a3 100644 --- a/helpers/flipbip_file.c +++ b/helpers/flipbip_file.c @@ -5,17 +5,19 @@ #include #include +// #define FLIPBIP_APP_BASE_FOLDER APP_DATA_PATH("flipbip") #define FLIPBIP_APP_BASE_FOLDER EXT_PATH("apps_data/flipbip") +#define FLIPBIP_APP_BASE_FOLDER_PATH(path) FLIPBIP_APP_BASE_FOLDER "/" path #define FLIPBIP_DAT_FILE_NAME ".flipbip.dat" // #define FLIPBIP_DAT_FILE_NAME ".flipbip.dat.txt" #define FLIPBIP_DAT_FILE_NAME_BAK ".flipbip.dat.bak" #define FLIPBIP_KEY_FILE_NAME ".flipbip.key" // #define FLIPBIP_KEY_FILE_NAME ".flipbip.key.txt" #define FLIPBIP_KEY_FILE_NAME_BAK ".flipbip.key.bak" -#define FLIPBIP_DAT_PATH FLIPBIP_APP_BASE_FOLDER "/" FLIPBIP_DAT_FILE_NAME -#define FLIPBIP_DAT_PATH_BAK FLIPBIP_APP_BASE_FOLDER "/" FLIPBIP_DAT_FILE_NAME_BAK -#define FLIPBIP_KEY_PATH FLIPBIP_APP_BASE_FOLDER "/" FLIPBIP_KEY_FILE_NAME -#define FLIPBIP_KEY_PATH_BAK FLIPBIP_APP_BASE_FOLDER "/" FLIPBIP_KEY_FILE_NAME_BAK +#define FLIPBIP_DAT_PATH FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_DAT_FILE_NAME) +#define FLIPBIP_DAT_PATH_BAK FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_DAT_FILE_NAME_BAK) +#define FLIPBIP_KEY_PATH FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME) +#define FLIPBIP_KEY_PATH_BAK FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME_BAK) const size_t FILE_HLEN = 4; const size_t FILE_KLEN = 256; @@ -24,13 +26,19 @@ const char* FILE_HSTR = "fb01"; const char* FILE_K1 = "fb0131d5cf688221c109163908ebe51debb46227c6cc8b37641910833222772a" "baefe6d9ceb651842260e0d1e05e3b90d15e7d5ffaaabc0207bf200a117793a2"; -bool flipbip_load_settings(char* settings, bool key_file) { +bool flipbip_load_settings(char* settings, const FlipBipFile file_type, const char* file_name) { bool ret = false; const char* path; - if(key_file) { + if(file_type == FlipBipFileKey) { path = FLIPBIP_KEY_PATH; - } else { + } else if(file_type == FlipBipFileDat) { path = FLIPBIP_DAT_PATH; + } else { + char path_buf[32] = {0}; + strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); + strcpy(path_buf + strlen(path_buf), "/"); + strcpy(path_buf + strlen(path_buf), file_name); + path = path_buf; } Storage* fs_api = furi_record_open(RECORD_STORAGE); @@ -73,13 +81,19 @@ bool flipbip_load_settings(char* settings, bool key_file) { return ret; } -bool flipbip_has_settings(bool key_file) { +bool flipbip_has_settings(const FlipBipFile file_type, const char* file_name) { bool ret = false; const char* path; - if(key_file) { + if(file_type == FlipBipFileKey) { path = FLIPBIP_KEY_PATH; - } else { + } else if(file_type == FlipBipFileDat) { path = FLIPBIP_DAT_PATH; + } else { + char path_buf[32] = {0}; + strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); + strcpy(path_buf + strlen(path_buf), "/"); + strcpy(path_buf + strlen(path_buf), file_name); + path = path_buf; } Storage* fs_api = furi_record_open(RECORD_STORAGE); @@ -91,16 +105,27 @@ bool flipbip_has_settings(bool key_file) { return ret; } -bool flipbip_save_settings(const char* settings, bool key_file, bool append) { +bool flipbip_save_settings( + const char* settings, + const FlipBipFile file_type, + const char* file_name, + const bool append) { bool ret = false; const char* path; const char* path_bak; - if(key_file) { + if(file_type == FlipBipFileKey) { path = FLIPBIP_KEY_PATH; path_bak = FLIPBIP_KEY_PATH_BAK; - } else { + } else if(file_type == FlipBipFileDat) { path = FLIPBIP_DAT_PATH; path_bak = FLIPBIP_DAT_PATH_BAK; + } else { + char path_buf[32] = {0}; + strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); + strcpy(path_buf + strlen(path_buf), "/"); + strcpy(path_buf + strlen(path_buf), file_name); + path = path_buf; + path_bak = NULL; } int open_mode = FSOM_OPEN_ALWAYS; if(append) { @@ -126,13 +151,15 @@ bool flipbip_save_settings(const char* settings, bool key_file, bool append) { storage_file_close(settings_file); storage_file_free(settings_file); - File* settings_file_bak = storage_file_alloc(fs_api); - if(storage_file_open(settings_file_bak, path_bak, FSAM_WRITE, open_mode)) { - storage_file_write(settings_file_bak, settings, strlen(settings)); - storage_file_write(settings_file_bak, "\n", 1); + if(path_bak != NULL) { + File* settings_file_bak = storage_file_alloc(fs_api); + if(storage_file_open(settings_file_bak, path_bak, FSAM_WRITE, open_mode)) { + storage_file_write(settings_file_bak, settings, strlen(settings)); + storage_file_write(settings_file_bak, "\n", 1); + } + storage_file_close(settings_file_bak); + storage_file_free(settings_file_bak); } - storage_file_close(settings_file_bak); - storage_file_free(settings_file_bak); furi_record_close(RECORD_STORAGE); @@ -147,7 +174,7 @@ bool flipbip_load_settings_secure(char* settings) { memzero(data, dlen); // load k2 from file - if(!flipbip_load_settings(data, true)) return false; + if(!flipbip_load_settings(data, FlipBipFileKey, NULL)) return false; // check header if(data[0] != FILE_HSTR[0] || data[1] != FILE_HSTR[1] || data[2] != FILE_HSTR[2] || @@ -173,7 +200,7 @@ bool flipbip_load_settings_secure(char* settings) { data -= FILE_HLEN; // load data from file - if(!flipbip_load_settings(data, false)) return false; + if(!flipbip_load_settings(data, FlipBipFileDat, NULL)) return false; // check header if(data[0] != FILE_HSTR[0] || data[1] != FILE_HSTR[1] || data[2] != FILE_HSTR[2] || @@ -237,7 +264,7 @@ bool flipbip_save_settings_secure(const char* settings) { // seek <-- header data -= FILE_HLEN; // save k2 to file - flipbip_save_settings(data, true, false); + flipbip_save_settings(data, FlipBipFileKey, NULL, false); // seek --> header data += FILE_HLEN; // zero k2 memory @@ -250,7 +277,7 @@ bool flipbip_save_settings_secure(const char* settings) { // seek <-- header data -= FILE_HLEN; // save data to file - flipbip_save_settings(data, false, false); + flipbip_save_settings(data, FlipBipFileDat, NULL, false); // clear memory memzero(data, dlen); diff --git a/helpers/flipbip_file.h b/helpers/flipbip_file.h index 8440a26b196..57a90b3f58e 100644 --- a/helpers/flipbip_file.h +++ b/helpers/flipbip_file.h @@ -1,8 +1,18 @@ #include -bool flipbip_has_settings(bool key_file); -bool flipbip_load_settings(char* settings, bool key_file); -bool flipbip_save_settings(const char* settings, bool key_file, bool append); +typedef enum { + FlipBipFileDat, + FlipBipFileKey, + FlipBipFileOther, +} FlipBipFile; + +bool flipbip_has_settings(const FlipBipFile file_type, const char* file_name); +bool flipbip_load_settings(char* settings, const FlipBipFile file_type, const char* file_name); +bool flipbip_save_settings( + const char* settings, + const FlipBipFile file_type, + const char* file_name, + const bool append); bool flipbip_load_settings_secure(char* settings); bool flipbip_save_settings_secure(const char* settings); \ No newline at end of file diff --git a/scenes/flipbip_scene_menu.c b/scenes/flipbip_scene_menu.c index e8fad579a77..d0ac5a7b8da 100644 --- a/scenes/flipbip_scene_menu.c +++ b/scenes/flipbip_scene_menu.c @@ -18,7 +18,7 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) { void flipbip_scene_menu_on_enter(void* context) { FlipBip* app = context; - if(flipbip_has_settings(true) && flipbip_has_settings(false)) { + if(flipbip_has_settings(FlipBipFileKey, NULL) && flipbip_has_settings(FlipBipFileDat, NULL)) { submenu_add_item( app->submenu, "View BTC wallet", diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 374bcde19d0..6331b3d9ee5 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -34,19 +34,28 @@ #define PAGE_ADDR_BEGIN 9 #define PAGE_ADDR_END 14 //18 +#define MAX_ADDR_LEN 42 + 1 // 42 = max length of address + null terminator + #define TEXT_LOADING "Loading..." #define TEXT_NEW_WALLET "New wallet" #define TEXT_DEFAULT_COIN "Coin" #define TEXT_RECEIVE_ADDRESS "receive address:" #define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0" - -const char* TEXT_INFO = "-Scroll pages with up/down-" +const char *TEXT_INFO = "-Scroll pages with up/down-" "p1,2) Mnemonic/Seed " "p3) xprv Root Key " "p4,5) xprv/xpub Accnt Keys" "p6,7) xprv/xpub Extnd Keys" "p8+) Receive Addresses "; +#define TEXT_SAVE_QR "Save QR" +#define TEXT_QRFILE_EXT "address.qrcode" +const char *TEXT_QRFILE = "Filetype: QRCode\n" + "Version: 0\n" + "Message: "; + + + // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format const uint32_t COIN_INFO_ARRAY[3][6] = { {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0}, @@ -54,10 +63,10 @@ const uint32_t COIN_INFO_ARRAY[3][6] = { {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0}}; // coin_name, derivation_path -const char* COIN_TEXT_ARRAY[3][2] = { - {"BTC", "m/44'/0'/0'/0"}, - {"ETH", "m/44'/60'/0'/0"}, - {"DOGE", "m/44'/3'/0'/0"}}; +const char* COIN_TEXT_ARRAY[3][3] = { + {"BTC", "m/44'/0'/0'/0", "bitcoin:"}, + {"ETH", "m/44'/60'/0'/0", "ethereum:"}, + {"DOGE", "m/44'/3'/0'/0", "dogecoin:"}}; struct FlipBipScene1 { View* view; @@ -82,6 +91,7 @@ typedef struct { // Node for the receive address static CONFIDENTIAL HDNode* s_addr_node = NULL; +static char* s_addr_text = NULL; // Generic display text static CONFIDENTIAL char* s_disp_text1 = NULL; static CONFIDENTIAL char* s_disp_text2 = NULL; @@ -203,6 +213,7 @@ static void // Use static node for address generation memcpy(s_addr_node, node, sizeof(HDNode)); + memzero(s_addr_text, MAX_ADDR_LEN); hdnode_private_ckd(s_addr_node, addr_index); hdnode_fill_public_key(s_addr_node); @@ -219,19 +230,20 @@ static void ecdsa_get_address( s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen); - flipbip_scene_1_draw_generic(buf, 12); + strcpy(s_addr_text, buf); + flipbip_scene_1_draw_generic(s_addr_text, 12); //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen); } else if(coin_info[5] == FlipBipCoinETH60) { // ETH // ETH style address hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf); - char address[42 + 1] = {0}; - address[0] = '0'; - address[1] = 'x'; + s_addr_text[0] = '0'; + s_addr_text[1] = 'x'; // Convert the hash to a hex string - flipbip_btox((uint8_t*)buf, 20, address + 2); - flipbip_scene_1_draw_generic(address, 12); + flipbip_btox((uint8_t*)buf, 20, s_addr_text + 2); + + flipbip_scene_1_draw_generic(s_addr_text, 12); } // Clear the address node @@ -273,6 +285,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) { flipbip_scene_1_draw_generic(model->xpub_extended, 20); } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { flipbip_scene_1_draw_address(model->node, model->coin, model->page - PAGE_ADDR_BEGIN); + elements_button_right(canvas, TEXT_SAVE_QR); } if(model->page == PAGE_LOADING) { @@ -333,7 +346,8 @@ static int flipbip_scene_1_model_init( memzero(mnemonic, TEXT_BUFFER_SIZE); // Check if the mnemonic key & data is already saved in persistent storage, or overwrite is true - if(overwrite || (!flipbip_has_settings(true) && !flipbip_has_settings(false))) { + if(overwrite || (!flipbip_has_settings(FlipBipFileKey, NULL) && + !flipbip_has_settings(FlipBipFileDat, NULL))) { // Set mnemonic only mode model->mnemonic_only = true; // Generate a random mnemonic using trezor-crypto @@ -468,9 +482,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; - case InputKeyRight: case InputKeyDown: - case InputKeyOk: with_view_model( instance->view, FlipBipScene1Model * model, @@ -499,6 +511,22 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; + case InputKeyRight: + case InputKeyOk: + with_view_model( + instance->view, + FlipBipScene1Model * model, + { + if (model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { + char qrbuf[90] = {0}; + strcpy(qrbuf, TEXT_QRFILE); + strcpy(qrbuf + strlen(qrbuf), COIN_TEXT_ARRAY[model->coin][2]); + strcpy(qrbuf + strlen(qrbuf), s_addr_text); + flipbip_save_settings(qrbuf, FlipBipFileOther, TEXT_QRFILE_EXT, false); + } + }, + true); + break; case InputKeyMAX: break; } @@ -628,6 +656,7 @@ FlipBipScene1* flipbip_scene_1_alloc() { // allocate the address node s_addr_node = (HDNode*)malloc(sizeof(HDNode)); + s_addr_text = (char*)malloc(MAX_ADDR_LEN); // allocate the display text s_disp_text1 = (char*)malloc(30 + 1); @@ -649,6 +678,8 @@ void flipbip_scene_1_free(FlipBipScene1* instance) { // free the address node memzero(s_addr_node, sizeof(HDNode)); free(s_addr_node); + memzero(s_addr_text, MAX_ADDR_LEN); + free(s_addr_text); // free the display text flipbip_scene_1_clear_text(); From 3f93a8f4da74fbd04e6bd216d80d40cf094dd6a1 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 00:35:52 -0700 Subject: [PATCH 04/15] fmt --- views/flipbip_scene_1.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 6331b3d9ee5..6dde04f573e 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -41,7 +41,7 @@ #define TEXT_DEFAULT_COIN "Coin" #define TEXT_RECEIVE_ADDRESS "receive address:" #define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0" -const char *TEXT_INFO = "-Scroll pages with up/down-" +const char* TEXT_INFO = "-Scroll pages with up/down-" "p1,2) Mnemonic/Seed " "p3) xprv Root Key " "p4,5) xprv/xpub Accnt Keys" @@ -50,12 +50,10 @@ const char *TEXT_INFO = "-Scroll pages with up/down-" #define TEXT_SAVE_QR "Save QR" #define TEXT_QRFILE_EXT "address.qrcode" -const char *TEXT_QRFILE = "Filetype: QRCode\n" +const char* TEXT_QRFILE = "Filetype: QRCode\n" "Version: 0\n" "Message: "; - - // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format const uint32_t COIN_INFO_ARRAY[3][6] = { {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0}, @@ -242,7 +240,7 @@ static void s_addr_text[1] = 'x'; // Convert the hash to a hex string flipbip_btox((uint8_t*)buf, 20, s_addr_text + 2); - + flipbip_scene_1_draw_generic(s_addr_text, 12); } @@ -517,7 +515,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { instance->view, FlipBipScene1Model * model, { - if (model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { + if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { char qrbuf[90] = {0}; strcpy(qrbuf, TEXT_QRFILE); strcpy(qrbuf + strlen(qrbuf), COIN_TEXT_ARRAY[model->coin][2]); From f8f744ed38956a50a3d80cffea98610bf01f953f Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 14:36:26 -0600 Subject: [PATCH 05/15] pregenerate addresses --- views/flipbip_scene_1.c | 126 ++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 6dde04f573e..1b858beb560 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -22,6 +22,9 @@ #define DERIV_ACCOUNT 0 #define DERIV_CHANGE 0 +#define MAX_ADDR_LEN 42 + 1 // 42 = max length of address + null terminator +#define NUM_ADDRS 6 + #define PAGE_LOADING 0 #define PAGE_INFO 1 #define PAGE_MNEMONIC 2 @@ -32,9 +35,7 @@ #define PAGE_XPRV_EXTD 7 #define PAGE_XPUB_EXTD 8 #define PAGE_ADDR_BEGIN 9 -#define PAGE_ADDR_END 14 //18 - -#define MAX_ADDR_LEN 42 + 1 // 42 = max length of address + null terminator +#define PAGE_ADDR_END (PAGE_ADDR_BEGIN + NUM_ADDRS - 1) #define TEXT_LOADING "Loading..." #define TEXT_NEW_WALLET "New wallet" @@ -85,11 +86,11 @@ typedef struct { CONFIDENTIAL const char* xpub_account; CONFIDENTIAL const char* xprv_extended; CONFIDENTIAL const char* xpub_extended; + char* recv_addresses[NUM_ADDRS]; } FlipBipScene1Model; // Node for the receive address static CONFIDENTIAL HDNode* s_addr_node = NULL; -static char* s_addr_text = NULL; // Generic display text static CONFIDENTIAL char* s_disp_text1 = NULL; static CONFIDENTIAL char* s_disp_text2 = NULL; @@ -111,6 +112,54 @@ void flipbip_scene_1_set_callback( instance->context = context; } +static void flipbip_scene_1_init_address( + char* addr_text, + const HDNode* node, + uint32_t coin_type, + uint32_t addr_index) { + //s_busy = true; + + // Buffer for address serialization + const size_t buflen = 40; + char buf[40 + 1] = {0}; + + // Use static node for address generation + memcpy(s_addr_node, node, sizeof(HDNode)); + memzero(addr_text, MAX_ADDR_LEN); + + hdnode_private_ckd(s_addr_node, addr_index); + hdnode_fill_public_key(s_addr_node); + + // coin info + // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format + uint32_t coin_info[6] = {0}; + for(size_t i = 0; i < 6; i++) { + coin_info[i] = COIN_INFO_ARRAY[coin_type][i]; + } + + if(coin_info[5] == FlipBipCoinBTC0) { // BTC / DOGE style address + // BTC / DOGE style address + ecdsa_get_address( + s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen); + strcpy(addr_text, buf); + + //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen); + + } else if(coin_info[5] == FlipBipCoinETH60) { // ETH + // ETH style address + hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf); + addr_text[0] = '0'; + addr_text[1] = 'x'; + // Convert the hash to a hex string + flipbip_btox((uint8_t*)buf, 20, addr_text + 2); + } + + // Clear the address node + memzero(s_addr_node, sizeof(HDNode)); + + //s_busy = false; +} + static void flipbip_scene_1_draw_generic(const char* text, size_t line_len) { // Split the text into parts for(size_t si = 1; si <= 6; si++) { @@ -201,55 +250,6 @@ static void flipbip_scene_1_draw_seed(FlipBipScene1Model* const model) { free(seed_working); } -static void - flipbip_scene_1_draw_address(const HDNode* node, uint32_t addr_type, uint32_t addr_index) { - //s_busy = true; - - // Buffer for address serialization - const size_t buflen = 40; - char buf[40 + 1] = {0}; - - // Use static node for address generation - memcpy(s_addr_node, node, sizeof(HDNode)); - memzero(s_addr_text, MAX_ADDR_LEN); - - hdnode_private_ckd(s_addr_node, addr_index); - hdnode_fill_public_key(s_addr_node); - - // coin info - // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format - uint32_t coin_info[6] = {0}; - for(size_t i = 0; i < 6; i++) { - coin_info[i] = COIN_INFO_ARRAY[addr_type][i]; - } - - if(coin_info[5] == FlipBipCoinBTC0) { // BTC / DOGE style address - // BTC / DOGE style address - ecdsa_get_address( - s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen); - - strcpy(s_addr_text, buf); - flipbip_scene_1_draw_generic(s_addr_text, 12); - - //ecdsa_get_wif(addr_node->private_key, WIF_VERSION, HASHER_SHA2D, buf, buflen); - - } else if(coin_info[5] == FlipBipCoinETH60) { // ETH - // ETH style address - hdnode_get_ethereum_pubkeyhash(s_addr_node, (uint8_t*)buf); - s_addr_text[0] = '0'; - s_addr_text[1] = 'x'; - // Convert the hash to a hex string - flipbip_btox((uint8_t*)buf, 20, s_addr_text + 2); - - flipbip_scene_1_draw_generic(s_addr_text, 12); - } - - // Clear the address node - memzero(s_addr_node, sizeof(HDNode)); - - //s_busy = false; -} - static void flipbip_scene_1_clear_text() { memzero((void*)s_disp_text1, 30 + 1); memzero((void*)s_disp_text2, 30 + 1); @@ -282,7 +282,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) { } else if(model->page == PAGE_XPUB_EXTD) { flipbip_scene_1_draw_generic(model->xpub_extended, 20); } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { - flipbip_scene_1_draw_address(model->node, model->coin, model->page - PAGE_ADDR_BEGIN); + flipbip_scene_1_draw_generic(model->recv_addresses[model->page - PAGE_ADDR_BEGIN], 12); elements_button_right(canvas, TEXT_SAVE_QR); } @@ -448,6 +448,13 @@ static int flipbip_scene_1_model_init( model->node = node; + // Initialize addresses + for(int a = 0; a < NUM_ADDRS; a++) { + model->recv_addresses[a] = malloc(MAX_ADDR_LEN); + memzero(model->recv_addresses[a], MAX_ADDR_LEN); + flipbip_scene_1_init_address(model->recv_addresses[a], node, coin_info[5], a); + } + model->page = PAGE_INFO; #if USE_BIP39_CACHE @@ -519,7 +526,9 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { char qrbuf[90] = {0}; strcpy(qrbuf, TEXT_QRFILE); strcpy(qrbuf + strlen(qrbuf), COIN_TEXT_ARRAY[model->coin][2]); - strcpy(qrbuf + strlen(qrbuf), s_addr_text); + strcpy( + qrbuf + strlen(qrbuf), + model->recv_addresses[model->page - PAGE_ADDR_BEGIN]); flipbip_save_settings(qrbuf, FlipBipFileOther, TEXT_QRFILE_EXT, false); } }, @@ -560,6 +569,10 @@ void flipbip_scene_1_exit(void* context) { free((void*)model->xpub_account); free((void*)model->xprv_extended); free((void*)model->xpub_extended); + for(int a = 0; a < NUM_ADDRS; a++) { + memzero((void*)model->recv_addresses[a], MAX_ADDR_LEN); + free((void*)model->recv_addresses[a]); + } } }, true); @@ -654,7 +667,6 @@ FlipBipScene1* flipbip_scene_1_alloc() { // allocate the address node s_addr_node = (HDNode*)malloc(sizeof(HDNode)); - s_addr_text = (char*)malloc(MAX_ADDR_LEN); // allocate the display text s_disp_text1 = (char*)malloc(30 + 1); @@ -676,8 +688,6 @@ void flipbip_scene_1_free(FlipBipScene1* instance) { // free the address node memzero(s_addr_node, sizeof(HDNode)); free(s_addr_node); - memzero(s_addr_text, MAX_ADDR_LEN); - free(s_addr_text); // free the display text flipbip_scene_1_clear_text(); From 8d2de88e670f86ffbf7b6f006832f8f8eca16a59 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 14:56:49 -0600 Subject: [PATCH 06/15] moving qr file stuff to file class --- helpers/flipbip_file.c | 16 ++++++++++++++++ helpers/flipbip_file.h | 5 +++++ views/flipbip_scene_1.c | 11 ----------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/helpers/flipbip_file.c b/helpers/flipbip_file.c index b7f060554a3..64994dccfc7 100644 --- a/helpers/flipbip_file.c +++ b/helpers/flipbip_file.c @@ -19,6 +19,11 @@ #define FLIPBIP_KEY_PATH FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME) #define FLIPBIP_KEY_PATH_BAK FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME_BAK) +#define TEXT_QRFILE_EXT ".qrcode" +const char* TEXT_QRFILE = "Filetype: QRCode\n" + "Version: 0\n" + "Message: "; + const size_t FILE_HLEN = 4; const size_t FILE_KLEN = 256; const size_t FILE_SLEN = 512; @@ -166,6 +171,17 @@ bool flipbip_save_settings( return ret; } +bool flipbip_save_qrfile( + const char* qr_msg_prefix, + const char* qr_msg_content, + const char* file_name) { + char qr_buf[90] = {0}; + strcpy(qr_buf, TEXT_QRFILE); + strcpy(qr_buf + strlen(qr_buf), qr_msg_prefix); + strcpy(qr_buf + strlen(qr_buf), qr_msg_content); + return flipbip_save_settings(qr_buf, FlipBipFileOther, file_name, false); +} + bool flipbip_load_settings_secure(char* settings) { const size_t dlen = FILE_HLEN + FILE_SLEN + 1; diff --git a/helpers/flipbip_file.h b/helpers/flipbip_file.h index 57a90b3f58e..3c271224ff0 100644 --- a/helpers/flipbip_file.h +++ b/helpers/flipbip_file.h @@ -14,5 +14,10 @@ bool flipbip_save_settings( const char* file_name, const bool append); +bool flipbip_save_qrfile( + const char* qr_msg_prefix, + const char* qr_msg_content, + const char* file_name); + bool flipbip_load_settings_secure(char* settings); bool flipbip_save_settings_secure(const char* settings); \ No newline at end of file diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 1b858beb560..6b544ed2274 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -50,10 +50,6 @@ const char* TEXT_INFO = "-Scroll pages with up/down-" "p8+) Receive Addresses "; #define TEXT_SAVE_QR "Save QR" -#define TEXT_QRFILE_EXT "address.qrcode" -const char* TEXT_QRFILE = "Filetype: QRCode\n" - "Version: 0\n" - "Message: "; // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format const uint32_t COIN_INFO_ARRAY[3][6] = { @@ -523,13 +519,6 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { FlipBipScene1Model * model, { if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { - char qrbuf[90] = {0}; - strcpy(qrbuf, TEXT_QRFILE); - strcpy(qrbuf + strlen(qrbuf), COIN_TEXT_ARRAY[model->coin][2]); - strcpy( - qrbuf + strlen(qrbuf), - model->recv_addresses[model->page - PAGE_ADDR_BEGIN]); - flipbip_save_settings(qrbuf, FlipBipFileOther, TEXT_QRFILE_EXT, false); } }, true); From 99adebd1e4aad425b7ecad42985c45b5a68bb477 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 18:37:06 -0600 Subject: [PATCH 07/15] write QR codes for addresses to file --- helpers/flipbip_file.c | 7 +++---- views/flipbip_scene_1.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/helpers/flipbip_file.c b/helpers/flipbip_file.c index 64994dccfc7..e4b01d187e8 100644 --- a/helpers/flipbip_file.c +++ b/helpers/flipbip_file.c @@ -19,10 +19,9 @@ #define FLIPBIP_KEY_PATH FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME) #define FLIPBIP_KEY_PATH_BAK FLIPBIP_APP_BASE_FOLDER_PATH(FLIPBIP_KEY_FILE_NAME_BAK) -#define TEXT_QRFILE_EXT ".qrcode" const char* TEXT_QRFILE = "Filetype: QRCode\n" "Version: 0\n" - "Message: "; + "Message: "; // 37 chars + 1 null const size_t FILE_HLEN = 4; const size_t FILE_KLEN = 256; @@ -125,8 +124,8 @@ bool flipbip_save_settings( path = FLIPBIP_DAT_PATH; path_bak = FLIPBIP_DAT_PATH_BAK; } else { - char path_buf[32] = {0}; - strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); + char path_buf[48] = {0}; + strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); // 22 strcpy(path_buf + strlen(path_buf), "/"); strcpy(path_buf + strlen(path_buf), file_name); path = path_buf; diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 6b544ed2274..1d285e8644a 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -50,6 +50,7 @@ const char* TEXT_INFO = "-Scroll pages with up/down-" "p8+) Receive Addresses "; #define TEXT_SAVE_QR "Save QR" +#define TEXT_QRFILE_EXT ".qrcode" // 7 chars + 1 null // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format const uint32_t COIN_INFO_ARRAY[3][6] = { @@ -445,10 +446,18 @@ static int flipbip_scene_1_model_init( model->node = node; // Initialize addresses - for(int a = 0; a < NUM_ADDRS; a++) { + for(uint8_t a = 0; a < NUM_ADDRS; a++) { model->recv_addresses[a] = malloc(MAX_ADDR_LEN); memzero(model->recv_addresses[a], MAX_ADDR_LEN); flipbip_scene_1_init_address(model->recv_addresses[a], node, coin_info[5], a); + + // Save QR code file + char name[14] = {0}; + strcpy(name, COIN_TEXT_ARRAY[coin][0]); + const unsigned char addr_num[1] = {a}; + flipbip_btox(addr_num, 1, name + strlen(name)); + strcpy(name + strlen(name), TEXT_QRFILE_EXT); + flipbip_save_qrfile(COIN_TEXT_ARRAY[coin][2], model->recv_addresses[a], name); } model->page = PAGE_INFO; From 2aa66d18495dbc9af41eea75bcd3d52b6e7286d2 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 19:01:53 -0600 Subject: [PATCH 08/15] write QR codes for addresses to file - cleanup --- application.fam | 2 +- views/flipbip_scene_1.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/application.fam b/application.fam index c539e9b0b8a..d0fb99272f6 100644 --- a/application.fam +++ b/application.fam @@ -7,7 +7,7 @@ App( requires=[ "gui", ], - stack_size=2 * 1024, + stack_size=3 * 1024, order=10, fap_icon="flipbip_10px.png", fap_icon_assets="icons", diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 1d285e8644a..f1ddec4f347 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -389,7 +389,7 @@ static int flipbip_scene_1_model_init( // buffer for key serialization const size_t buflen = 128; - char buf[128 + 1]; + char buf[128 + 1] = {0}; // coin info // bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format @@ -452,12 +452,13 @@ static int flipbip_scene_1_model_init( flipbip_scene_1_init_address(model->recv_addresses[a], node, coin_info[5], a); // Save QR code file - char name[14] = {0}; - strcpy(name, COIN_TEXT_ARRAY[coin][0]); + memzero(buf, buflen); + strcpy(buf, COIN_TEXT_ARRAY[coin][0]); const unsigned char addr_num[1] = {a}; - flipbip_btox(addr_num, 1, name + strlen(name)); - strcpy(name + strlen(name), TEXT_QRFILE_EXT); - flipbip_save_qrfile(COIN_TEXT_ARRAY[coin][2], model->recv_addresses[a], name); + flipbip_btox(addr_num, 1, buf + strlen(buf)); + strcpy(buf + strlen(buf), TEXT_QRFILE_EXT); + flipbip_save_qrfile(COIN_TEXT_ARRAY[coin][2], model->recv_addresses[a], buf); + memzero(buf, buflen); } model->page = PAGE_INFO; From bc830bb8715170d1ec33cc339a3e54d7dcb661ee Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 22:02:37 -0600 Subject: [PATCH 09/15] clean up labels --- flipbip.c | 2 +- helpers/flipbip_file.c | 42 ++++++++++++++------------ helpers/flipbip_file.h | 10 +++---- scenes/flipbip_scene_menu.c | 3 +- views/flipbip_scene_1.c | 59 +++++++++++++++++++++---------------- 5 files changed, 65 insertions(+), 51 deletions(-) diff --git a/flipbip.c b/flipbip.c index 2682ac2e10b..a14305eec16 100644 --- a/flipbip.c +++ b/flipbip.c @@ -50,7 +50,7 @@ static void text_input_callback(void* context) { if(mnemonic_check(app->import_mnemonic_text) == 0) status = FlipBipStatusMnemonicCheckError; // 13 = mnemonic check error // Save the mnemonic to persistent storage - else if(!flipbip_save_settings_secure(app->import_mnemonic_text)) + else if(!flipbip_save_file_secure(app->import_mnemonic_text)) status = FlipBipStatusSaveError; // 12 = save error if(status == FlipBipStatusSuccess) { diff --git a/helpers/flipbip_file.c b/helpers/flipbip_file.c index e4b01d187e8..4bac1709ada 100644 --- a/helpers/flipbip_file.c +++ b/helpers/flipbip_file.c @@ -1,5 +1,7 @@ #include "flipbip_file.h" #include +#include +#include #include "../helpers/flipbip_string.h" // From: lib/crypto #include @@ -22,15 +24,15 @@ const char* TEXT_QRFILE = "Filetype: QRCode\n" "Version: 0\n" "Message: "; // 37 chars + 1 null - -const size_t FILE_HLEN = 4; -const size_t FILE_KLEN = 256; -const size_t FILE_SLEN = 512; +#define FILE_HLEN 4 +#define FILE_KLEN 256 +#define FILE_SLEN 512 +#define FILE_MAX_PATH_LEN 48 const char* FILE_HSTR = "fb01"; const char* FILE_K1 = "fb0131d5cf688221c109163908ebe51debb46227c6cc8b37641910833222772a" "baefe6d9ceb651842260e0d1e05e3b90d15e7d5ffaaabc0207bf200a117793a2"; -bool flipbip_load_settings(char* settings, const FlipBipFile file_type, const char* file_name) { +bool flipbip_load_file(char* settings, const FlipBipFile file_type, const char* file_name) { bool ret = false; const char* path; if(file_type == FlipBipFileKey) { @@ -85,7 +87,7 @@ bool flipbip_load_settings(char* settings, const FlipBipFile file_type, const ch return ret; } -bool flipbip_has_settings(const FlipBipFile file_type, const char* file_name) { +bool flipbip_has_file(const FlipBipFile file_type, const char* file_name, const bool remove) { bool ret = false; const char* path; if(file_type == FlipBipFileKey) { @@ -101,15 +103,17 @@ bool flipbip_has_settings(const FlipBipFile file_type, const char* file_name) { } Storage* fs_api = furi_record_open(RECORD_STORAGE); - if(storage_file_exists(fs_api, path)) { - ret = true; + if(remove) { + ret = storage_simply_remove(fs_api, path); + } else { + ret = storage_file_exists(fs_api, path); } furi_record_close(RECORD_STORAGE); return ret; } -bool flipbip_save_settings( +bool flipbip_save_file( const char* settings, const FlipBipFile file_type, const char* file_name, @@ -124,7 +128,7 @@ bool flipbip_save_settings( path = FLIPBIP_DAT_PATH; path_bak = FLIPBIP_DAT_PATH_BAK; } else { - char path_buf[48] = {0}; + char path_buf[FILE_MAX_PATH_LEN] = {0}; strcpy(path_buf, FLIPBIP_APP_BASE_FOLDER); // 22 strcpy(path_buf + strlen(path_buf), "/"); strcpy(path_buf + strlen(path_buf), file_name); @@ -144,7 +148,7 @@ bool flipbip_save_settings( // return ret; // } // try to create the folder - storage_common_mkdir(fs_api, FLIPBIP_APP_BASE_FOLDER); + storage_simply_mkdir(fs_api, FLIPBIP_APP_BASE_FOLDER); File* settings_file = storage_file_alloc(fs_api); if(storage_file_open(settings_file, path, FSAM_WRITE, open_mode)) { @@ -178,10 +182,10 @@ bool flipbip_save_qrfile( strcpy(qr_buf, TEXT_QRFILE); strcpy(qr_buf + strlen(qr_buf), qr_msg_prefix); strcpy(qr_buf + strlen(qr_buf), qr_msg_content); - return flipbip_save_settings(qr_buf, FlipBipFileOther, file_name, false); + return flipbip_save_file(qr_buf, FlipBipFileOther, file_name, false); } -bool flipbip_load_settings_secure(char* settings) { +bool flipbip_load_file_secure(char* settings) { const size_t dlen = FILE_HLEN + FILE_SLEN + 1; // allocate memory for key/data @@ -189,7 +193,7 @@ bool flipbip_load_settings_secure(char* settings) { memzero(data, dlen); // load k2 from file - if(!flipbip_load_settings(data, FlipBipFileKey, NULL)) return false; + if(!flipbip_load_file(data, FlipBipFileKey, NULL)) return false; // check header if(data[0] != FILE_HSTR[0] || data[1] != FILE_HSTR[1] || data[2] != FILE_HSTR[2] || @@ -215,7 +219,7 @@ bool flipbip_load_settings_secure(char* settings) { data -= FILE_HLEN; // load data from file - if(!flipbip_load_settings(data, FlipBipFileDat, NULL)) return false; + if(!flipbip_load_file(data, FlipBipFileDat, NULL)) return false; // check header if(data[0] != FILE_HSTR[0] || data[1] != FILE_HSTR[1] || data[2] != FILE_HSTR[2] || @@ -248,7 +252,7 @@ bool flipbip_load_settings_secure(char* settings) { return true; } -bool flipbip_save_settings_secure(const char* settings) { +bool flipbip_save_file_secure(const char* settings) { const size_t dlen = FILE_HLEN + FILE_SLEN + 1; // cap settings to 256 bytes @@ -279,7 +283,7 @@ bool flipbip_save_settings_secure(const char* settings) { // seek <-- header data -= FILE_HLEN; // save k2 to file - flipbip_save_settings(data, FlipBipFileKey, NULL, false); + flipbip_save_file(data, FlipBipFileKey, NULL, false); // seek --> header data += FILE_HLEN; // zero k2 memory @@ -292,7 +296,7 @@ bool flipbip_save_settings_secure(const char* settings) { // seek <-- header data -= FILE_HLEN; // save data to file - flipbip_save_settings(data, FlipBipFileDat, NULL, false); + flipbip_save_file(data, FlipBipFileDat, NULL, false); // clear memory memzero(data, dlen); @@ -301,4 +305,4 @@ bool flipbip_save_settings_secure(const char* settings) { memzero(k2, FILE_KLEN / 2); return true; -} \ No newline at end of file +} diff --git a/helpers/flipbip_file.h b/helpers/flipbip_file.h index 3c271224ff0..c19f70dc519 100644 --- a/helpers/flipbip_file.h +++ b/helpers/flipbip_file.h @@ -6,9 +6,9 @@ typedef enum { FlipBipFileOther, } FlipBipFile; -bool flipbip_has_settings(const FlipBipFile file_type, const char* file_name); -bool flipbip_load_settings(char* settings, const FlipBipFile file_type, const char* file_name); -bool flipbip_save_settings( +bool flipbip_has_file(const FlipBipFile file_type, const char* file_name, const bool remove); +bool flipbip_load_file(char* settings, const FlipBipFile file_type, const char* file_name); +bool flipbip_save_file( const char* settings, const FlipBipFile file_type, const char* file_name, @@ -19,5 +19,5 @@ bool flipbip_save_qrfile( const char* qr_msg_content, const char* file_name); -bool flipbip_load_settings_secure(char* settings); -bool flipbip_save_settings_secure(const char* settings); \ No newline at end of file +bool flipbip_load_file_secure(char* settings); +bool flipbip_save_file_secure(const char* settings); diff --git a/scenes/flipbip_scene_menu.c b/scenes/flipbip_scene_menu.c index d0ac5a7b8da..4784fcdc1af 100644 --- a/scenes/flipbip_scene_menu.c +++ b/scenes/flipbip_scene_menu.c @@ -18,7 +18,8 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) { void flipbip_scene_menu_on_enter(void* context) { FlipBip* app = context; - if(flipbip_has_settings(FlipBipFileKey, NULL) && flipbip_has_settings(FlipBipFileDat, NULL)) { + if(flipbip_has_file(FlipBipFileKey, NULL, false) && + flipbip_has_file(FlipBipFileDat, NULL, false)) { submenu_add_item( app->submenu, "View BTC wallet", diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index f1ddec4f347..1c3689fa719 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -280,13 +280,12 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) { flipbip_scene_1_draw_generic(model->xpub_extended, 20); } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { flipbip_scene_1_draw_generic(model->recv_addresses[model->page - PAGE_ADDR_BEGIN], 12); - elements_button_right(canvas, TEXT_SAVE_QR); } if(model->page == PAGE_LOADING) { canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 1, 10, TEXT_LOADING); - canvas_draw_str(canvas, 6, 30, s_derivation_text); + canvas_draw_str(canvas, 2, 10, TEXT_LOADING); + canvas_draw_str(canvas, 7, 30, s_derivation_text); canvas_draw_icon(canvas, 86, 25, &I_Keychain_39x36); } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { // draw address header @@ -297,22 +296,31 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) { receive_text = TEXT_DEFAULT_COIN; } const size_t receive_len = strlen(receive_text) * 7; - canvas_draw_str_aligned(canvas, 1, 2, AlignLeft, AlignTop, receive_text); - canvas_draw_str_aligned(canvas, receive_len, 2, AlignLeft, AlignTop, TEXT_RECEIVE_ADDRESS); + canvas_draw_str_aligned(canvas, 2, 2, AlignLeft, AlignTop, receive_text); + canvas_draw_str_aligned( + canvas, receive_len + 1, 2, AlignLeft, AlignTop, TEXT_RECEIVE_ADDRESS); // draw address number const unsigned char addr_num[1] = {(unsigned char)(model->page - PAGE_ADDR_BEGIN)}; - char addr_num_text[3]; + char addr_num_text[3] = {0}; flipbip_btox(addr_num, 1, addr_num_text); addr_num_text[0] = '/'; - canvas_draw_str_aligned(canvas, 110, 2, AlignLeft, AlignTop, addr_num_text); + canvas_draw_str_aligned(canvas, 125, 2, AlignRight, AlignTop, addr_num_text); + + // draw QR code file path + char addr_name_text[14] = {0}; + strcpy(addr_name_text, COIN_TEXT_ARRAY[model->coin][0]); + flipbip_btox(addr_num, 1, addr_name_text + strlen(addr_name_text)); + strcpy(addr_name_text + strlen(addr_name_text), TEXT_QRFILE_EXT); + //elements_button_right(canvas, addr_name_text); + canvas_draw_str_aligned(canvas, 125, 53, AlignRight, AlignTop, addr_name_text); // draw address canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 6, 22, s_disp_text1); - canvas_draw_str(canvas, 6, 34, s_disp_text2); - canvas_draw_str(canvas, 6, 46, s_disp_text3); - canvas_draw_str(canvas, 6, 58, s_disp_text4); + canvas_draw_str(canvas, 7, 22, s_disp_text1); + canvas_draw_str(canvas, 7, 34, s_disp_text2); + canvas_draw_str(canvas, 7, 46, s_disp_text3); + canvas_draw_str(canvas, 7, 58, s_disp_text4); } else { canvas_set_font(canvas, FontSecondary); canvas_draw_str_aligned(canvas, 1, 2, AlignLeft, AlignTop, s_disp_text1); @@ -341,8 +349,8 @@ static int flipbip_scene_1_model_init( memzero(mnemonic, TEXT_BUFFER_SIZE); // Check if the mnemonic key & data is already saved in persistent storage, or overwrite is true - if(overwrite || (!flipbip_has_settings(FlipBipFileKey, NULL) && - !flipbip_has_settings(FlipBipFileDat, NULL))) { + if(overwrite || (!flipbip_has_file(FlipBipFileKey, NULL, false) && + !flipbip_has_file(FlipBipFileDat, NULL, false))) { // Set mnemonic only mode model->mnemonic_only = true; // Generate a random mnemonic using trezor-crypto @@ -351,14 +359,14 @@ static int flipbip_scene_1_model_init( if(mnemonic_check(mnemonic_gen) == 0) return FlipBipStatusMnemonicCheckError; // 13 = mnemonic check error // Save the mnemonic to persistent storage - else if(!flipbip_save_settings_secure(mnemonic_gen)) + else if(!flipbip_save_file_secure(mnemonic_gen)) return FlipBipStatusSaveError; // 12 = save error // Clear the generated mnemonic from memory mnemonic_clear(); } // Load the mnemonic from persistent storage - if(!flipbip_load_settings_secure(mnemonic)) { + if(!flipbip_load_file_secure(mnemonic)) { // Set mnemonic only mode for this error for memory cleanup purposes model->mnemonic_only = true; return FlipBipStatusLoadError; // 11 = load error @@ -507,7 +515,6 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; - case InputKeyLeft: case InputKeyUp: with_view_model( instance->view, @@ -524,15 +531,17 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { break; case InputKeyRight: case InputKeyOk: - with_view_model( - instance->view, - FlipBipScene1Model * model, - { - if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { - } - }, - true); - break; + // with_view_model( + // instance->view, + // FlipBipScene1Model * model, + // { + // if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) { + + // } + // }, + // true); + // break; + case InputKeyLeft: case InputKeyMAX: break; } From c93f308527b4f1370704e542397f5ef01259f84b Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 22:04:37 -0600 Subject: [PATCH 10/15] nav --- views/flipbip_scene_1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 1c3689fa719..79057e47605 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -501,6 +501,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; + case InputKeyRight: case InputKeyDown: with_view_model( instance->view, @@ -515,6 +516,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; + case InputKeyLeft: case InputKeyUp: with_view_model( instance->view, @@ -529,7 +531,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { }, true); break; - case InputKeyRight: + // case InputKeyRight: case InputKeyOk: // with_view_model( // instance->view, @@ -541,7 +543,7 @@ bool flipbip_scene_1_input(InputEvent* event, void* context) { // }, // true); // break; - case InputKeyLeft: + // case InputKeyLeft: case InputKeyMAX: break; } From 68a112e9db4cad40c1433cd2801456f241a602d1 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 22:27:44 -0600 Subject: [PATCH 11/15] fix address gen bug --- views/flipbip_scene_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/flipbip_scene_1.c b/views/flipbip_scene_1.c index 79057e47605..76626f76b95 100644 --- a/views/flipbip_scene_1.c +++ b/views/flipbip_scene_1.c @@ -457,7 +457,7 @@ static int flipbip_scene_1_model_init( for(uint8_t a = 0; a < NUM_ADDRS; a++) { model->recv_addresses[a] = malloc(MAX_ADDR_LEN); memzero(model->recv_addresses[a], MAX_ADDR_LEN); - flipbip_scene_1_init_address(model->recv_addresses[a], node, coin_info[5], a); + flipbip_scene_1_init_address(model->recv_addresses[a], node, coin, a); // Save QR code file memzero(buf, buflen); From 91831db8568fa53b0c79ab864215aac7358cd420 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 22:38:46 -0600 Subject: [PATCH 12/15] adding README updates --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index db9f0a5b793..d0b0e0a9205 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ The application will be compiled and copied onto your device - Import your own mnemonic - Lots of typing required but you can now use the wallet with an existing mnemonic you have saved - Useful to convert paper backup to keys and receive addresses without relying on a laptop or phone +- Improved receive address generation features + - Addresses are now generated at the same time as other pieces of wallet info + - This slows down initial wallet load, but makes UI much more responsive + - QR code files are now generated for each address and stored in the `apps_data/flipbip` directory + - This app is required to view the QR code files: https://github.com/bmatcuk/flipperzero-qrcode (included in RM firmware) + - NOTE: This happens during the `View Wallet` step; you must view a wallet after generating/importing a wallet in order to ensure the address QR files are correct +- Broke out crypto functionality into its own library using `fap_private_libs` feature ### Work in Progress From 535013609dafd1976cad01579f1ee0225adc68f2 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 22:59:41 -0600 Subject: [PATCH 13/15] adding CI --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..e8178bdb926 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Build + +on: + push: + branches: + - main + - develop + +env: + firmware_version: '0.78.1' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Flipper Zero Firmware + uses: actions/checkout@v3 + with: + repository: 'flipperdevices/flipperzero-firmware' + ref: ${{ env.firmware_version }} + submodules: true + - name: Checkout + uses: actions/checkout@v3 + with: + path: 'applications_user/FlipBIP' + - name: Build + run: ./fbt COMPACT=1 DEBUG=0 faps \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..567d90349ce --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +env: + firmware_version: '0.78.1' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Flipper Zero Firmware + uses: actions/checkout@v3 + with: + repository: 'flipperdevices/flipperzero-firmware' + ref: ${{ env.firmware_version }} + submodules: true + - name: Checkout + uses: actions/checkout@v3 + with: + path: 'applications_user/FlipBIP' + - name: Build + run: ./fbt COMPACT=1 DEBUG=0 faps + - name: Publish + uses: softprops/action-gh-release@v1 + with: + files: build/f7-firmware-C/.extapps/FlipBIP.fap + body: Built against firmware v${{ env.firmware_version }} + generate_release_notes: true + fail_on_unmatched_files: true \ No newline at end of file From 9734eacc51cacb60a89a554803dc41bd71478cad Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 23:07:10 -0600 Subject: [PATCH 14/15] modify build scripts, build only --- .github/workflows/build.yml | 2 ++ .github/workflows/release.yml | 34 ---------------------------------- 2 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8178bdb926..60bd84b58b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,8 @@ on: branches: - main - develop + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' env: firmware_version: '0.78.1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 567d90349ce..00000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - -env: - firmware_version: '0.78.1' - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout Flipper Zero Firmware - uses: actions/checkout@v3 - with: - repository: 'flipperdevices/flipperzero-firmware' - ref: ${{ env.firmware_version }} - submodules: true - - name: Checkout - uses: actions/checkout@v3 - with: - path: 'applications_user/FlipBIP' - - name: Build - run: ./fbt COMPACT=1 DEBUG=0 faps - - name: Publish - uses: softprops/action-gh-release@v1 - with: - files: build/f7-firmware-C/.extapps/FlipBIP.fap - body: Built against firmware v${{ env.firmware_version }} - generate_release_notes: true - fail_on_unmatched_files: true \ No newline at end of file From 0150732757c7f1e37ebc0557b3cc9916ca8cdec2 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sun, 12 Mar 2023 23:19:02 -0600 Subject: [PATCH 15/15] CI updates --- .github/workflows/build.yml | 6 ++--- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60bd84b58b6..27c32f17042 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,6 @@ on: branches: - main - develop - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' env: firmware_version: '0.78.1' @@ -22,9 +20,9 @@ jobs: repository: 'flipperdevices/flipperzero-firmware' ref: ${{ env.firmware_version }} submodules: true - - name: Checkout + - name: Checkout FlipBIP uses: actions/checkout@v3 with: path: 'applications_user/FlipBIP' - - name: Build + - name: Build FAPs run: ./fbt COMPACT=1 DEBUG=0 faps \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..8eff6329665 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +env: + firmware_version: '0.78.1' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Flipper Zero Firmware + uses: actions/checkout@v3 + with: + repository: 'flipperdevices/flipperzero-firmware' + ref: ${{ env.firmware_version }} + submodules: true + - name: Checkout FlipBIP + uses: actions/checkout@v3 + with: + path: 'applications_user/FlipBIP' + - name: Build FAPs + run: ./fbt COMPACT=1 DEBUG=0 faps + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + with: + strip_v: false + - name: Publish FlipBIP + uses: softprops/action-gh-release@v1 + with: + files: | + build/f7-firmware-C/.extapps/FlipBIP.fap + applications_user/FlipBIP/README.md + name: ${{steps.tag.outputs.tag}} + body: Built against Flipper Zero firmware v${{ env.firmware_version }} + generate_release_notes: true + fail_on_unmatched_files: true \ No newline at end of file