|
|
|
@ -81,7 +81,9 @@ STATIC mp_obj_t mod_trezorcrypto_bip39_generate(mp_obj_t strength) {
|
|
|
|
|
mp_raise_ValueError("Invalid bit strength (only 128, 160, 192, 224 and 256 values are allowed)");
|
|
|
|
|
}
|
|
|
|
|
const char *mnemo = mnemonic_generate(bits);
|
|
|
|
|
return mp_obj_new_str_copy(&mp_type_str, (const uint8_t *)mnemo, strlen(mnemo));
|
|
|
|
|
mp_obj_t res = mp_obj_new_str_copy(&mp_type_str, (const uint8_t *)mnemo, strlen(mnemo));
|
|
|
|
|
mnemonic_clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_bip39_generate_obj, mod_trezorcrypto_bip39_generate);
|
|
|
|
|
|
|
|
|
@ -96,7 +98,9 @@ STATIC mp_obj_t mod_trezorcrypto_bip39_from_data(mp_obj_t data) {
|
|
|
|
|
mp_raise_ValueError("Invalid data length (only 16, 20, 24, 28 and 32 bytes are allowed)");
|
|
|
|
|
}
|
|
|
|
|
const char *mnemo = mnemonic_from_data(bin.buf, bin.len);
|
|
|
|
|
return mp_obj_new_str_copy(&mp_type_str, (const uint8_t *)mnemo, strlen(mnemo));
|
|
|
|
|
mp_obj_t res = mp_obj_new_str_copy(&mp_type_str, (const uint8_t *)mnemo, strlen(mnemo));
|
|
|
|
|
mnemonic_clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_bip39_from_data_obj, mod_trezorcrypto_bip39_from_data);
|
|
|
|
|
|
|
|
|
|