mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-12 14:16:06 +00:00
chore(core): delete unused bip39/slip39 micropython/C bindings
[no changelog]
This commit is contained in:
parent
428ac8d2ac
commit
571bb79e33
@ -25,41 +25,6 @@
|
|||||||
|
|
||||||
/// package: trezorcrypto.bip39
|
/// package: trezorcrypto.bip39
|
||||||
|
|
||||||
/// def complete_word(prefix: str) -> str | None:
|
|
||||||
/// """
|
|
||||||
/// Return the first word from the wordlist starting with prefix.
|
|
||||||
/// """
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_bip39_complete_word(mp_obj_t prefix) {
|
|
||||||
mp_buffer_info_t pfx = {0};
|
|
||||||
mp_get_buffer_raise(prefix, &pfx, MP_BUFFER_READ);
|
|
||||||
if (pfx.len == 0) {
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
const char *word = mnemonic_complete_word(pfx.buf, pfx.len);
|
|
||||||
if (word) {
|
|
||||||
return mp_obj_new_str(word, strlen(word));
|
|
||||||
} else {
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_bip39_complete_word_obj,
|
|
||||||
mod_trezorcrypto_bip39_complete_word);
|
|
||||||
|
|
||||||
/// def word_completion_mask(prefix: str) -> int:
|
|
||||||
/// """
|
|
||||||
/// Return possible 1-letter suffixes for given word prefix.
|
|
||||||
/// Result is a bitmask, with 'a' on the lowest bit, 'b' on the second
|
|
||||||
/// lowest, etc.
|
|
||||||
/// """
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_bip39_word_completion_mask(mp_obj_t prefix) {
|
|
||||||
mp_buffer_info_t pfx = {0};
|
|
||||||
mp_get_buffer_raise(prefix, &pfx, MP_BUFFER_READ);
|
|
||||||
return mp_obj_new_int(mnemonic_word_completion_mask(pfx.buf, pfx.len));
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(
|
|
||||||
mod_trezorcrypto_bip39_word_completion_mask_obj,
|
|
||||||
mod_trezorcrypto_bip39_word_completion_mask);
|
|
||||||
|
|
||||||
/// def generate(strength: int) -> str:
|
/// def generate(strength: int) -> str:
|
||||||
/// """
|
/// """
|
||||||
/// Generate a mnemonic of given strength (128, 160, 192, 224 and 256 bits).
|
/// Generate a mnemonic of given strength (128, 160, 192, 224 and 256 bits).
|
||||||
@ -148,10 +113,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_bip39_seed_obj, 2,
|
|||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mod_trezorcrypto_bip39_globals_table[] = {
|
STATIC const mp_rom_map_elem_t mod_trezorcrypto_bip39_globals_table[] = {
|
||||||
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bip39)},
|
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bip39)},
|
||||||
{MP_ROM_QSTR(MP_QSTR_complete_word),
|
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_bip39_complete_word_obj)},
|
|
||||||
{MP_ROM_QSTR(MP_QSTR_word_completion_mask),
|
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_bip39_word_completion_mask_obj)},
|
|
||||||
{MP_ROM_QSTR(MP_QSTR_generate),
|
{MP_ROM_QSTR(MP_QSTR_generate),
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_bip39_generate_obj)},
|
MP_ROM_PTR(&mod_trezorcrypto_bip39_generate_obj)},
|
||||||
{MP_ROM_QSTR(MP_QSTR_from_data),
|
{MP_ROM_QSTR(MP_QSTR_from_data),
|
||||||
|
@ -24,47 +24,6 @@
|
|||||||
|
|
||||||
/// package: trezorcrypto.slip39
|
/// package: trezorcrypto.slip39
|
||||||
|
|
||||||
/// def word_completion_mask(prefix: int) -> int:
|
|
||||||
/// """
|
|
||||||
/// Calculates which buttons still can be pressed after some already were.
|
|
||||||
/// Returns a 9-bit bitmask, where each bit specifies which buttons
|
|
||||||
/// can be further pressed (there are still words in this combination).
|
|
||||||
/// LSB denotes first button.
|
|
||||||
///
|
|
||||||
/// Example: 110000110 - second, third, eighth and ninth button still can be
|
|
||||||
/// pressed.
|
|
||||||
/// """
|
|
||||||
STATIC mp_obj_t mod_trezorcrypto_slip39_word_completion_mask(mp_obj_t _prefix) {
|
|
||||||
uint16_t prefix = mp_obj_get_int(_prefix);
|
|
||||||
|
|
||||||
if (prefix < 1 || prefix > 9999) {
|
|
||||||
mp_raise_ValueError(
|
|
||||||
"Invalid button prefix (range between 1 and 9999 is allowed)");
|
|
||||||
}
|
|
||||||
return mp_obj_new_int_from_uint(slip39_word_completion_mask(prefix));
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(
|
|
||||||
mod_trezorcrypto_slip39_word_completion_mask_obj,
|
|
||||||
mod_trezorcrypto_slip39_word_completion_mask);
|
|
||||||
|
|
||||||
/// def button_sequence_to_word(prefix: int) -> str:
|
|
||||||
/// """
|
|
||||||
/// Finds the first word that fits the given button prefix.
|
|
||||||
/// """
|
|
||||||
STATIC mp_obj_t
|
|
||||||
mod_trezorcrypto_slip39_button_sequence_to_word(mp_obj_t _prefix) {
|
|
||||||
uint16_t prefix = mp_obj_get_int(_prefix);
|
|
||||||
|
|
||||||
const char *word = button_sequence_to_word(prefix);
|
|
||||||
if (word == NULL) {
|
|
||||||
mp_raise_ValueError("Invalid button prefix");
|
|
||||||
}
|
|
||||||
return mp_obj_new_str_copy(&mp_type_str, (const uint8_t *)word, strlen(word));
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(
|
|
||||||
mod_trezorcrypto_slip39_button_sequence_to_word_obj,
|
|
||||||
mod_trezorcrypto_slip39_button_sequence_to_word);
|
|
||||||
|
|
||||||
/// def word_index(word: str) -> int:
|
/// def word_index(word: str) -> int:
|
||||||
/// """
|
/// """
|
||||||
/// Finds index of given word.
|
/// Finds index of given word.
|
||||||
@ -104,10 +63,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_slip39_get_word_obj,
|
|||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mod_trezorcrypto_slip39_globals_table[] = {
|
STATIC const mp_rom_map_elem_t mod_trezorcrypto_slip39_globals_table[] = {
|
||||||
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_slip39)},
|
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_slip39)},
|
||||||
{MP_ROM_QSTR(MP_QSTR_word_completion_mask),
|
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_slip39_word_completion_mask_obj)},
|
|
||||||
{MP_ROM_QSTR(MP_QSTR_button_sequence_to_word),
|
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_slip39_button_sequence_to_word_obj)},
|
|
||||||
{MP_ROM_QSTR(MP_QSTR_word_index),
|
{MP_ROM_QSTR(MP_QSTR_word_index),
|
||||||
MP_ROM_PTR(&mod_trezorcrypto_slip39_word_index_obj)},
|
MP_ROM_PTR(&mod_trezorcrypto_slip39_word_index_obj)},
|
||||||
{MP_ROM_QSTR(MP_QSTR_get_word),
|
{MP_ROM_QSTR(MP_QSTR_get_word),
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
|
|
||||||
def complete_word(prefix: str) -> str | None:
|
|
||||||
"""
|
|
||||||
Return the first word from the wordlist starting with prefix.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
|
|
||||||
def word_completion_mask(prefix: str) -> int:
|
|
||||||
"""
|
|
||||||
Return possible 1-letter suffixes for given word prefix.
|
|
||||||
Result is a bitmask, with 'a' on the lowest bit, 'b' on the second
|
|
||||||
lowest, etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
|
# extmod/modtrezorcrypto/modtrezorcrypto-bip39.h
|
||||||
def generate(strength: int) -> str:
|
def generate(strength: int) -> str:
|
||||||
"""
|
"""
|
||||||
|
@ -1,25 +1,6 @@
|
|||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h
|
|
||||||
def word_completion_mask(prefix: int) -> int:
|
|
||||||
"""
|
|
||||||
Calculates which buttons still can be pressed after some already were.
|
|
||||||
Returns a 9-bit bitmask, where each bit specifies which buttons
|
|
||||||
can be further pressed (there are still words in this combination).
|
|
||||||
LSB denotes first button.
|
|
||||||
Example: 110000110 - second, third, eighth and ninth button still can be
|
|
||||||
pressed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h
|
|
||||||
def button_sequence_to_word(prefix: int) -> str:
|
|
||||||
"""
|
|
||||||
Finds the first word that fits the given button prefix.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h
|
# extmod/modtrezorcrypto/modtrezorcrypto-slip39.h
|
||||||
def word_index(word: str) -> int:
|
def word_index(word: str) -> int:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user