1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 00:08:10 +00:00

fix(core): fix typos in modtrezorcrypto-bip340.h

This commit is contained in:
Ondřej Vejpustek 2021-11-04 00:11:01 +01:00
parent 3612620268
commit f918cf9a27

View File

@ -28,7 +28,7 @@
/// """
/// Generate secret key.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_generate_secret() {
STATIC mp_obj_t mod_trezorcrypto_bip340_generate_secret() {
vstr_t sk = {0};
vstr_init_len(&sk, 32);
for (;;) {
@ -52,14 +52,14 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_generate_secret() {
}
return mp_obj_new_str_from_vstr(&mp_type_bytes, &sk);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypt_bip340_generate_secret_obj,
mod_trezorcrypt_bip340_generate_secret);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypto_bip340_generate_secret_obj,
mod_trezorcrypto_bip340_generate_secret);
/// def publickey(secret_key: bytes) -> bytes:
/// """
/// Computes public key from secret key.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_publickey(mp_obj_t secret_key) {
STATIC mp_obj_t mod_trezorcrypto_bip340_publickey(mp_obj_t secret_key) {
mp_buffer_info_t sk = {0};
mp_get_buffer_raise(secret_key, &sk, MP_BUFFER_READ);
if (sk.len != 32) {
@ -76,8 +76,8 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_publickey(mp_obj_t secret_key) {
return mp_obj_new_str_from_vstr(&mp_type_bytes, &pk);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypt_bip340_publickey_obj,
mod_trezorcrypt_bip340_publickey);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_bip340_publickey_obj,
mod_trezorcrypto_bip340_publickey);
/// def sign(
/// secret_key: bytes,
@ -86,8 +86,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypt_bip340_publickey_obj,
/// """
/// Uses secret key to produce the signature of the digest.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_sign(mp_obj_t secret_key,
mp_obj_t digest) {
STATIC mp_obj_t mod_trezorcrypto_bip340_sign(mp_obj_t secret_key,
mp_obj_t digest) {
mp_buffer_info_t sk = {0}, dig = {0};
mp_get_buffer_raise(secret_key, &sk, MP_BUFFER_READ);
mp_get_buffer_raise(digest, &dig, MP_BUFFER_READ);
@ -110,17 +110,17 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_sign(mp_obj_t secret_key,
return mp_obj_new_str_from_vstr(&mp_type_bytes, &sig);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypt_bip340_sign_obj,
mod_trezorcrypt_bip340_sign);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_bip340_sign_obj,
mod_trezorcrypto_bip340_sign);
/// def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool:
/// """
/// Uses public key to verify the signature of the digest.
/// Returns True on success.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_verify(mp_obj_t public_key,
mp_obj_t signature,
mp_obj_t digest) {
STATIC mp_obj_t mod_trezorcrypto_bip340_verify(mp_obj_t public_key,
mp_obj_t signature,
mp_obj_t digest) {
mp_buffer_info_t pk = {0}, sig = {0}, dig = {0};
mp_get_buffer_raise(public_key, &pk, MP_BUFFER_READ);
mp_get_buffer_raise(signature, &sig, MP_BUFFER_READ);
@ -139,8 +139,8 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_verify(mp_obj_t public_key,
(const uint8_t *)dig.buf);
return mp_obj_new_bool(ret == 0);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_trezorcrypt_bip340_verify_obj,
mod_trezorcrypt_bip340_verify);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_trezorcrypto_bip340_verify_obj,
mod_trezorcrypto_bip340_verify);
/// def tweak_public_key(
/// public_key: bytes,
@ -149,8 +149,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_trezorcrypt_bip340_verify_obj,
/// """
/// Tweaks the public key with the specified root_hash.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_tweak_public_key(size_t n_args,
const mp_obj_t *args) {
STATIC mp_obj_t mod_trezorcrypto_bip340_tweak_public_key(size_t n_args,
const mp_obj_t *args) {
mp_buffer_info_t pk = {0};
mp_get_buffer_raise(args[0], &pk, MP_BUFFER_READ);
if (pk.len != 32) {
@ -179,8 +179,8 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_tweak_public_key(size_t n_args,
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
mod_trezorcrypt_bip340_tweak_public_key_obj, 1, 2,
mod_trezorcrypt_bip340_tweak_public_key);
mod_trezorcrypto_bip340_tweak_public_key_obj, 1, 2,
mod_trezorcrypto_bip340_tweak_public_key);
/// def tweak_secret_key(
/// secret_key: bytes,
@ -189,8 +189,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
/// """
/// Tweaks the secret key with the specified root_hash.
/// """
STATIC mp_obj_t mod_trezorcrypt_bip340_tweak_secret_key(size_t n_args,
const mp_obj_t *args) {
STATIC mp_obj_t mod_trezorcrypto_bip340_tweak_secret_key(size_t n_args,
const mp_obj_t *args) {
mp_buffer_info_t sk = {0};
mp_get_buffer_raise(args[0], &sk, MP_BUFFER_READ);
if (sk.len != 32) {
@ -219,26 +219,26 @@ STATIC mp_obj_t mod_trezorcrypt_bip340_tweak_secret_key(size_t n_args,
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
mod_trezorcrypt_bip340_tweak_secret_key_obj, 1, 2,
mod_trezorcrypt_bip340_tweak_secret_key);
mod_trezorcrypto_bip340_tweak_secret_key_obj, 1, 2,
mod_trezorcrypto_bip340_tweak_secret_key);
STATIC const mp_rom_map_elem_t mod_trezorcrypt_bip340_globals_table[] = {
STATIC const mp_rom_map_elem_t mod_trezorcrypto_bip340_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bip340)},
{MP_ROM_QSTR(MP_QSTR_generate_secret),
MP_ROM_PTR(&mod_trezorcrypt_bip340_generate_secret_obj)},
MP_ROM_PTR(&mod_trezorcrypto_bip340_generate_secret_obj)},
{MP_ROM_QSTR(MP_QSTR_publickey),
MP_ROM_PTR(&mod_trezorcrypt_bip340_publickey_obj)},
{MP_ROM_QSTR(MP_QSTR_sign), MP_ROM_PTR(&mod_trezorcrypt_bip340_sign_obj)},
MP_ROM_PTR(&mod_trezorcrypto_bip340_publickey_obj)},
{MP_ROM_QSTR(MP_QSTR_sign), MP_ROM_PTR(&mod_trezorcrypto_bip340_sign_obj)},
{MP_ROM_QSTR(MP_QSTR_verify),
MP_ROM_PTR(&mod_trezorcrypt_bip340_verify_obj)},
MP_ROM_PTR(&mod_trezorcrypto_bip340_verify_obj)},
{MP_ROM_QSTR(MP_QSTR_tweak_public_key),
MP_ROM_PTR(&mod_trezorcrypt_bip340_tweak_public_key_obj)},
MP_ROM_PTR(&mod_trezorcrypto_bip340_tweak_public_key_obj)},
{MP_ROM_QSTR(MP_QSTR_tweak_secret_key),
MP_ROM_PTR(&mod_trezorcrypt_bip340_tweak_secret_key_obj)}};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypt_bip340_globals,
mod_trezorcrypt_bip340_globals_table);
MP_ROM_PTR(&mod_trezorcrypto_bip340_tweak_secret_key_obj)}};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_bip340_globals,
mod_trezorcrypto_bip340_globals_table);
STATIC const mp_obj_module_t mod_trezorcrypto_bip340_module = {
.base = {&mp_type_module},
.globals = (mp_obj_dict_t *)&mod_trezorcrypt_bip340_globals,
.globals = (mp_obj_dict_t *)&mod_trezorcrypto_bip340_globals,
};