@@ -24,6 +24,7 @@ struct FlipBip39Scene1 {
24
24
25
25
typedef struct {
26
26
int strength ;
27
+ const char * seed ;
27
28
const char * mnemonic1 ;
28
29
const char * mnemonic2 ;
29
30
const char * mnemonic3 ;
@@ -63,7 +64,7 @@ void flipbip39_scene_1_draw(Canvas* canvas, FlipBip39Scene1Model* model) {
63
64
static void flipbip39_scene_1_model_init (FlipBip39Scene1Model * const model , const int strength ) {
64
65
// Generate a random mnemonic using trezor-crypto
65
66
model -> strength = strength ;
66
- const char * mnemonic = mnemonic_generate (strength );
67
+ const char * mnemonic = mnemonic_generate (model -> strength );
67
68
68
69
// Delineate 6 sections of the mnemonic
69
70
char * str = malloc (strlen (mnemonic ) + 1 );
@@ -78,7 +79,12 @@ static void flipbip39_scene_1_model_init(FlipBip39Scene1Model* const model, cons
78
79
}
79
80
}
80
81
81
- // Split the mnemonic into 6 parts
82
+ // Generate a seed from the mnemonic
83
+ uint8_t seed [64 ];
84
+ //mnemonic_to_seed(mnemonic, "", seed, 0);
85
+ model -> seed = (char * )seed ;
86
+
87
+ // Split the mnemonic into parts
82
88
char * ptr = strtok (str , "," );
83
89
int partnum = 0 ;
84
90
while (ptr != NULL )
@@ -97,12 +103,11 @@ static void flipbip39_scene_1_model_init(FlipBip39Scene1Model* const model, cons
97
103
ptr = strtok (NULL , "," );
98
104
}
99
105
106
+
100
107
// WIP / TODO: Generate a BIP32 root key from the mnemonic
101
108
102
109
// //bool root_set = false;
103
110
// HDNode root;
104
- // uint8_t seed[64];
105
- // mnemonic_to_seed(mnemonic, "", seed, 0);
106
111
// hdnode_from_seed(seed, 64, SECP256K1_NAME, &root);
107
112
// //root_set = true;
108
113
@@ -192,6 +197,7 @@ void flipbip39_scene_1_exit(void* context) {
192
197
{
193
198
// Clear the mnemonic from memory
194
199
model -> strength = 0 ;
200
+ memzero ((void * )model -> seed , strlen (model -> seed ));
195
201
memzero ((void * )model -> mnemonic1 , strlen (model -> mnemonic1 ));
196
202
memzero ((void * )model -> mnemonic2 , strlen (model -> mnemonic2 ));
197
203
memzero ((void * )model -> mnemonic3 , strlen (model -> mnemonic3 ));
0 commit comments