From 92a481e770ec59cc5d98d6a222d6871606e75780 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Fri, 11 Aug 2023 23:51:28 -0600 Subject: [PATCH] feat: FlipBIP v1.13 --- applications/external/flipbip/application.fam | 6 +- applications/external/flipbip/flipbip.c | 47 +++---- applications/external/flipbip/flipbip.h | 23 +-- .../flipbip/helpers/flipbip_custom_event.h | 6 - .../external/flipbip/helpers/flipbip_haptic.c | 35 ----- .../external/flipbip/helpers/flipbip_haptic.h | 7 - .../external/flipbip/helpers/flipbip_led.c | 39 ------ .../external/flipbip/helpers/flipbip_led.h | 2 - .../flipbip/helpers/flipbip_speaker.c | 27 ---- .../flipbip/helpers/flipbip_speaker.h | 4 - .../flipbip/icons/ButtonDown_10x5.png | Bin 6223 -> 0 bytes .../external/flipbip/icons/ButtonUp_10x5.png | Bin 6233 -> 0 bytes .../external/flipbip/lib/crypto/CONTRIBUTORS | 1 + .../external/flipbip/lib/crypto/bip32.c | 2 + .../external/flipbip/lib/crypto/memzero.c | 1 + .../external/flipbip/lib/crypto/options.h | 7 +- .../external/flipbip/lib/crypto/rand.c | 10 +- .../external/flipbip/lib/crypto/rand.h | 1 + .../flipbip/scenes/flipbip_scene_config.h | 1 - .../flipbip/scenes/flipbip_scene_menu.c | 36 ++++- .../flipbip/scenes/flipbip_scene_scene_1.c | 32 +++-- .../flipbip/scenes/flipbip_scene_settings.c | 46 ------ .../scenes/flipbip_scene_startscreen.c | 55 -------- .../external/flipbip/views/flipbip_scene_1.c | 45 +++--- .../flipbip/views/flipbip_startscreen.c | 131 ------------------ .../flipbip/views/flipbip_startscreen.h | 19 --- 26 files changed, 127 insertions(+), 456 deletions(-) delete mode 100644 applications/external/flipbip/helpers/flipbip_haptic.c delete mode 100644 applications/external/flipbip/helpers/flipbip_haptic.h delete mode 100644 applications/external/flipbip/helpers/flipbip_led.c delete mode 100644 applications/external/flipbip/helpers/flipbip_led.h delete mode 100644 applications/external/flipbip/helpers/flipbip_speaker.c delete mode 100644 applications/external/flipbip/helpers/flipbip_speaker.h delete mode 100644 applications/external/flipbip/icons/ButtonDown_10x5.png delete mode 100644 applications/external/flipbip/icons/ButtonUp_10x5.png delete mode 100644 applications/external/flipbip/scenes/flipbip_scene_startscreen.c delete mode 100644 applications/external/flipbip/views/flipbip_startscreen.c delete mode 100644 applications/external/flipbip/views/flipbip_startscreen.h diff --git a/applications/external/flipbip/application.fam b/applications/external/flipbip/application.fam index 135b717e9..bae1c0fb6 100644 --- a/applications/external/flipbip/application.fam +++ b/applications/external/flipbip/application.fam @@ -9,8 +9,6 @@ App( stack_size=3 * 1024, order=10, fap_icon="flipbip_10px.png", - fap_icon_assets="icons", - fap_icon_assets_symbol="flipbip", fap_private_libs=[ Lib( name="crypto", @@ -19,6 +17,6 @@ App( fap_category="Tools", fap_author="Struan Clark (xtruan)", fap_weburl="https://github.com/xtruan/FlipBIP", - fap_version=(1, 11), - fap_description="Crypto wallet tools for Flipper", + fap_version=(1, 13), + fap_description="Crypto wallet for Flipper", ) diff --git a/applications/external/flipbip/flipbip.c b/applications/external/flipbip/flipbip.c index 1a5e5a983..7a7237639 100644 --- a/applications/external/flipbip/flipbip.c +++ b/applications/external/flipbip/flipbip.c @@ -1,12 +1,13 @@ -#pragma GCC optimize("-Os") - #include "flipbip.h" #include "helpers/flipbip_file.h" -#include "helpers/flipbip_haptic.h" // From: lib/crypto #include #include +#define MNEMONIC_MENU_DEFAULT "Import mnemonic seed" +#define MNEMONIC_MENU_SUCCESS "Import seed (success)" +#define MNEMONIC_MENU_FAILURE "Import seed (failed!)" + bool flipbip_custom_event_callback(void* context, uint32_t event) { furi_assert(context); FlipBip* app = context; @@ -42,6 +43,7 @@ static void text_input_callback(void* context) { // reset input state app->input_state = FlipBipTextInputDefault; handled = true; + // switch back to settings view view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings); } else if(app->input_state == FlipBipTextInputMnemonic) { if(app->import_from_mnemonic == 1) { @@ -56,11 +58,13 @@ static void text_input_callback(void* context) { status = FlipBipStatusSaveError; // 12 = save error if(status == FlipBipStatusSuccess) { + app->mnemonic_menu_text = MNEMONIC_MENU_SUCCESS; //notification_message(app->notification, &sequence_blink_cyan_100); - flipbip_play_happy_bump(app); + //flipbip_play_happy_bump(app); } else { + app->mnemonic_menu_text = MNEMONIC_MENU_FAILURE; //notification_message(app->notification, &sequence_blink_red_100); - flipbip_play_long_bump(app); + //flipbip_play_long_bump(app); } memzero(app->import_mnemonic_text, TEXT_BUFFER_SIZE); @@ -70,7 +74,9 @@ static void text_input_callback(void* context) { // reset input state app->input_state = FlipBipTextInputDefault; handled = true; - view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu); + // exit scene 1 instance that's being used for text input and go back to menu + scene_manager_previous_scene(app->scene_manager); + //view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu); } } @@ -79,6 +85,7 @@ static void text_input_callback(void* context) { memzero(app->input_text, TEXT_BUFFER_SIZE); // reset input state app->input_state = FlipBipTextInputDefault; + // something went wrong, switch to menu view view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu); } } @@ -86,12 +93,12 @@ static void text_input_callback(void* context) { FlipBip* flipbip_app_alloc() { FlipBip* app = malloc(sizeof(FlipBip)); app->gui = furi_record_open(RECORD_GUI); - app->notification = furi_record_open(RECORD_NOTIFICATION); + //app->notification = furi_record_open(RECORD_NOTIFICATION); - //Turn backlight on, believe me this makes testing your app easier - notification_message(app->notification, &sequence_display_backlight_on); + // Turn backlight on, believe me this makes testing your app easier + //notification_message(app->notification, &sequence_display_backlight_on); - //Scene additions + // Scene additions app->view_dispatcher = view_dispatcher_alloc(); view_dispatcher_enable_queue(app->view_dispatcher); @@ -105,8 +112,6 @@ FlipBip* flipbip_app_alloc() { app->submenu = submenu_alloc(); // Settings - app->haptic = FlipBipHapticOn; - app->led = FlipBipLedOn; app->bip39_strength = FlipBipStrength256; // 256 bits (24 words) app->passphrase = FlipBipPassphraseOff; @@ -114,17 +119,13 @@ FlipBip* flipbip_app_alloc() { app->bip44_coin = FlipBipCoinBTC0; // 0 (BTC) app->overwrite_saved_seed = 0; app->import_from_mnemonic = 0; + app->mnemonic_menu_text = MNEMONIC_MENU_DEFAULT; // Text input app->input_state = FlipBipTextInputDefault; view_dispatcher_add_view( app->view_dispatcher, FlipBipViewIdMenu, submenu_get_view(app->submenu)); - app->flipbip_startscreen = flipbip_startscreen_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - FlipBipViewIdStartscreen, - flipbip_startscreen_get_view(app->flipbip_startscreen)); app->flipbip_scene_1 = flipbip_scene_1_alloc(); view_dispatcher_add_view( app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1)); @@ -141,13 +142,13 @@ FlipBip* flipbip_app_alloc() { (void*)app, app->input_text, TEXT_BUFFER_SIZE, - //clear default text + // clear default text true); - text_input_set_header_text(app->text_input, "Input"); + //text_input_set_header_text(app->text_input, "Input"); view_dispatcher_add_view( app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input)); - //End Scene Additions + // End Scene Additions return app; } @@ -171,7 +172,7 @@ void flipbip_app_free(FlipBip* app) { furi_record_close(RECORD_GUI); app->gui = NULL; - app->notification = NULL; + //app->notification = NULL; //Remove whatever is left memzero(app, sizeof(FlipBip)); @@ -190,9 +191,7 @@ int32_t flipbip_app(void* p) { view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - scene_manager_next_scene( - app->scene_manager, FlipBipSceneStartscreen); //Start with start screen - //scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //if you want to directly start with Menu + scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); //Start with menu furi_hal_power_suppress_charge_enter(); diff --git a/applications/external/flipbip/flipbip.h b/applications/external/flipbip/flipbip.h index 9df002aaa..9f5994b80 100644 --- a/applications/external/flipbip/flipbip.h +++ b/applications/external/flipbip/flipbip.h @@ -5,37 +5,35 @@ #include #include #include -#include +//#include #include #include #include #include #include #include "scenes/flipbip_scene.h" -#include "views/flipbip_startscreen.h" #include "views/flipbip_scene_1.h" -#define FLIPBIP_VERSION "v1.11.0" +#define FLIPBIP_VERSION "v1.13" #define COIN_BTC 0 #define COIN_DOGE 3 #define COIN_ETH 60 +#define COIN_ZEC 133 #define TEXT_BUFFER_SIZE 256 typedef struct { Gui* gui; - NotificationApp* notification; + // NotificationApp* notification; ViewDispatcher* view_dispatcher; Submenu* submenu; SceneManager* scene_manager; VariableItemList* variable_item_list; TextInput* text_input; - FlipBipStartscreen* flipbip_startscreen; FlipBipScene1* flipbip_scene_1; + char* mnemonic_menu_text; // Settings options - int haptic; - int led; int bip39_strength; int passphrase; // Main menu options @@ -57,16 +55,6 @@ typedef enum { FlipBipViewIdTextInput, } FlipBipViewId; -typedef enum { - FlipBipHapticOff, - FlipBipHapticOn, -} FlipBipHapticState; - -typedef enum { - FlipBipLedOff, - FlipBipLedOn, -} FlipBipLedState; - typedef enum { FlipBipStrength128, FlipBipStrength192, @@ -82,6 +70,7 @@ typedef enum { FlipBipCoinBTC0, FlipBipCoinETH60, FlipBipCoinDOGE3, + FlipBipCoinZEC133, } FlipBipCoin; typedef enum { diff --git a/applications/external/flipbip/helpers/flipbip_custom_event.h b/applications/external/flipbip/helpers/flipbip_custom_event.h index 2dbaf5112..882c50439 100644 --- a/applications/external/flipbip/helpers/flipbip_custom_event.h +++ b/applications/external/flipbip/helpers/flipbip_custom_event.h @@ -1,12 +1,6 @@ #pragma once typedef enum { - FlipBipCustomEventStartscreenUp, - FlipBipCustomEventStartscreenDown, - FlipBipCustomEventStartscreenLeft, - FlipBipCustomEventStartscreenRight, - FlipBipCustomEventStartscreenOk, - FlipBipCustomEventStartscreenBack, FlipBipCustomEventScene1Up, FlipBipCustomEventScene1Down, FlipBipCustomEventScene1Left, diff --git a/applications/external/flipbip/helpers/flipbip_haptic.c b/applications/external/flipbip/helpers/flipbip_haptic.c deleted file mode 100644 index c5608efa5..000000000 --- a/applications/external/flipbip/helpers/flipbip_haptic.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "flipbip_haptic.h" -#include "../flipbip.h" - -void flipbip_play_happy_bump(void* context) { - FlipBip* app = context; - if(app->haptic != 1) { - return; - } - notification_message(app->notification, &sequence_set_vibro_on); - furi_thread_flags_wait(0, FuriFlagWaitAny, 20); - notification_message(app->notification, &sequence_reset_vibro); -} - -void flipbip_play_bad_bump(void* context) { - FlipBip* app = context; - if(app->haptic != 1) { - return; - } - notification_message(app->notification, &sequence_set_vibro_on); - furi_thread_flags_wait(0, FuriFlagWaitAny, 100); - notification_message(app->notification, &sequence_reset_vibro); -} - -void flipbip_play_long_bump(void* context) { - FlipBip* app = context; - if(app->haptic != 1) { - return; - } - for(int i = 0; i < 4; i++) { - notification_message(app->notification, &sequence_set_vibro_on); - furi_thread_flags_wait(0, FuriFlagWaitAny, 50); - notification_message(app->notification, &sequence_reset_vibro); - furi_thread_flags_wait(0, FuriFlagWaitAny, 100); - } -} diff --git a/applications/external/flipbip/helpers/flipbip_haptic.h b/applications/external/flipbip/helpers/flipbip_haptic.h deleted file mode 100644 index cab1d3a63..000000000 --- a/applications/external/flipbip/helpers/flipbip_haptic.h +++ /dev/null @@ -1,7 +0,0 @@ -#include - -void flipbip_play_happy_bump(void* context); - -void flipbip_play_bad_bump(void* context); - -void flipbip_play_long_bump(void* context); diff --git a/applications/external/flipbip/helpers/flipbip_led.c b/applications/external/flipbip/helpers/flipbip_led.c deleted file mode 100644 index 7a6fd1778..000000000 --- a/applications/external/flipbip/helpers/flipbip_led.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "flipbip_led.h" -#include "../flipbip.h" - -void flipbip_led_set_rgb(void* context, int red, int green, int blue) { - FlipBip* app = context; - if(app->led != 1) { - return; - } - NotificationMessage notification_led_message_1; - notification_led_message_1.type = NotificationMessageTypeLedRed; - NotificationMessage notification_led_message_2; - notification_led_message_2.type = NotificationMessageTypeLedGreen; - NotificationMessage notification_led_message_3; - notification_led_message_3.type = NotificationMessageTypeLedBlue; - - notification_led_message_1.data.led.value = red; - notification_led_message_2.data.led.value = green; - notification_led_message_3.data.led.value = blue; - const NotificationSequence notification_sequence = { - ¬ification_led_message_1, - ¬ification_led_message_2, - ¬ification_led_message_3, - &message_do_not_reset, - NULL, - }; - notification_message(app->notification, ¬ification_sequence); - furi_thread_flags_wait( - 0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set -} - -void flipbip_led_reset(void* context) { - FlipBip* app = context; - notification_message(app->notification, &sequence_reset_red); - notification_message(app->notification, &sequence_reset_green); - notification_message(app->notification, &sequence_reset_blue); - - furi_thread_flags_wait( - 0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set -} diff --git a/applications/external/flipbip/helpers/flipbip_led.h b/applications/external/flipbip/helpers/flipbip_led.h deleted file mode 100644 index bbacc976b..000000000 --- a/applications/external/flipbip/helpers/flipbip_led.h +++ /dev/null @@ -1,2 +0,0 @@ -void flipbip_led_set_rgb(void* context, int red, int green, int blue); -void flipbip_led_reset(void* context); diff --git a/applications/external/flipbip/helpers/flipbip_speaker.c b/applications/external/flipbip/helpers/flipbip_speaker.c deleted file mode 100644 index f7ae2193b..000000000 --- a/applications/external/flipbip/helpers/flipbip_speaker.c +++ /dev/null @@ -1,27 +0,0 @@ -// #include "flipbip_speaker.h" -// #include "../flipbip.h" - -// #define NOTE_INPUT 587.33f - -// void flipbip_play_input_sound(void* context) { -// FlipBip* app = context; -// if (app->speaker != 1) { -// return; -// } -// float volume = 1.0f; -// if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { -// furi_hal_speaker_start(NOTE_INPUT, volume); -// } - -// } - -// void flipbip_stop_all_sound(void* context) { -// FlipBip* app = context; -// if (app->speaker != 1) { -// return; -// } -// if(furi_hal_speaker_is_mine()) { -// furi_hal_speaker_stop(); -// furi_hal_speaker_release(); -// } -// } diff --git a/applications/external/flipbip/helpers/flipbip_speaker.h b/applications/external/flipbip/helpers/flipbip_speaker.h deleted file mode 100644 index 150ba9129..000000000 --- a/applications/external/flipbip/helpers/flipbip_speaker.h +++ /dev/null @@ -1,4 +0,0 @@ -// #define NOTE_INPUT 587.33f - -// void flipbip_play_input_sound(void* context); -// void flipbip_stop_all_sound(void* context); diff --git a/applications/external/flipbip/icons/ButtonDown_10x5.png b/applications/external/flipbip/icons/ButtonDown_10x5.png deleted file mode 100644 index b492b926c45def68d88b03c380527e226740beb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6223 zcmeHKc{r478y`w`71_5jLS$BB%nXAXvdfmn62{CsOw3|tGJ{kiY2m1(QaVbZEGZN! z?WMAH)UlqdHFBm^QukN2Ype5gVwm&ai+qXDQOjtf8m5t9Ldh&oFtL3@{) zD$NWnNtmCKIsZ;C6KB=_?2J6@p9gC!TUpkJay7jj<~xsOxOGrJPM*>Il)Uz@C1kbb zfolvyY6f$(JY6rHiLEmoeDg7;VfGVN@3@V+a;k_UsC4qchSc-Kl#q|I!!Re2Nv^PH3w;H3xjKsq0Gc(qA#r{G=k~a$92=Aa&xy(s!<}kM!PF zs-Lnc5NX?Pg>95S}-tZa&Du}>qE&Uf{3HGHkPJg=zW z8hXpg5l-jb>hbxZJEWfjy9+K*o|gnQ^OEJ%j;2_vP%+n4Oy9R%dHpHo_~muu4oZv~ zia}ZbVM!{U|0(^Vz0Au48U2u%_}LG<5KV=9Nj1=GYSX#L19-PZ;=G5I~BNv)2J z#t;We&>{uDKTXZfX8KfS?Uuo-y=p~yU-NXj}I^Hri#?k z7Ww16d~1@56==zu%+(`{WZl#jtL}rX$vMYRU1Pc7P1Nmd5BJ6rN|k?gKg@C0eq~p9 zX~8{|)2YDH?7*lfN+oqLwNRTKSz6dc629mxJrI(ho!MMZPF2!2+D+_q-)FKhe7G`z zk;{6pHOoKboS?(3xa_<^Riibhqn34GoiKrxe*NUT`_q#F`RY+GPy<$-+EJp1BbHJ% zxoP|bw|$IJ>?X+k+#?l~WkXAj5Qoh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3|ZWornzI1xnptkVl+~*vL3~zMhI)(eFp8RNB^hF#zWzsD0&*R#Wvu8w2X|f9D zyd6RBw zS_#EpO?v(67$xiatn__)>+kq=+MyCNCrhHt`)8d7k{Y&2Xw@y)<**tb{>FTk=uv2l z?^`SR++sYIwf8V2VnHa*% zyg$AuVUSliYnH_Ydr~zf*n7H?w-BftmH|NH_|OeREKmVHrsg6pK=r2!pgwe8CYuNw zFROq-nKUA7JC=+jbFJupOuG;s-6@3PObzj;;%P8*GZ|A60R&*t1prjU3SjdIA|h-a zmjI5%Vgw92ZzAv~!d%G?P%93P4mC6|G(f^_M9d&G%uEJq%A+v|j@Gu{Aiy^w%ugWT z5)cTXP-q~;7;t#L2oxTVMbmKZ2mVEKt2#6fQvvGAQ3DU;%5)Oz$OR;`8J`y_24^$Ej+@J z&gbmrQRy~8bhbe2X9ybghd*~WFJL|$8WlkgptC?zJ{T4COUR8RvcnG#F$KO%7I)qY zB>NXj0h93;S-;FpteH>e=ZS#sKX8As{+|21F=$056RbJZ-Qwwytcfsjd;*O_Wzq=q zLp*@T`!JA5IMxV{f*S%z92`Ib7`P$Thl<5gsaTpJ>L(}?n=b&^RJs@n1UF!UI6g=; z-3LHo;7AhA=iS8%LjcnOsRhK93Ifc_!E6XtJUSrY@SHiE03u8b0Tp}B7dX`P>$2D} z`JhFxxaPlAy%Rm~>)Y2&5Wt*QL80@7O8}@}gYbbMI&D4>==W7c^#ji%jk^rMTJLZZQvK*7;CXB3Kn#1hbW7~)&92=Si&o~iSLBKVsk? z8UL=X{~28}e_eOzY_J0of|r@dzBTQS&*fNRwRv2nua$wg(P* mog John Dvorak Christian Reitter +Struan Clark \ No newline at end of file diff --git a/applications/external/flipbip/lib/crypto/bip32.c b/applications/external/flipbip/lib/crypto/bip32.c index 09f00d60e..efa511e6d 100644 --- a/applications/external/flipbip/lib/crypto/bip32.c +++ b/applications/external/flipbip/lib/crypto/bip32.c @@ -26,7 +26,9 @@ #include #include "address.h" +#if USE_NEM #include "aes/aes.h" +#endif #include "base58.h" #include "bignum.h" #include "bip32.h" diff --git a/applications/external/flipbip/lib/crypto/memzero.c b/applications/external/flipbip/lib/crypto/memzero.c index 64866ee56..234f7dd6c 100644 --- a/applications/external/flipbip/lib/crypto/memzero.c +++ b/applications/external/flipbip/lib/crypto/memzero.c @@ -50,6 +50,7 @@ void memzero(void* const pnt, const size_t len) { SecureZeroMemory(pnt, len); #elif defined(HAVE_MEMSET_S) memset_s(pnt, (rsize_t)len, 0, (rsize_t)len); +// REMOVED - Flipper Zero does not have this function // #elif defined(HAVE_EXPLICIT_BZERO) // explicit_bzero(pnt, len); #elif defined(HAVE_EXPLICIT_MEMSET) diff --git a/applications/external/flipbip/lib/crypto/options.h b/applications/external/flipbip/lib/crypto/options.h index f0edcc60f..8510cb3f5 100644 --- a/applications/external/flipbip/lib/crypto/options.h +++ b/applications/external/flipbip/lib/crypto/options.h @@ -86,9 +86,14 @@ #define USE_KECCAK 1 #endif -// add way how to mark confidential data +// add a way to mark confidential data #ifndef CONFIDENTIAL #define CONFIDENTIAL #endif +// use Flipper Zero hardware random number generator +#ifndef USE_FLIPPER_HAL_RANDOM +#define USE_FLIPPER_HAL_RANDOM 1 +#endif + #endif diff --git a/applications/external/flipbip/lib/crypto/rand.c b/applications/external/flipbip/lib/crypto/rand.c index a10858734..64ee3d7a1 100644 --- a/applications/external/flipbip/lib/crypto/rand.c +++ b/applications/external/flipbip/lib/crypto/rand.c @@ -21,11 +21,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#define FLIPPER_HAL_RANDOM - #include "rand.h" -#ifdef FLIPPER_HAL_RANDOM +#if USE_FLIPPER_HAL_RANDOM // NOTE: // random32() and random_buffer() have been replaced in this implementation @@ -67,6 +65,8 @@ void random_buffer(uint8_t* buf, size_t len) { // The following code is platform independent // +static uint32_t seed = 0; + uint32_t random32(void) { // Linear congruential generator from Numerical Recipes // https://en.wikipedia.org/wiki/Linear_congruential_generator @@ -74,7 +74,7 @@ uint32_t random32(void) { return seed; } -void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) { +void random_buffer(uint8_t *buf, size_t len) { uint32_t r = 0; for (size_t i = 0; i < len; i++) { if (i % 4 == 0) { @@ -84,7 +84,7 @@ void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) { } } -#endif /* FLIPPER_HAL_RANDOM */ +#endif /* USE_FLIPPER_HAL_RANDOM */ uint32_t random_uniform(uint32_t n) { uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n); diff --git a/applications/external/flipbip/lib/crypto/rand.h b/applications/external/flipbip/lib/crypto/rand.h index fa854890f..14c2bfcfc 100644 --- a/applications/external/flipbip/lib/crypto/rand.h +++ b/applications/external/flipbip/lib/crypto/rand.h @@ -26,6 +26,7 @@ #include #include +#include "options.h" void random_reseed(const uint32_t value); uint32_t random32(void); diff --git a/applications/external/flipbip/scenes/flipbip_scene_config.h b/applications/external/flipbip/scenes/flipbip_scene_config.h index a62832162..6468414ac 100644 --- a/applications/external/flipbip/scenes/flipbip_scene_config.h +++ b/applications/external/flipbip/scenes/flipbip_scene_config.h @@ -1,4 +1,3 @@ -ADD_SCENE(flipbip, startscreen, Startscreen) ADD_SCENE(flipbip, menu, Menu) ADD_SCENE(flipbip, scene_1, Scene_1) ADD_SCENE(flipbip, settings, Settings) \ No newline at end of file diff --git a/applications/external/flipbip/scenes/flipbip_scene_menu.c b/applications/external/flipbip/scenes/flipbip_scene_menu.c index 04525909d..928a002f7 100644 --- a/applications/external/flipbip/scenes/flipbip_scene_menu.c +++ b/applications/external/flipbip/scenes/flipbip_scene_menu.c @@ -1,13 +1,17 @@ #include "../flipbip.h" #include "../helpers/flipbip_file.h" +#define FLIPBIP_SUBMENU_TEXT "** FlipBIP wallet " FLIPBIP_VERSION " **" + enum SubmenuIndex { SubmenuIndexScene1BTC = 10, SubmenuIndexScene1ETH, SubmenuIndexScene1DOGE, + SubmenuIndexScene1ZEC, SubmenuIndexScene1New, SubmenuIndexScene1Import, SubmenuIndexSettings, + SubmenuIndexNOP, }; void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) { @@ -18,6 +22,14 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) { void flipbip_scene_menu_on_enter(void* context) { FlipBip* app = context; + // FlipBIP header with version + submenu_add_item( + app->submenu, + FLIPBIP_SUBMENU_TEXT, + SubmenuIndexNOP, + flipbip_scene_menu_submenu_callback, + app); + if(flipbip_has_file(FlipBipFileKey, NULL, false) && flipbip_has_file(FlipBipFileDat, NULL, false)) { submenu_add_item( @@ -38,6 +50,12 @@ void flipbip_scene_menu_on_enter(void* context) { SubmenuIndexScene1DOGE, flipbip_scene_menu_submenu_callback, app); + submenu_add_item( + app->submenu, + "View ZEC (t-addr) wallet", + SubmenuIndexScene1ZEC, + flipbip_scene_menu_submenu_callback, + app); submenu_add_item( app->submenu, "Regenerate wallet", @@ -54,7 +72,7 @@ void flipbip_scene_menu_on_enter(void* context) { } submenu_add_item( app->submenu, - "Import from mnemonic", + app->mnemonic_menu_text, SubmenuIndexScene1Import, flipbip_scene_menu_submenu_callback, app); @@ -101,6 +119,14 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) { app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1DOGE); scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); return true; + } else if(event.event == SubmenuIndexScene1ZEC) { + app->overwrite_saved_seed = 0; + app->import_from_mnemonic = 0; + app->bip44_coin = FlipBipCoinZEC133; + scene_manager_set_scene_state( + app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ZEC); + scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); + return true; } else if(event.event == SubmenuIndexScene1New) { app->overwrite_saved_seed = 1; app->import_from_mnemonic = 0; @@ -110,15 +136,17 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) { return true; } else if(event.event == SubmenuIndexScene1Import) { app->import_from_mnemonic = 1; - app->input_state = FlipBipTextInputMnemonic; - text_input_set_header_text(app->text_input, "Enter mnemonic phrase"); - view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput); + scene_manager_set_scene_state( + app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1Import); + scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); return true; } else if(event.event == SubmenuIndexSettings) { scene_manager_set_scene_state( app->scene_manager, FlipBipSceneMenu, SubmenuIndexSettings); scene_manager_next_scene(app->scene_manager, FlipBipSceneSettings); return true; + } else if(event.event == SubmenuIndexNOP) { + return true; } } return false; diff --git a/applications/external/flipbip/scenes/flipbip_scene_scene_1.c b/applications/external/flipbip/scenes/flipbip_scene_scene_1.c index 6f4064cd4..3b0f1ff0e 100644 --- a/applications/external/flipbip/scenes/flipbip_scene_scene_1.c +++ b/applications/external/flipbip/scenes/flipbip_scene_scene_1.c @@ -11,8 +11,18 @@ void flipbip_scene_1_callback(FlipBipCustomEvent event, void* context) { void flipbip_scene_scene_1_on_enter(void* context) { furi_assert(context); FlipBip* app = context; - flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app); - view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1); + + if(app->import_from_mnemonic == 1) { + // handle mnemonic seed import mode with text input, this only + // uses this scene to have a correct stack of scenes + app->input_state = FlipBipTextInputMnemonic; + text_input_set_header_text(app->text_input, "Enter mnemonic phrase"); + view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdTextInput); + } else { + // handle all other modes, these actually use this scene's logic + flipbip_scene_1_set_callback(app->flipbip_scene_1, flipbip_scene_1_callback, app); + view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdScene1); + } } bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) { @@ -21,16 +31,16 @@ bool flipbip_scene_scene_1_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { - case FlipBipCustomEventScene1Left: - case FlipBipCustomEventScene1Right: - break; - case FlipBipCustomEventScene1Up: - case FlipBipCustomEventScene1Down: - break; + // case FlipBipCustomEventScene1Left: + // case FlipBipCustomEventScene1Right: + // break; + // case FlipBipCustomEventScene1Up: + // case FlipBipCustomEventScene1Down: + // break; case FlipBipCustomEventScene1Back: - notification_message(app->notification, &sequence_reset_red); - notification_message(app->notification, &sequence_reset_green); - notification_message(app->notification, &sequence_reset_blue); + //notification_message(app->notification, &sequence_reset_red); + //notification_message(app->notification, &sequence_reset_green); + //notification_message(app->notification, &sequence_reset_blue); if(!scene_manager_search_and_switch_to_previous_scene( app->scene_manager, FlipBipSceneMenu)) { scene_manager_stop(app->scene_manager); diff --git a/applications/external/flipbip/scenes/flipbip_scene_settings.c b/applications/external/flipbip/scenes/flipbip_scene_settings.c index c743c97b8..0e43033ed 100644 --- a/applications/external/flipbip/scenes/flipbip_scene_settings.c +++ b/applications/external/flipbip/scenes/flipbip_scene_settings.c @@ -6,24 +6,6 @@ #define TEXT_LABEL_ON "ON" #define TEXT_LABEL_OFF "OFF" -const char* const haptic_text[2] = { - TEXT_LABEL_OFF, - TEXT_LABEL_ON, -}; -const uint32_t haptic_value[2] = { - FlipBipHapticOff, - FlipBipHapticOn, -}; - -const char* const led_text[2] = { - TEXT_LABEL_OFF, - TEXT_LABEL_ON, -}; -const uint32_t led_value[2] = { - FlipBipLedOff, - FlipBipLedOn, -}; - const char* const bip39_strength_text[3] = { "12", "18", @@ -44,20 +26,6 @@ const uint32_t passphrase_value[2] = { FlipBipPassphraseOn, }; -static void flipbip_scene_settings_set_haptic(VariableItem* item) { - FlipBip* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, haptic_text[index]); - app->haptic = haptic_value[index]; -} - -static void flipbip_scene_settings_set_led(VariableItem* item) { - FlipBip* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, led_text[index]); - app->led = led_value[index]; -} - static void flipbip_scene_settings_set_bip39_strength(VariableItem* item) { FlipBip* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -108,20 +76,6 @@ void flipbip_scene_settings_on_enter(void* context) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, passphrase_text[value_index]); - // Vibro on/off - item = variable_item_list_add( - app->variable_item_list, "Vibro/Haptic:", 2, flipbip_scene_settings_set_haptic, app); - value_index = value_index_uint32(app->haptic, haptic_value, 2); - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, haptic_text[value_index]); - - // LED Effects on/off - item = variable_item_list_add( - app->variable_item_list, "LED FX:", 2, flipbip_scene_settings_set_led, app); - value_index = value_index_uint32(app->led, led_value, 2); - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, led_text[value_index]); - view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdSettings); } diff --git a/applications/external/flipbip/scenes/flipbip_scene_startscreen.c b/applications/external/flipbip/scenes/flipbip_scene_startscreen.c deleted file mode 100644 index a9cb8ba5f..000000000 --- a/applications/external/flipbip/scenes/flipbip_scene_startscreen.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "../flipbip.h" -#include "../helpers/flipbip_custom_event.h" -#include "../views/flipbip_startscreen.h" - -void flipbip_scene_startscreen_callback(FlipBipCustomEvent event, void* context) { - furi_assert(context); - FlipBip* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, event); -} - -void flipbip_scene_startscreen_on_enter(void* context) { - furi_assert(context); - FlipBip* app = context; - flipbip_startscreen_set_callback( - app->flipbip_startscreen, flipbip_scene_startscreen_callback, app); - view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdStartscreen); -} - -bool flipbip_scene_startscreen_on_event(void* context, SceneManagerEvent event) { - FlipBip* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - switch(event.event) { - case FlipBipCustomEventStartscreenLeft: - case FlipBipCustomEventStartscreenRight: - break; - case FlipBipCustomEventStartscreenUp: - case FlipBipCustomEventStartscreenDown: - break; - case FlipBipCustomEventStartscreenOk: - scene_manager_next_scene(app->scene_manager, FlipBipSceneMenu); - consumed = true; - break; - case FlipBipCustomEventStartscreenBack: - notification_message(app->notification, &sequence_reset_red); - notification_message(app->notification, &sequence_reset_green); - notification_message(app->notification, &sequence_reset_blue); - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, FlipBipSceneStartscreen)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - consumed = true; - break; - } - } - - return consumed; -} - -void flipbip_scene_startscreen_on_exit(void* context) { - FlipBip* app = context; - UNUSED(app); -} \ No newline at end of file diff --git a/applications/external/flipbip/views/flipbip_scene_1.c b/applications/external/flipbip/views/flipbip_scene_1.c index faafc8442..d3a5ee065 100644 --- a/applications/external/flipbip/views/flipbip_scene_1.c +++ b/applications/external/flipbip/views/flipbip_scene_1.c @@ -5,10 +5,7 @@ #include #include #include -#include "flipbip_icons.h" -#include -#include "../helpers/flipbip_haptic.h" -#include "../helpers/flipbip_led.h" +//#include "flipbip_icons.h" #include "../helpers/flipbip_string.h" #include "../helpers/flipbip_file.h" // From: /lib/crypto @@ -43,7 +40,7 @@ #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" +// #define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0" const char* TEXT_INFO = "-Scroll pages with up/down-" "p1,2) BIP39 Mnemonic/Seed" "p3) BIP32 Root Key " @@ -55,16 +52,19 @@ const char* TEXT_INFO = "-Scroll pages with up/down-" #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] = { +const uint32_t COIN_INFO_ARRAY[4][6] = { {COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0}, {COIN_ETH, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinETH60}, - {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0}}; + {COIN_DOGE, 0x02fac398, 0x02facafd, 0x1e, 0x9e, FlipBipCoinBTC0}, + {COIN_ZEC, 0x0488ade4, 0x0488b21e, 0x1cb8, 0x80, FlipBipCoinZEC133}, +}; // coin_name, derivation_path -const char* COIN_TEXT_ARRAY[3][3] = { +const char* COIN_TEXT_ARRAY[4][3] = { {"BTC", "m/44'/0'/0'/0", "bitcoin:"}, {"ETH", "m/44'/60'/0'/0", "ethereum:"}, - {"DOGE", "m/44'/3'/0'/0", "dogecoin:"}}; + {"DOGE", "m/44'/3'/0'/0", "dogecoin:"}, + {"ZEC", "m/44'/133'/0'/0", "zcash:"}}; struct FlipBipScene1 { View* view; @@ -98,7 +98,7 @@ static CONFIDENTIAL char* s_disp_text4 = NULL; static CONFIDENTIAL char* s_disp_text5 = NULL; static CONFIDENTIAL char* s_disp_text6 = NULL; // Derivation path text -static const char* s_derivation_text = TEXT_DEFAULT_DERIV; +static const char* s_derivation_text = TEXT_DEFAULT_COIN; // TEXT_DEFAULT_DERIV; // Warning text static bool s_warn_insecure = false; #define WARN_INSECURE_TEXT_1 "Recommendation:" @@ -147,7 +147,6 @@ static void flipbip_scene_1_init_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 @@ -157,6 +156,12 @@ static void flipbip_scene_1_init_address( addr_text[1] = 'x'; // Convert the hash to a hex string flipbip_btox((uint8_t*)buf, 20, addr_text + 2); + + } else if(coin_info[5] == FlipBipCoinZEC133) { // ZEC + ecdsa_get_address( + s_addr_node->public_key, coin_info[3], HASHER_SHA2_RIPEMD, HASHER_SHA2D, buf, buflen); + addr_text[0] = 't'; + strcpy(addr_text, buf); } // Clear the address node @@ -311,7 +316,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) { canvas_set_font(canvas, FontPrimary); canvas_draw_str(canvas, 2, 10, TEXT_LOADING); canvas_draw_str(canvas, 7, 30, s_derivation_text); - canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36); + // canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36); if(s_warn_insecure) { canvas_set_font(canvas, FontSecondary); canvas_draw_str(canvas, 2, 50, WARN_INSECURE_TEXT_1); @@ -654,9 +659,12 @@ void flipbip_scene_1_enter(void* context) { s_derivation_text = TEXT_NEW_WALLET; } - flipbip_play_happy_bump(app); + // Wait a beat to allow the display time to update to the loading screen + furi_thread_flags_wait(0, FuriFlagWaitAny, 20); + + //flipbip_play_happy_bump(app); //notification_message(app->notification, &sequence_blink_cyan_100); - flipbip_led_set_rgb(app, 255, 0, 0); + //flipbip_led_set_rgb(app, 255, 0, 0); with_view_model( instance->view, @@ -669,7 +677,8 @@ void flipbip_scene_1_enter(void* context) { // nonzero status, free the mnemonic if(status != FlipBipStatusSuccess) { - memzero((void*)model->mnemonic, strlen(model->mnemonic)); + // calling strlen on mnemonic here can cause a crash, don't. + // it wasn't loaded properly anyways, no need to zero the memory free((void*)model->mnemonic); } @@ -677,15 +686,15 @@ void flipbip_scene_1_enter(void* context) { if(status == FlipBipStatusSaveError) { model->mnemonic = "ERROR:,Save error"; model->page = PAGE_MNEMONIC; - flipbip_play_long_bump(app); + //flipbip_play_long_bump(app); } else if(status == FlipBipStatusLoadError) { model->mnemonic = "ERROR:,Load error"; model->page = PAGE_MNEMONIC; - flipbip_play_long_bump(app); + //flipbip_play_long_bump(app); } else if(status == FlipBipStatusMnemonicCheckError) { model->mnemonic = "ERROR:,Mnemonic check error"; model->page = PAGE_MNEMONIC; - flipbip_play_long_bump(app); + //flipbip_play_long_bump(app); } // s_busy = false; diff --git a/applications/external/flipbip/views/flipbip_startscreen.c b/applications/external/flipbip/views/flipbip_startscreen.c deleted file mode 100644 index 0a4bebb57..000000000 --- a/applications/external/flipbip/views/flipbip_startscreen.c +++ /dev/null @@ -1,131 +0,0 @@ -#include "../flipbip.h" -#include -#include -#include -#include -#include "flipbip_icons.h" -#include - -struct FlipBipStartscreen { - View* view; - FlipBipStartscreenCallback callback; - void* context; -}; - -typedef struct { - int some_value; -} FlipBipStartscreenModel; - -void flipbip_startscreen_set_callback( - FlipBipStartscreen* instance, - FlipBipStartscreenCallback callback, - void* context) { - furi_assert(instance); - furi_assert(callback); - instance->callback = callback; - instance->context = context; -} - -void flipbip_startscreen_draw(Canvas* canvas, FlipBipStartscreenModel* model) { - UNUSED(model); - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - - canvas_draw_icon(canvas, 1, 33, &I_Auth_62x31); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 18, 11, "FlipBIP - BIP32/39/44"); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 23, 22, "Crypto toolkit for Flipper"); - canvas_draw_str(canvas, 99, 34, FLIPBIP_VERSION); - - elements_button_right(canvas, "Start"); -} - -static void flipbip_startscreen_model_init(FlipBipStartscreenModel* const model) { - model->some_value = 1; -} - -bool flipbip_startscreen_input(InputEvent* event, void* context) { - furi_assert(context); - FlipBipStartscreen* instance = context; - if(event->type == InputTypeRelease) { - switch(event->key) { - case InputKeyBack: - with_view_model( - instance->view, - FlipBipStartscreenModel * model, - { - UNUSED(model); - instance->callback(FlipBipCustomEventStartscreenBack, instance->context); - }, - true); - break; - case InputKeyLeft: - case InputKeyRight: - case InputKeyUp: - case InputKeyDown: - case InputKeyOk: - with_view_model( - instance->view, - FlipBipStartscreenModel * model, - { - UNUSED(model); - instance->callback(FlipBipCustomEventStartscreenOk, instance->context); - }, - true); - break; - case InputKeyMAX: - break; - } - } - return true; -} - -void flipbip_startscreen_exit(void* context) { - furi_assert(context); -} - -void flipbip_startscreen_enter(void* context) { - furi_assert(context); - FlipBipStartscreen* instance = (FlipBipStartscreen*)context; - with_view_model( - instance->view, - FlipBipStartscreenModel * model, - { flipbip_startscreen_model_init(model); }, - true); -} - -FlipBipStartscreen* flipbip_startscreen_alloc() { - FlipBipStartscreen* instance = malloc(sizeof(FlipBipStartscreen)); - instance->view = view_alloc(); - view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(FlipBipStartscreenModel)); - view_set_context(instance->view, instance); // furi_assert crashes in events without this - view_set_draw_callback(instance->view, (ViewDrawCallback)flipbip_startscreen_draw); - view_set_input_callback(instance->view, flipbip_startscreen_input); - //view_set_enter_callback(instance->view, flipbip_startscreen_enter); - //view_set_exit_callback(instance->view, flipbip_startscreen_exit); - - with_view_model( - instance->view, - FlipBipStartscreenModel * model, - { flipbip_startscreen_model_init(model); }, - true); - - return instance; -} - -void flipbip_startscreen_free(FlipBipStartscreen* instance) { - furi_assert(instance); - - with_view_model( - instance->view, FlipBipStartscreenModel * model, { UNUSED(model); }, true); - view_free(instance->view); - free(instance); -} - -View* flipbip_startscreen_get_view(FlipBipStartscreen* instance) { - furi_assert(instance); - return instance->view; -} diff --git a/applications/external/flipbip/views/flipbip_startscreen.h b/applications/external/flipbip/views/flipbip_startscreen.h deleted file mode 100644 index d6eb1fad8..000000000 --- a/applications/external/flipbip/views/flipbip_startscreen.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include "../helpers/flipbip_custom_event.h" - -typedef struct FlipBipStartscreen FlipBipStartscreen; - -typedef void (*FlipBipStartscreenCallback)(FlipBipCustomEvent event, void* context); - -void flipbip_startscreen_set_callback( - FlipBipStartscreen* flipbip_startscreen, - FlipBipStartscreenCallback callback, - void* context); - -View* flipbip_startscreen_get_view(FlipBipStartscreen* flipbip_static); - -FlipBipStartscreen* flipbip_startscreen_alloc(); - -void flipbip_startscreen_free(FlipBipStartscreen* flipbip_static); \ No newline at end of file