1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-08 13:42:41 +00:00

update docu strings in native code

This commit is contained in:
Pavol Rusnak 2016-09-23 17:25:34 +02:00
parent d32dc93c10
commit 8f80749870
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
16 changed files with 61 additions and 55 deletions

View File

@ -23,7 +23,10 @@ typedef struct _mp_obj_AES_t {
uint8_t ctr[AES_BLOCK_SIZE]; uint8_t ctr[AES_BLOCK_SIZE];
} mp_obj_AES_t; } mp_obj_AES_t;
/// def trezor.crypto.aes.AES(mode:int, key: bytes, iv: bytes=None) -> AES /// def trezor.crypto.aes.AES(mode:int, key: bytes, iv: bytes=None) -> AES:
/// '''
/// Create AES context
/// '''
STATIC mp_obj_t mod_TrezorCrypto_AES_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_AES_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, 2, 3, false); mp_arg_check_num(n_args, n_kw, 2, 3, false);
mp_obj_AES_t *o = m_new_obj(mp_obj_AES_t); mp_obj_AES_t *o = m_new_obj(mp_obj_AES_t);
@ -74,7 +77,10 @@ STATIC mp_obj_t mod_TrezorCrypto_AES_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def AES.crypt(self, data: bytes) -> bytes /// def trezor.crypto.aes.AES.update(self, data: bytes) -> bytes:
/// '''
/// Update AES context
/// '''
STATIC mp_obj_t mod_TrezorCrypto_AES_update(mp_obj_t self, mp_obj_t data) { STATIC mp_obj_t mod_TrezorCrypto_AES_update(mp_obj_t self, mp_obj_t data) {
mp_buffer_info_t buf; mp_buffer_info_t buf;
mp_get_buffer_raise(data, &buf, MP_BUFFER_READ); mp_get_buffer_raise(data, &buf, MP_BUFFER_READ);

View File

@ -20,7 +20,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Bip39_make_new(const mp_obj_type_t *type, size_
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.bip39.generate(strength: int) -> str /// def trezor.crypto.bip39.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)
/// ''' /// '''
@ -37,7 +37,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Bip39_generate(mp_obj_t self, mp_obj_t strength
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_generate_obj, mod_TrezorCrypto_Bip39_generate); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_generate_obj, mod_TrezorCrypto_Bip39_generate);
/// def trezor.crypto.bip39.from_data(data: bytes) -> str /// def trezor.crypto.bip39.from_data(data: bytes) -> str:
/// ''' /// '''
/// Generate a mnemonic from given data (of 16, 20, 24, 28 and 32 bytes) /// Generate a mnemonic from given data (of 16, 20, 24, 28 and 32 bytes)
/// ''' /// '''
@ -55,7 +55,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Bip39_from_data(mp_obj_t self, mp_obj_t data) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_from_data_obj, mod_TrezorCrypto_Bip39_from_data); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_from_data_obj, mod_TrezorCrypto_Bip39_from_data);
/// def trezor.crypto.bip39.check(mnemonic: str) -> bool /// def trezor.crypto.bip39.check(mnemonic: str) -> bool:
/// ''' /// '''
/// Check whether given mnemonic is valid /// Check whether given mnemonic is valid
/// ''' /// '''
@ -66,7 +66,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Bip39_check(mp_obj_t self, mp_obj_t mnemonic) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_check_obj, mod_TrezorCrypto_Bip39_check); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Bip39_check_obj, mod_TrezorCrypto_Bip39_check);
/// def trezor.crypto.bip39.seed(mnemonic: str, passphrase: str) -> bytes /// def trezor.crypto.bip39.seed(mnemonic: str, passphrase: str) -> bytes:
/// ''' /// '''
/// Generate seed from mnemonic and passphrase /// Generate seed from mnemonic and passphrase
/// ''' /// '''

View File

@ -20,7 +20,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ed25519_make_new(const mp_obj_type_t *type, siz
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.curve.ed25519.publickey(secret_key: bytes) -> bytes /// def trezor.crypto.curve.ed25519.publickey(secret_key: bytes) -> bytes:
/// ''' /// '''
/// Computes public key from secret key. /// Computes public key from secret key.
/// ''' /// '''
@ -37,7 +37,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ed25519_publickey(mp_obj_t self, mp_obj_t secre
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Ed25519_publickey_obj, mod_TrezorCrypto_Ed25519_publickey); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Ed25519_publickey_obj, mod_TrezorCrypto_Ed25519_publickey);
/// def trezor.crypto.curve.ed25519.sign(secret_key: bytes, message: bytes) -> bytes /// def trezor.crypto.curve.ed25519.sign(secret_key: bytes, message: bytes) -> bytes:
/// ''' /// '''
/// Uses secret key to produce the signature of message. /// Uses secret key to produce the signature of message.
/// ''' /// '''
@ -57,7 +57,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ed25519_sign(mp_obj_t self, mp_obj_t secret_key
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Ed25519_sign_obj, mod_TrezorCrypto_Ed25519_sign); STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Ed25519_sign_obj, mod_TrezorCrypto_Ed25519_sign);
/// def trezor.crypto.curve.ed25519.verify(public_key: bytes, signature: bytes, message: bytes) -> bool /// def trezor.crypto.curve.ed25519.verify(public_key: bytes, signature: bytes, message: bytes) -> bool:
/// ''' /// '''
/// Uses public key to verify the signature of the message. /// Uses public key to verify the signature of the message.
/// Returns True on success. /// Returns True on success.

View File

@ -21,7 +21,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Nist256p1_make_new(const mp_obj_type_t *type, s
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.curve.nist256p1.publickey(secret_key: bytes, compressed: bool=True) -> bytes /// def trezor.crypto.curve.nist256p1.publickey(secret_key: bytes, compressed: bool=True) -> bytes:
/// ''' /// '''
/// Computes public key from secret key. /// Computes public key from secret key.
/// ''' /// '''
@ -44,7 +44,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Nist256p1_publickey(size_t n_args, const mp_obj
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_Nist256p1_publickey_obj, 2, 3, mod_TrezorCrypto_Nist256p1_publickey); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_Nist256p1_publickey_obj, 2, 3, mod_TrezorCrypto_Nist256p1_publickey);
/// def trezor.crypto.curve.nist256p1.sign(secret_key: bytes, message: bytes) -> bytes /// def trezor.crypto.curve.nist256p1.sign(secret_key: bytes, message: bytes) -> bytes:
/// ''' /// '''
/// Uses secret key to produce the signature of message. /// Uses secret key to produce the signature of message.
/// ''' /// '''
@ -66,7 +66,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Nist256p1_sign(mp_obj_t self, mp_obj_t secret_k
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Nist256p1_sign_obj, mod_TrezorCrypto_Nist256p1_sign); STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Nist256p1_sign_obj, mod_TrezorCrypto_Nist256p1_sign);
/// def trezor.crypto.curve.nist256p1.verify(public_key: bytes, signature: bytes, message: bytes) -> bool /// def trezor.crypto.curve.nist256p1.verify(public_key: bytes, signature: bytes, message: bytes) -> bool:
/// ''' /// '''
/// Uses public key to verify the signature of the message /// Uses public key to verify the signature of the message
/// Returns True on success. /// Returns True on success.

View File

@ -20,7 +20,7 @@ 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:
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);
@ -52,7 +52,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Pbkdf2_make_new(const mp_obj_type_t *type, size
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Pbkdf2.update(self, iterations: int) -> None /// def trezor.crypto.pbkdf2.Pbkdf2.update(self, iterations: int) -> None:
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);
@ -66,7 +66,7 @@ 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 Pbkdf2.key(self) -> bytes /// def trezor.crypto.pbkdf2.Pbkdf2.key(self) -> bytes:
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;

View File

@ -20,7 +20,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Random_make_new(const mp_obj_type_t *type, size
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.random.uniform(n: int) -> int /// def trezor.crypto.random.uniform(n: int) -> int:
/// ''' /// '''
/// Compute uniform random number from interval 0 ... n - 1 /// Compute uniform random number from interval 0 ... n - 1
/// ''' /// '''
@ -33,7 +33,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Random_uniform(mp_obj_t self, mp_obj_t n) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_uniform_obj, mod_TrezorCrypto_Random_uniform); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_uniform_obj, mod_TrezorCrypto_Random_uniform);
/// def trezor.crypto.random.bytes(len: int) -> bytes /// def trezor.crypto.random.bytes(len: int) -> bytes:
/// ''' /// '''
/// Generate random bytes sequence of length len /// Generate random bytes sequence of length len
/// ''' /// '''
@ -46,7 +46,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Random_bytes(mp_obj_t self, mp_obj_t len) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_bytes_obj, mod_TrezorCrypto_Random_bytes); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Random_bytes_obj, mod_TrezorCrypto_Random_bytes);
/// def trezor.crypto.random.shuffle(data: list) -> None /// def trezor.crypto.random.shuffle(data: list) -> None:
/// ''' /// '''
/// Shuffles items of given list (in-place) /// Shuffles items of given list (in-place)
/// ''' /// '''

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_Ripemd160_t {
STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data); STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data);
/// def trezor.crypto.hashlib.ripemd160(data: bytes=None) -> Ripemd160 /// def trezor.crypto.hashlib.ripemd160(data: bytes=None) -> Ripemd160:
/// ''' /// '''
/// Creates a hash context object. /// Creates a hash context object.
/// ''' /// '''
@ -35,7 +35,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_make_new(const mp_obj_type_t *type, s
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Ripemd160.update(self, data: bytes) -> None /// def trezor.crypto.hashlib.Ripemd160.update(self, data: bytes) -> None:
/// ''' /// '''
/// Update the hash context with hashed data. /// Update the hash context with hashed data.
/// ''' /// '''
@ -48,7 +48,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data)
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Ripemd160_update_obj, mod_TrezorCrypto_Ripemd160_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Ripemd160_update_obj, mod_TrezorCrypto_Ripemd160_update);
/// def Ripemd160.digest(self) -> bytes /// def trezor.crypto.hashlib.Ripemd160.digest(self) -> bytes:
/// ''' /// '''
/// Returns the digest of hashed data. /// Returns the digest of hashed data.
/// ''' /// '''

View File

@ -21,7 +21,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Secp256k1_make_new(const mp_obj_type_t *type, s
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.curve.secp256k1.publickey(secret_key: bytes, compressed: bool=True) -> bytes /// def trezor.crypto.curve.secp256k1.publickey(secret_key: bytes, compressed: bool=True) -> bytes:
/// ''' /// '''
/// Computes public key from secret key. /// Computes public key from secret key.
/// ''' /// '''
@ -44,7 +44,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Secp256k1_publickey(size_t n_args, const mp_obj
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_Secp256k1_publickey_obj, 2, 3, mod_TrezorCrypto_Secp256k1_publickey); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_Secp256k1_publickey_obj, 2, 3, mod_TrezorCrypto_Secp256k1_publickey);
/// def trezor.crypto.curve.secp256k1.sign(secret_key: bytes, message: bytes) -> bytes /// def trezor.crypto.curve.secp256k1.sign(secret_key: bytes, message: bytes) -> bytes:
/// ''' /// '''
/// Uses secret key to produce the signature of message. /// Uses secret key to produce the signature of message.
/// ''' /// '''
@ -66,7 +66,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Secp256k1_sign(mp_obj_t self, mp_obj_t secret_k
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Secp256k1_sign_obj, mod_TrezorCrypto_Secp256k1_sign); STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorCrypto_Secp256k1_sign_obj, mod_TrezorCrypto_Secp256k1_sign);
/// def trezor.crypto.curve.secp256k1.verify(public_key: bytes, signature: bytes, message: bytes) -> bool /// def trezor.crypto.curve.secp256k1.verify(public_key: bytes, signature: bytes, message: bytes) -> bool:
/// ''' /// '''
/// Uses public key to verify the signature of the message /// Uses public key to verify the signature of the message
/// Returns True on success. /// Returns True on success.

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_Sha256_t {
STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data); STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data);
/// def trezor.crypto.hashlib.sha256(data: bytes=None) -> Sha256 /// def trezor.crypto.hashlib.sha256(data: bytes=None) -> Sha256:
/// ''' /// '''
/// Creates a hash context object. /// Creates a hash context object.
/// ''' /// '''
@ -35,7 +35,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha256_make_new(const mp_obj_type_t *type, size
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Sha256.update(self, data: bytes) -> None /// def trezor.crypto.hashlib.Sha256.update(self, data: bytes) -> None:
/// ''' /// '''
/// Update the hash context with hashed data. /// Update the hash context with hashed data.
/// ''' /// '''
@ -48,7 +48,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha256_update_obj, mod_TrezorCrypto_Sha256_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha256_update_obj, mod_TrezorCrypto_Sha256_update);
/// def Sha256.digest(self) -> bytes /// def trezor.crypto.hashlib.Sha256.digest(self) -> bytes:
/// ''' /// '''
/// Returns the digest of hashed data. /// Returns the digest of hashed data.
/// ''' /// '''

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_Sha3_256_t {
STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data); STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data);
/// def trezor.crypto.hashlib.sha3_256(data: bytes=None) -> Sha3_256 /// def trezor.crypto.hashlib.sha3_256(data: bytes=None) -> Sha3_256:
/// ''' /// '''
/// Creates a hash context object. /// Creates a hash context object.
/// ''' /// '''
@ -35,7 +35,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_make_new(const mp_obj_type_t *type, si
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Sha3_256.update(self, data: bytes) -> None /// def trezor.crypto.hashlib.Sha3_256.update(self, data: bytes) -> None:
/// ''' /// '''
/// Update the hash context with hashed data. /// Update the hash context with hashed data.
/// ''' /// '''
@ -48,7 +48,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_256_update(mp_obj_t self, mp_obj_t data) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_256_update_obj, mod_TrezorCrypto_Sha3_256_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_256_update_obj, mod_TrezorCrypto_Sha3_256_update);
/// def Sha3_256.digest(self) -> bytes /// def trezor.crypto.hashlib.Sha3_256.digest(self) -> bytes:
/// ''' /// '''
/// Returns the digest of hashed data. /// Returns the digest of hashed data.
/// ''' /// '''

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_Sha3_512_t {
STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data); STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data);
/// def trezor.crypto.hashlib.sha3_512(data: bytes=None) -> Sha3_512 /// def trezor.crypto.hashlib.sha3_512(data: bytes=None) -> Sha3_512:
/// ''' /// '''
/// Creates a hash context object. /// Creates a hash context object.
/// ''' /// '''
@ -35,7 +35,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_make_new(const mp_obj_type_t *type, si
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Sha3_512.update(self, data: bytes) -> None /// def trezor.crypto.hashlib.Sha3_512.update(self, data: bytes) -> None:
/// ''' /// '''
/// Update the hash context with hashed data. /// Update the hash context with hashed data.
/// ''' /// '''
@ -48,7 +48,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha3_512_update(mp_obj_t self, mp_obj_t data) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_512_update_obj, mod_TrezorCrypto_Sha3_512_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha3_512_update_obj, mod_TrezorCrypto_Sha3_512_update);
/// def Sha3_512.digest(self) -> bytes /// def trezor.crypto.hashlib.Sha3_512.digest(self) -> bytes:
/// ''' /// '''
/// Returns the digest of hashed data. /// Returns the digest of hashed data.
/// ''' /// '''

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_Sha512_t {
STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data); STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data);
/// def trezor.crypto.hashlib.sha512(data: bytes=None) -> Sha512 /// def trezor.crypto.hashlib.sha512(data: bytes=None) -> Sha512:
/// ''' /// '''
/// Creates a hash context object. /// Creates a hash context object.
/// ''' /// '''
@ -34,7 +34,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha512_make_new(const mp_obj_type_t *type, size
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def Sha512.hash(self, data: bytes) -> None /// def trezor.crypto.hashlib.Sha512.hash(self, data: bytes) -> None:
/// ''' /// '''
/// Update the hash context with hashed data. /// Update the hash context with hashed data.
/// ''' /// '''
@ -47,7 +47,7 @@ STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha512_update_obj, mod_TrezorCrypto_Sha512_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha512_update_obj, mod_TrezorCrypto_Sha512_update);
/// def Sha512.digest(self) -> bytes /// def trezor.crypto.hashlib.Sha512.digest(self) -> bytes:
/// ''' /// '''
/// Returns the digest of hashed data. /// Returns the digest of hashed data.
/// ''' /// '''

View File

@ -21,7 +21,7 @@ STATIC mp_obj_t mod_TrezorCrypto_SSSS_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.crypto.ssss.split(m: int, n: int, secret: bytes) -> tuple /// def trezor.crypto.ssss.split(m: int, n: int, secret: bytes) -> tuple:
/// ''' /// '''
/// Split secret to (M of N) shares using Shamir's Secret Sharing Scheme /// Split secret to (M of N) shares using Shamir's Secret Sharing Scheme
/// ''' /// '''
@ -53,7 +53,7 @@ STATIC mp_obj_t mod_TrezorCrypto_SSSS_split(size_t n_args, const mp_obj_t *args)
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_SSSS_split_obj, 4, 4, mod_TrezorCrypto_SSSS_split); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorCrypto_SSSS_split_obj, 4, 4, mod_TrezorCrypto_SSSS_split);
/// def trezor.crypto.ssss.combine(shares: tuple) -> bytes /// def trezor.crypto.ssss.combine(shares: tuple) -> bytes:
/// ''' /// '''
/// Combine M shares of Shamir's Secret Sharing Scheme into secret /// Combine M shares of Shamir's Secret Sharing Scheme into secret
/// ''' /// '''

View File

@ -27,7 +27,7 @@ STATIC mp_obj_t mod_TrezorDebug_Debug_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.debug.memaccess(address: int, length: int) -> bytes /// def trezor.debug.memaccess(address: int, length: int) -> bytes:
/// ''' /// '''
/// Creates a bytes object that can be used to access certain memory location. /// Creates a bytes object that can be used to access certain memory location.
/// ''' /// '''

View File

@ -36,7 +36,7 @@ STATIC mp_obj_t mod_TrezorMsg_Msg_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.msg.setup(ifaces: list) -> None /// def trezor.msg.setup(ifaces: list) -> None:
/// ''' /// '''
/// Configures USB interfaces with a list of tuples (interface_number, usage_page) /// Configures USB interfaces with a list of tuples (interface_number, usage_page)
/// ''' /// '''
@ -67,7 +67,7 @@ STATIC mp_obj_t mod_TrezorMsg_Msg_setup(mp_obj_t self, mp_obj_t ifaces) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorMsg_Msg_setup_obj, mod_TrezorMsg_Msg_setup); STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorMsg_Msg_setup_obj, mod_TrezorMsg_Msg_setup);
/// def trezor.msg.send(iface: int, message: bytes) -> int /// def trezor.msg.send(iface: int, message: bytes) -> int:
/// ''' /// '''
/// Sends message using USB HID (device) or UDP (emulator). /// Sends message using USB HID (device) or UDP (emulator).
/// ''' /// '''
@ -83,7 +83,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorMsg_Msg_send_obj, mod_TrezorMsg_Msg_s
#define TICK_RESOLUTION 1000 #define TICK_RESOLUTION 1000
#define TOUCH_IFACE 256 #define TOUCH_IFACE 256
/// def trezor.msg.select(timeout_us: int) -> tuple /// def trezor.msg.select(timeout_us: int) -> tuple:
/// ''' /// '''
/// Polls the event queue and returns the event object. /// Polls the event queue and returns the event object.
/// Function returns None if timeout specified in microseconds is reached. /// Function returns None if timeout specified in microseconds is reached.

View File

@ -21,7 +21,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(o); return MP_OBJ_FROM_PTR(o);
} }
/// def trezor.ui.display.bar(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> None /// def trezor.ui.display.bar(x: int, y: int, w: int, h: int, fgcolor: int, bgcolor: int=None, radius: int=None) -> 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 fgcolor.
/// When a bgcolor is set, the bar is drawn with rounded corners and bgcolor is used for background. /// When a bgcolor is set, the bar is drawn with rounded corners and bgcolor is used for background.
@ -46,7 +46,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_bar(size_t n_args, const mp_obj_t *args) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_bar_obj, 6, 8, mod_TrezorUi_Display_bar); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_bar_obj, 6, 8, mod_TrezorUi_Display_bar);
/// def trezor.ui.display.blit(x: int, y: int, w: int, h: int, data: bytes) -> None /// def trezor.ui.display.blit(x: int, y: int, w: int, h: int, data: bytes) -> None:
/// ''' /// '''
/// Renders rectangle at position (x,y = upper left corner) with width w and height h with data. /// Renders rectangle at position (x,y = upper left corner) with width w and height h with data.
/// The data needs to have the correct format. /// The data needs to have the correct format.
@ -66,7 +66,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_blit(size_t n_args, const mp_obj_t *args) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_blit_obj, 6, 6, mod_TrezorUi_Display_blit); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_blit_obj, 6, 6, mod_TrezorUi_Display_blit);
/// def trezor.ui.display.image(x: int, y: int, image: bytes) -> None /// def trezor.ui.display.image(x: int, y: int, image: bytes) -> None:
/// ''' /// '''
/// Renders an image at position (x,y). /// Renders an image at position (x,y).
/// The image needs to be in TREZOR Optimized Image Format (TOIF) - full-color mode. /// The image needs to be in TREZOR Optimized Image Format (TOIF) - full-color mode.
@ -94,7 +94,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_image(size_t n_args, const mp_obj_t *args)
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_image_obj, 4, 4, mod_TrezorUi_Display_image); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_image_obj, 4, 4, mod_TrezorUi_Display_image);
/// def trezor.ui.display.icon(x: int, y: int, icon: bytes, fgcolor: int, bgcolor: int) -> None /// def trezor.ui.display.icon(x: int, y: int, icon: bytes, fgcolor: int, bgcolor: int) -> None:
/// ''' /// '''
/// Renders an icon at position (x,y), fgcolor is used as foreground color, bgcolor as background. /// Renders an icon at position (x,y), fgcolor is used as foreground color, bgcolor as background.
/// The image needs to be in TREZOR Optimized Image Format (TOIF) - gray-scale mode. /// The image needs to be in TREZOR Optimized Image Format (TOIF) - gray-scale mode.
@ -124,7 +124,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_icon(size_t n_args, const mp_obj_t *args) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_icon_obj, 6, 6, mod_TrezorUi_Display_icon); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_icon_obj, 6, 6, mod_TrezorUi_Display_icon);
/// def trezor.ui.display.text(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None /// def trezor.ui.display.text(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
/// ''' /// '''
/// Renders left-aligned text at position (x,y) where x is left position and y is baseline. /// Renders left-aligned text at position (x,y) where x is left position and y is baseline.
/// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background. /// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background.
@ -142,7 +142,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_text(size_t n_args, const mp_obj_t *args) {
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_obj, 7, 7, mod_TrezorUi_Display_text); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_obj, 7, 7, mod_TrezorUi_Display_text);
/// def trezor.ui.display.text_center(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None /// def trezor.ui.display.text_center(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
/// ''' /// '''
/// Renders text centered at position (x,y) where x is text center and y is baseline. /// Renders text centered at position (x,y) where x is text center and y is baseline.
/// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background. /// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background.
@ -161,7 +161,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_text_center(size_t n_args, const mp_obj_t *
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_center_obj, 7, 7, mod_TrezorUi_Display_text_center); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_center_obj, 7, 7, mod_TrezorUi_Display_text_center);
/// def trezor.ui.display.text_right(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None /// def trezor.ui.display.text_right(x: int, y: int, text: bytes, font: int, fgcolor: int, bgcolor: int) -> None:
/// ''' /// '''
/// Renders right-aligned text at position (x,y) where x is right position and y is baseline. /// Renders right-aligned text at position (x,y) where x is right position and y is baseline.
/// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background. /// Font font is used for rendering, fgcolor is used as foreground color, bgcolor as background.
@ -180,7 +180,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_text_right(size_t n_args, const mp_obj_t *a
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_right_obj, 7, 7, mod_TrezorUi_Display_text_right); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_text_right_obj, 7, 7, mod_TrezorUi_Display_text_right);
/// def trezor.ui.display.text_width(text: bytes, font: int) -> int /// def trezor.ui.display.text_width(text: bytes, font: int) -> int:
/// ''' /// '''
/// Returns a width of text in pixels. Font font is used for rendering. /// Returns a width of text in pixels. Font font is used for rendering.
/// ''' /// '''
@ -193,7 +193,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_text_width(mp_obj_t self, mp_obj_t text, mp
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorUi_Display_text_width_obj, mod_TrezorUi_Display_text_width); STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_TrezorUi_Display_text_width_obj, mod_TrezorUi_Display_text_width);
/// def trezor.ui.display.qrcode(x: int, y: int, data: bytes, scale: int) -> None /// def trezor.ui.display.qrcode(x: int, y: int, data: bytes, scale: int) -> None:
/// ''' /// '''
/// Renders data encoded as a QR code at position (x,y). /// Renders data encoded as a QR code at position (x,y).
/// Scale determines a zoom factor. /// Scale determines a zoom factor.
@ -212,7 +212,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_qrcode(size_t n_args, const mp_obj_t *args)
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_qrcode_obj, 5, 5, mod_TrezorUi_Display_qrcode); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_qrcode_obj, 5, 5, mod_TrezorUi_Display_qrcode);
/// def trezor.ui.display.loader(progress: int, fgcolor: int, bgcolor: int, icon: bytes=None, iconfgcolor: int=None) -> None /// def trezor.ui.display.loader(progress: int, fgcolor: int, bgcolor: int, icon: bytes=None, iconfgcolor: int=None) -> None:
/// ''' /// '''
/// Renders a rotating loader graphic. /// Renders a rotating loader graphic.
/// Progress determines its position (0-1000), fgcolor is used as foreground color, bgcolor as background. /// Progress determines its position (0-1000), fgcolor is used as foreground color, bgcolor as background.
@ -253,7 +253,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_loader(size_t n_args, const mp_obj_t *args)
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_loader_obj, 4, 6, mod_TrezorUi_Display_loader); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_loader_obj, 4, 6, mod_TrezorUi_Display_loader);
/// def trezor.ui.display.orientation(degrees: int=None) -> int /// def trezor.ui.display.orientation(degrees: int=None) -> int:
/// ''' /// '''
/// Sets display orientation to 0, 90, 180 or 270 degrees. /// Sets display orientation to 0, 90, 180 or 270 degrees.
/// Everything needs to be redrawn again when this function is used. /// Everything needs to be redrawn again when this function is used.
@ -274,7 +274,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_orientation(size_t n_args, const mp_obj_t *
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_orientation_obj, 1, 2, mod_TrezorUi_Display_orientation); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_orientation_obj, 1, 2, mod_TrezorUi_Display_orientation);
/// def trezor.ui.display.backlight(val: int=None) -> int /// def trezor.ui.display.backlight(val: int=None) -> int:
/// ''' /// '''
/// Sets backlight intensity to the value specified in val. /// Sets backlight intensity to the value specified in val.
/// Call without the val parameter to just perform the read of the value. /// Call without the val parameter to just perform the read of the value.
@ -294,7 +294,7 @@ STATIC mp_obj_t mod_TrezorUi_Display_backlight(size_t n_args, const mp_obj_t *ar
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_backlight_obj, 1, 2, mod_TrezorUi_Display_backlight); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_TrezorUi_Display_backlight_obj, 1, 2, mod_TrezorUi_Display_backlight);
/// def trezor.ui.display.raw(reg: int, data: bytes) -> None /// def trezor.ui.display.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.
/// ''' /// '''