mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
minor changes in modtrezorcrypto docu
This commit is contained in:
parent
4023b83feb
commit
446ea33dc1
@ -195,7 +195,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Bip32_make_new(const mp_obj_type_t *type, size_
|
|||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// def trezor.crypto.Bip32.from_seed(seed: bytes, curve_name: str) -> HDNode:
|
/// def trezor.crypto.bip32.from_seed(seed: bytes, curve_name: str) -> HDNode:
|
||||||
/// '''
|
/// '''
|
||||||
/// Construct a BIP0032 HD node from a BIP0039 seed value.
|
/// Construct a BIP0032 HD node from a BIP0039 seed value.
|
||||||
/// '''
|
/// '''
|
||||||
|
@ -21,7 +21,9 @@ typedef struct _mp_obj_Pbkdf2_t {
|
|||||||
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t data);
|
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t data);
|
||||||
|
|
||||||
/// def trezor.crypto.pbkdf2(prf: str, password: bytes, salt: bytes, iterations: int=None) -> Pbkdf2:
|
/// def trezor.crypto.pbkdf2(prf: str, password: bytes, salt: bytes, iterations: int=None) -> Pbkdf2:
|
||||||
/// pass
|
/// '''
|
||||||
|
/// Create a PBKDF2 context
|
||||||
|
/// '''
|
||||||
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
mp_arg_check_num(n_args, n_kw, 3, 4, false);
|
mp_arg_check_num(n_args, n_kw, 3, 4, false);
|
||||||
mp_obj_Pbkdf2_t *o = m_new_obj(mp_obj_Pbkdf2_t);
|
mp_obj_Pbkdf2_t *o = m_new_obj(mp_obj_Pbkdf2_t);
|
||||||
@ -61,7 +63,9 @@ STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_make_new(const mp_obj_type_t *type, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// def trezor.crypto.pbkdf2.Pbkdf2.update(self, iterations: int) -> None:
|
/// def trezor.crypto.pbkdf2.Pbkdf2.update(self, iterations: int) -> None:
|
||||||
/// pass
|
/// '''
|
||||||
|
/// Update a PBKDF2 context
|
||||||
|
/// '''
|
||||||
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t iterations) {
|
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t iterations) {
|
||||||
mp_obj_Pbkdf2_t *o = MP_OBJ_TO_PTR(self);
|
mp_obj_Pbkdf2_t *o = MP_OBJ_TO_PTR(self);
|
||||||
uint32_t iter = mp_obj_get_int(iterations);
|
uint32_t iter = mp_obj_get_int(iterations);
|
||||||
@ -76,7 +80,9 @@ STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t iteration
|
|||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Pbkdf2_update_obj, mod_TrezorCrypto_Pbkdf2_update);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Pbkdf2_update_obj, mod_TrezorCrypto_Pbkdf2_update);
|
||||||
|
|
||||||
/// def trezor.crypto.pbkdf2.Pbkdf2.key(self) -> bytes:
|
/// def trezor.crypto.pbkdf2.Pbkdf2.key(self) -> bytes:
|
||||||
/// pass
|
/// '''
|
||||||
|
/// Retreive derived key
|
||||||
|
/// '''
|
||||||
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_key(mp_obj_t self) {
|
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_key(mp_obj_t self) {
|
||||||
mp_obj_Pbkdf2_t *o = MP_OBJ_TO_PTR(self);
|
mp_obj_Pbkdf2_t *o = MP_OBJ_TO_PTR(self);
|
||||||
vstr_t vstr;
|
vstr_t vstr;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
||||||
def pbkdf2(prf: str, password: bytes, salt: bytes, iterations: int=None) -> Pbkdf2:
|
def pbkdf2(prf: str, password: bytes, salt: bytes, iterations: int=None) -> Pbkdf2:
|
||||||
pass
|
'''
|
||||||
|
Create a PBKDF2 context
|
||||||
|
'''
|
||||||
|
0
mocks/trezor/crypto/.mock-generated
Normal file
0
mocks/trezor/crypto/.mock-generated
Normal file
60
mocks/trezor/crypto/HDNode.py
Normal file
60
mocks/trezor/crypto/HDNode.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def derive(index: int) -> None:
|
||||||
|
'''
|
||||||
|
Derive a BIP0032 child node in place.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def derive_path(path: list) -> None:
|
||||||
|
'''
|
||||||
|
Go through a list of indexes and iteratively derive a child node in place.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def serialize_public(version: int) -> str:
|
||||||
|
'''
|
||||||
|
Serialize the public info from HD node to base58 string.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def serialize_private(version: int) -> str:
|
||||||
|
'''
|
||||||
|
Serialize the private info HD node to base58 string.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def depth() -> int:
|
||||||
|
'''
|
||||||
|
Returns a depth of the HD node.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def fingerprint() -> int:
|
||||||
|
'''
|
||||||
|
Returns a fingerprint of the HD node (hash of the parent public key).
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def child_num() -> int:
|
||||||
|
'''
|
||||||
|
Returns a child index of the HD node.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def chain_code() -> bytes:
|
||||||
|
'''
|
||||||
|
Returns a chain code of the HD node.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def public_key() -> bytes:
|
||||||
|
'''
|
||||||
|
Returns a public key of the HD node.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def private_key() -> bytes:
|
||||||
|
'''
|
||||||
|
Returns a private key of the HD node.
|
||||||
|
'''
|
0
mocks/trezor/crypto/__init__.py
Normal file
0
mocks/trezor/crypto/__init__.py
Normal file
6
mocks/trezor/crypto/bip32.py
Normal file
6
mocks/trezor/crypto/bip32.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
|
||||||
|
def from_seed(seed: bytes, curve_name: str) -> HDNode:
|
||||||
|
'''
|
||||||
|
Construct a BIP0032 HD node from a BIP0039 seed value.
|
||||||
|
'''
|
@ -1,8 +1,12 @@
|
|||||||
|
|
||||||
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
||||||
def update(self, iterations: int) -> None:
|
def update(self, iterations: int) -> None:
|
||||||
pass
|
'''
|
||||||
|
Update a PBKDF2 context
|
||||||
|
'''
|
||||||
|
|
||||||
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
|
||||||
def key(self) -> bytes:
|
def key(self) -> bytes:
|
||||||
pass
|
'''
|
||||||
|
Retreive derived key
|
||||||
|
'''
|
||||||
|
@ -12,10 +12,16 @@ def refresh() -> None
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
# ../extmod/modtrezorui/modtrezorui-display.h
|
# ../extmod/modtrezorui/modtrezorui-display.h
|
||||||
def bar(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> None:
|
def bar(x: int, y: int, w: int, h: int, color: int) -> None:
|
||||||
'''
|
'''
|
||||||
Renders a bar at position (x,y = upper left corner) with width w and height h of color fgcolor.
|
Renders a bar at position (x,y = upper left corner) with width w and height h of color color.
|
||||||
When a bgcolor is set, the bar is drawn with rounded corners and bgcolor is used for background.
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorui/modtrezorui-display.h
|
||||||
|
def bar_radius(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> None:
|
||||||
|
'''
|
||||||
|
Renders a rounded bar at position (x,y = upper left corner) with width w and height h of color fgcolor.
|
||||||
|
Background is set to bgcolor and corners are drawn with radius radius.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# ../extmod/modtrezorui/modtrezorui-display.h
|
# ../extmod/modtrezorui/modtrezorui-display.h
|
||||||
@ -102,3 +108,9 @@ def raw(reg: int, data: bytes) -> None:
|
|||||||
'''
|
'''
|
||||||
Performs a raw command on the display. Read the datasheet to learn more.
|
Performs a raw command on the display. Read the datasheet to learn more.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
# ../extmod/modtrezorui/modtrezorui-display.h
|
||||||
|
def save(filename: string) -> None:
|
||||||
|
'''
|
||||||
|
Saves current display contents to file filename.
|
||||||
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user