Skip to content

Commit 027f836

Browse files
vrockz747TejasvOnly
authored andcommitted
fix(app): Add review changes
1 parent e99ac0a commit 027f836

File tree

5 files changed

+79
-76
lines changed

5 files changed

+79
-76
lines changed

apps/inheritance_app/inheritance_auth_wallet.c

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include "inheritance/core.pb.h"
2323
#include "inheritance_api.h"
2424
#include "inheritance_main.h"
25-
#include "nem.h"
25+
#include "inheritance_priv.h"
2626
#include "nfc.h"
27+
#include "reconstruct_wallet_flow.h"
2728
#include "status_api.h"
2829
#include "ui_core_confirm.h"
2930
#include "ui_screens.h"
@@ -35,39 +36,6 @@
3536
/*****************************************************************************
3637
* PRIVATE MACROS AND DEFINES
3738
*****************************************************************************/
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)
7139

7240
/*****************************************************************************
7341
* STATIC VARIABLES
@@ -142,6 +110,7 @@ static bool verify_auth_wallet_inputs() {
142110
auth->challenge_size > CHALLENGE_SIZE_MAX) {
143111
inheritance_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,
144112
ERROR_DATA_FLOW_INVALID_QUERY);
113+
delay_scr_init(ui_text_inheritance_wallet_auth_fail, DELAY_TIME);
145114
return false;
146115
}
147116

@@ -195,12 +164,33 @@ static bool auth_wallet_get_signature() {
195164
unsigned_txn, unsigned_txn_size, auth->public_key, auth->signature);
196165

197166
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);
198170
return false;
199171
}
200172

201173
return true;
202174
}
203175

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+
}
204194
/*****************************************************************************
205195
* GLOBAL FUNCTIONS
206196
*****************************************************************************/
@@ -218,28 +208,8 @@ void inheritance_wallet_login(inheritance_query_t *query) {
218208
auth->is_setup = query->auth_wallet.initiate.is_public_key;
219209

220210
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);
242214
}
243-
244-
inheritance_send_result(&result);
245215
}

apps/inheritance_app/inheritance_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ void inheritance_main(usb_event_t usb_evt, const void *app_config) {
126126

127127
switch ((uint8_t)query.which_request) {
128128
case INHERITANCE_QUERY_AUTH_WALLET_TAG: {
129-
// TODO: Add auth wallet functionality
130129
inheritance_wallet_login(&query);
131130
break;
132131
}

apps/inheritance_app/inheritance_main.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,4 @@
4343
* @return A const reference to cy_app_desc_t
4444
*/
4545
const cy_app_desc_t *get_inheritance_app_desc();
46-
47-
/**
48-
* @brief Entry point to auth wallet flow
49-
*
50-
*/
51-
void inheritance_wallet_login(inheritance_query_t *query);
52-
5346
#endif /* INHERITANCE_MAIN_H */

apps/inheritance_app/inheritance_priv.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,60 @@
1717
#include <stdint.h>
1818

1919
#include "inheritance_context.h"
20+
#include "nem.h"
21+
22+
/*****************************************************************************
23+
* PRIVATE MACROS AND DEFINES
24+
*****************************************************************************/
25+
#define CHALLENGE_SIZE_MAX 32
26+
#define CHALLENGE_SIZE_MIN 16
27+
#define ENTROPY_SIZE_LIMIT 100
28+
29+
/*****************************************************************************
30+
* PRIVATE TYPEDEFS
31+
*****************************************************************************/
32+
typedef enum {
33+
AUTH_WALLET_OK = 0,
34+
AUTH_WALLET_TYPE_INVALID, // TODO: In inheriance app - Show error message
35+
// on ui that which assert is wrong
36+
AUTH_WALLET_INPUTS_INVALID, // TODO: In inheritance app - Add in wallet id
37+
// comparison, show error message on ui
38+
} auth_wallet_error_type_e;
39+
40+
#pragma pack(push, 1)
41+
typedef struct {
42+
uint8_t wallet_id[WALLET_ID_SIZE];
43+
uint8_t challenge[CHALLENGE_SIZE_MAX];
44+
size_t challenge_size;
45+
46+
const uint8_t entropy[ENTROPY_SIZE_LIMIT];
47+
uint8_t entropy_size;
48+
ed25519_secret_key private_key;
49+
50+
ed25519_signature signature;
51+
ed25519_public_key public_key;
52+
53+
bool is_setup;
54+
auth_wallet_error_type_e status;
55+
} auth_wallet_config_t;
56+
#pragma pack(pop)
2057

2158
/*****************************************************************************
2259
* TYPEDEFS
2360
*****************************************************************************/
2461

62+
/*****************************************************************************
63+
* EXPORTED VARIABLES
64+
*****************************************************************************/
65+
66+
/*****************************************************************************
67+
* GLOBAL FUNCTION PROTOTYPES
68+
*****************************************************************************/
69+
70+
/**
71+
* @brief Entry point to auth wallet flow
72+
*
73+
*/
74+
void inheritance_wallet_login(inheritance_query_t *query);
75+
2576
#endif /* INHERITANCE_PRIV_H */

src/card_operations/card_fetch_data.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,7 @@ typedef struct {
5151
*****************************************************************************/
5252

5353
/**
54-
* @brief Deletes wallet share data from a card.
55-
* @details This function initializes the applet, deletes the wallet data on
56-
* the card, and updates wallet data on flash accordingly. It handles various
57-
* error cases and returns an appropriate error code. For special case such as
58-
* incorrect pin, it indicates the no. of attempts left.
59-
*
60-
* @param delete_config A pointer to the configuration of the card delete
61-
* operation.
62-
* @param handle_wallet_deleted_from_card Function pointer that needs to be
63-
* called to handle successful deletion of wallet on a card. The function takes
64-
* the delete_config as an argument.
54+
* @brief
6555
*
6656
* @return A card_error_type_e value representing the result of the operation.
6757
*/

0 commit comments

Comments
 (0)