22
22
#include "inheritance/core.pb.h"
23
23
#include "inheritance_api.h"
24
24
#include "inheritance_main.h"
25
- #include "nem .h"
25
+ #include "inheritance_priv .h"
26
26
#include "nfc.h"
27
+ #include "reconstruct_wallet_flow.h"
27
28
#include "status_api.h"
28
29
#include "ui_core_confirm.h"
29
30
#include "ui_screens.h"
35
36
/*****************************************************************************
36
37
* PRIVATE MACROS AND DEFINES
37
38
*****************************************************************************/
38
- #define CHALLENGE_SIZE_MAX 32
39
- #define CHALLENGE_SIZE_MIN 16
40
- #define ENTROPY_SIZE_LIMIT 100
41
-
42
- /*****************************************************************************
43
- * PRIVATE TYPEDEFS
44
- *****************************************************************************/
45
-
46
- typedef enum {
47
- AUTH_WALLET_OK = 0 ,
48
- AUTH_WALLET_TYPE_INVALID , // TODO: In inheriance app - Show error message
49
- // on ui that which assert is wrong
50
- AUTH_WALLET_INPUTS_INVALID , // TODO: In inheritance app - Add in wallet id
51
- // comparison, show error message on ui
52
- } auth_wallet_error_type_e ;
53
-
54
- #pragma pack(push, 1)
55
- typedef struct {
56
- uint8_t wallet_id [WALLET_ID_SIZE ];
57
- uint8_t challenge [CHALLENGE_SIZE_MAX ];
58
- size_t challenge_size ;
59
-
60
- const uint8_t entropy [ENTROPY_SIZE_LIMIT ];
61
- uint8_t entropy_size ;
62
- ed25519_secret_key private_key ;
63
-
64
- ed25519_signature signature ;
65
- ed25519_public_key public_key ;
66
-
67
- bool is_setup ;
68
- auth_wallet_error_type_e status ;
69
- } auth_wallet_config_t ;
70
- #pragma pack(pop)
71
39
72
40
/*****************************************************************************
73
41
* STATIC VARIABLES
@@ -142,6 +110,7 @@ static bool verify_auth_wallet_inputs() {
142
110
auth -> challenge_size > CHALLENGE_SIZE_MAX ) {
143
111
inheritance_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG ,
144
112
ERROR_DATA_FLOW_INVALID_QUERY );
113
+ delay_scr_init (ui_text_inheritance_wallet_auth_fail , DELAY_TIME );
145
114
return false;
146
115
}
147
116
@@ -195,12 +164,33 @@ static bool auth_wallet_get_signature() {
195
164
unsigned_txn , unsigned_txn_size , auth -> public_key , auth -> signature );
196
165
197
166
if (0 != valid ) {
167
+ inheritance_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG ,
168
+ ERROR_DATA_FLOW_INVALID_DATA );
169
+ delay_scr_init (ui_text_inheritance_wallet_auth_fail , DELAY_TIME );
198
170
return false;
199
171
}
200
172
201
173
return true;
202
174
}
203
175
176
+ static bool send_result () {
177
+ inheritance_result_t result = INHERITANCE_RESULT_INIT_ZERO ;
178
+ result .which_response = INHERITANCE_RESULT_AUTH_WALLET_TAG ;
179
+ result .auth_wallet .which_response =
180
+ INHERITANCE_AUTH_WALLET_RESPONSE_RESULT_TAG ;
181
+ memcpy (result .auth_wallet .result .signature ,
182
+ auth -> signature ,
183
+ sizeof (ed25519_signature ));
184
+
185
+ if (auth -> is_setup ) {
186
+ memcpy (result .auth_wallet .result .public_key ,
187
+ auth -> public_key ,
188
+ sizeof (ed25519_public_key ));
189
+ }
190
+
191
+ inheritance_send_result (& result );
192
+ return true;
193
+ }
204
194
/*****************************************************************************
205
195
* GLOBAL FUNCTIONS
206
196
*****************************************************************************/
@@ -218,28 +208,8 @@ void inheritance_wallet_login(inheritance_query_t *query) {
218
208
auth -> is_setup = query -> auth_wallet .initiate .is_public_key ;
219
209
220
210
set_app_flow_status (INHERITANCE_AUTH_WALLET_STATUS_INIT );
221
- if (!verify_auth_wallet_inputs () || !auth_wallet_get_entropy () ||
222
- !auth_wallet_get_pairs () || !auth_wallet_get_signature ()) {
223
- inheritance_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG ,
224
- ERROR_DATA_FLOW_INVALID_DATA );
225
- delay_scr_init (ui_text_inheritance_wallet_auth_fail , DELAY_TIME );
226
- return ;
227
- }
228
- delay_scr_init (ui_text_inheritance_wallet_auth_success , DELAY_TIME );
229
-
230
- inheritance_result_t result = INHERITANCE_RESULT_INIT_ZERO ;
231
- result .which_response = INHERITANCE_RESULT_AUTH_WALLET_TAG ;
232
- result .auth_wallet .which_response =
233
- INHERITANCE_AUTH_WALLET_RESPONSE_RESULT_TAG ;
234
- memcpy (result .auth_wallet .result .signature ,
235
- auth -> signature ,
236
- sizeof (ed25519_signature ));
237
-
238
- if (auth -> is_setup ) {
239
- memcpy (result .auth_wallet .result .public_key ,
240
- auth -> public_key ,
241
- sizeof (ed25519_public_key ));
211
+ if (verify_auth_wallet_inputs () && auth_wallet_get_entropy () &&
212
+ auth_wallet_get_pairs () && auth_wallet_get_signature () && send_result ()) {
213
+ delay_scr_init (ui_text_inheritance_wallet_auth_success , DELAY_TIME );
242
214
}
243
-
244
- inheritance_send_result (& result );
245
215
}
0 commit comments