minor changes in modtrezorcrypto docu

This commit is contained in:
Pavol Rusnak 2016-10-07 13:27:43 +02:00
parent 4023b83feb
commit 446ea33dc1
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
9 changed files with 100 additions and 10 deletions

View File

@ -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);
}
/// 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.
/// '''

View File

@ -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);
/// 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) {
mp_arg_check_num(n_args, n_kw, 3, 4, false);
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:
/// pass
/// '''
/// Update a PBKDF2 context
/// '''
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);
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);
/// def trezor.crypto.pbkdf2.Pbkdf2.key(self) -> bytes:
/// pass
/// '''
/// Retreive derived key
/// '''
STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_key(mp_obj_t self) {
mp_obj_Pbkdf2_t *o = MP_OBJ_TO_PTR(self);
vstr_t vstr;

View File

@ -1,4 +1,6 @@
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
def pbkdf2(prf: str, password: bytes, salt: bytes, iterations: int=None) -> Pbkdf2:
pass
'''
Create a PBKDF2 context
'''

View File

View 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.
'''

View File

View 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.
'''

View File

@ -1,8 +1,12 @@
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
def update(self, iterations: int) -> None:
pass
'''
Update a PBKDF2 context
'''
# ../extmod/modtrezorcrypto/modtrezorcrypto-pbkdf2.h
def key(self) -> bytes:
pass
'''
Retreive derived key
'''

View File

@ -12,10 +12,16 @@ def refresh() -> None
'''
# ../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.
When a bgcolor is set, the bar is drawn with rounded corners and bgcolor is used for background.
Renders a bar at position (x,y = upper left corner) with width w and height h of color color.
'''
# ../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
@ -102,3 +108,9 @@ def raw(reg: int, data: bytes) -> None:
'''
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.
'''