1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-03 12:28:13 +00:00

WIP secbytes typing

This commit is contained in:
Pavol Rusnak 2020-04-06 14:26:30 +02:00
parent 6e0b25b2cc
commit 15f602076b
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
19 changed files with 53 additions and 53 deletions

View File

@ -51,8 +51,8 @@ STATIC const mp_obj_type_t mod_trezorcrypto_HDNode_type;
/// depth: int,
/// fingerprint: int,
/// child_num: int,
/// chain_code: bytes,
/// private_key: bytes = None,
/// chain_code: secbytes,
/// private_key: secbytes = None,
/// public_key: bytes = None,
/// curve_name: str = None,
/// ) -> None:
@ -328,7 +328,7 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_child_num(mp_obj_t self) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_HDNode_child_num_obj,
mod_trezorcrypto_HDNode_child_num);
/// def chain_code(self) -> bytes:
/// def chain_code(self) -> secbytes:
/// """
/// Returns a chain code of the HD node.
/// """
@ -339,7 +339,7 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_chain_code(mp_obj_t self) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_HDNode_chain_code_obj,
mod_trezorcrypto_HDNode_chain_code);
/// def private_key(self) -> bytes:
/// def private_key(self) -> secbytes:
/// """
/// Returns a private key of the HD node.
/// """
@ -350,7 +350,7 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_private_key(mp_obj_t self) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_HDNode_private_key_obj,
mod_trezorcrypto_HDNode_private_key);
/// def private_key_ext(self) -> bytes:
/// def private_key_ext(self) -> secbytes:
/// """
/// Returns a private key extension of the HD node.
/// """
@ -541,7 +541,7 @@ STATIC const mp_obj_type_t mod_trezorcrypto_HDNode_type = {
/// mock:global
/// def from_seed(seed: bytes, curve_name: str) -> HDNode:
/// def from_seed(seed: secbytes, curve_name: str) -> HDNode:
/// """
/// Construct a BIP0032 HD node from a BIP0039 seed value.
/// """
@ -583,7 +583,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_bip32_from_seed_obj,
#if !BITCOIN_ONLY
/// def from_mnemonic_cardano(mnemonic: str, passphrase: str) -> bytes:
/// def from_mnemonic_cardano(mnemonic: str, passphrase: str) -> secbytes:
/// """
/// Construct a HD node from a BIP-0039 mnemonic using the Icarus derivation
/// scheme, aka v2 derivation scheme.

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_Blake256_t {
STATIC mp_obj_t mod_trezorcrypto_Blake256_update(mp_obj_t self, mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -55,7 +55,7 @@ STATIC mp_obj_t mod_trezorcrypto_Blake256_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -41,9 +41,9 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2b_update(mp_obj_t self, mp_obj_t data);
/// def __init__(
/// self,
/// data: bytes = None,
/// data: secbytes = None,
/// outlen: int = blake2b.digest_size,
/// key: bytes = None,
/// key: secbytes = None,
/// personal: bytes = None,
/// ) -> None:
/// """
@ -109,7 +109,7 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2b_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -41,9 +41,9 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2s_update(mp_obj_t self, mp_obj_t data);
/// def __init__(
/// self,
/// data: bytes = None,
/// data: secbytes = None,
/// outlen: int = blake2s.digest_size,
/// key: bytes = None,
/// key: secbytes = None,
/// personal: bytes = None,
/// ) -> None:
/// """
@ -109,7 +109,7 @@ STATIC mp_obj_t mod_trezorcrypto_Blake2s_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -34,7 +34,7 @@ typedef struct _mp_obj_ChaCha20Poly1305_t {
int64_t alen, plen;
} mp_obj_ChaCha20Poly1305_t;
/// def __init__(self, key: bytes, nonce: bytes) -> None:
/// def __init__(self, key: secbytes, nonce: bytes) -> None:
/// """
/// Initialize the ChaCha20 + Poly1305 context for encryption or decryption
/// using a 32 byte key and 12 byte nonce as in the RFC 7539 style.

View File

@ -25,7 +25,7 @@
/// package: trezorcrypto.curve25519
/// def generate_secret() -> bytes:
/// def generate_secret() -> secbytes:
/// """
/// Generate secret key.
/// """
@ -42,7 +42,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(
mod_trezorcrypto_curve25519_generate_secret_obj,
mod_trezorcrypto_curve25519_generate_secret);
/// def publickey(secret_key: bytes) -> bytes:
/// def publickey(secret_key: secbytes) -> bytes:
/// """
/// Computes public key from secret key.
/// """
@ -59,7 +59,7 @@ STATIC mp_obj_t mod_trezorcrypto_curve25519_publickey(mp_obj_t secret_key) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_curve25519_publickey_obj,
mod_trezorcrypto_curve25519_publickey);
/// def multiply(secret_key: bytes, public_key: bytes) -> bytes:
/// def multiply(secret_key: secbytes, public_key: bytes) -> bytes:
/// """
/// Multiplies point defined by public_key with scalar defined by
/// secret_key. Useful for ECDH.

View File

@ -26,7 +26,7 @@
/// package: trezorcrypto.ed25519
/// def generate_secret() -> bytes:
/// def generate_secret() -> secbytes:
/// """
/// Generate secret key.
/// """
@ -42,7 +42,7 @@ STATIC mp_obj_t mod_trezorcrypto_ed25519_generate_secret() {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypto_ed25519_generate_secret_obj,
mod_trezorcrypto_ed25519_generate_secret);
/// def publickey(secret_key: bytes) -> bytes:
/// def publickey(secret_key: secbytes) -> bytes:
/// """
/// Computes public key from secret key.
/// """
@ -60,7 +60,7 @@ STATIC mp_obj_t mod_trezorcrypto_ed25519_publickey(mp_obj_t secret_key) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorcrypto_ed25519_publickey_obj,
mod_trezorcrypto_ed25519_publickey);
/// def sign(secret_key: bytes, message: bytes, hasher: str = "") -> bytes:
/// def sign(secret_key: secbytes, message: bytes, hasher: str = "") -> bytes:
/// """
/// Uses secret key to produce the signature of message.
/// """
@ -103,7 +103,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_ed25519_sign_obj, 2,
#if !BITCOIN_ONLY
/// def sign_ext(
/// secret_key: bytes, secret_extension: bytes, message: bytes
/// secret_key: secbytes, secret_extension: secbytes, message: bytes
/// ) -> bytes:
/// """
/// Uses secret key to produce the cardano signature of message.
@ -238,7 +238,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(
mod_trezorcrypto_ed25519_cosi_combine_signatures);
/// def cosi_sign(
/// secret_key: bytes,
/// secret_key: secbytes,
/// message: bytes,
/// nonce: bytes,
/// sigR: bytes,

View File

@ -41,7 +41,7 @@ typedef struct _mp_obj_Groestl512_t {
STATIC mp_obj_t mod_trezorcrypto_Groestl512_update(mp_obj_t self,
mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -58,7 +58,7 @@ STATIC mp_obj_t mod_trezorcrypto_Groestl512_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -24,7 +24,7 @@
/// package: trezorcrypto.nist256p1
/// def generate_secret() -> bytes:
/// def generate_secret() -> secbytes:
/// """
/// Generate secret key.
/// """
@ -54,7 +54,7 @@ STATIC mp_obj_t mod_trezorcrypto_nist256p1_generate_secret() {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypto_nist256p1_generate_secret_obj,
mod_trezorcrypto_nist256p1_generate_secret);
/// def publickey(secret_key: bytes, compressed: bool = True) -> bytes:
/// def publickey(secret_key: secbytes, compressed: bool = True) -> bytes:
/// """
/// Computes public key from secret key.
/// """
@ -81,7 +81,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
mod_trezorcrypto_nist256p1_publickey);
/// def sign(
/// secret_key: bytes, digest: bytes, compressed: bool = True
/// secret_key: secbytes, digest: bytes, compressed: bool = True
/// ) -> bytes:
/// """
/// Uses secret key to produce the signature of the digest.
@ -178,7 +178,7 @@ STATIC mp_obj_t mod_trezorcrypto_nist256p1_verify_recover(mp_obj_t signature,
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_nist256p1_verify_recover_obj,
mod_trezorcrypto_nist256p1_verify_recover);
/// def multiply(secret_key: bytes, public_key: bytes) -> bytes:
/// def multiply(secret_key: secbytes, public_key: bytes) -> bytes:
/// """
/// Multiplies point defined by public_key with scalar defined by
/// secret_key. Useful for ECDH.

View File

@ -47,8 +47,8 @@ STATIC mp_obj_t mod_trezorcrypto_Pbkdf2_update(mp_obj_t self, mp_obj_t data);
/// def __init__(
/// self,
/// prf: int,
/// password: bytes,
/// salt: bytes,
/// password: secbytes,
/// salt: secbytes,
/// iterations: int = None,
/// blocknr: int = 1,
/// ) -> None:

View File

@ -32,7 +32,7 @@ typedef struct _mp_obj_Rfc6979_t {
rfc6979_state rng;
} mp_obj_Rfc6979_t;
/// def __init__(self, secret_key: bytes, hash: bytes) -> None:
/// def __init__(self, secret_key: secbytes, hash: secbytes) -> None:
/// """
/// Initialize RFC6979 context from secret key and a hash.
/// """

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_Ripemd160_t {
STATIC mp_obj_t mod_trezorcrypto_Ripemd160_update(mp_obj_t self, mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -55,7 +55,7 @@ STATIC mp_obj_t mod_trezorcrypto_Ripemd160_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -24,7 +24,7 @@
/// package: trezorcrypto.secp256k1
/// def generate_secret() -> bytes:
/// def generate_secret() -> secbytes:
/// """
/// Generate secret key.
/// """
@ -54,7 +54,7 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_generate_secret() {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorcrypto_secp256k1_generate_secret_obj,
mod_trezorcrypto_secp256k1_generate_secret);
/// def publickey(secret_key: bytes, compressed: bool = True) -> bytes:
/// def publickey(secret_key: secbytes, compressed: bool = True) -> bytes:
/// """
/// Computes public key from secret key.
/// """
@ -103,7 +103,7 @@ enum {
#endif
/// def sign(
/// secret_key: bytes,
/// secret_key: secbytes,
/// digest: bytes,
/// compressed: bool = True,
/// canonical: int = None,
@ -216,7 +216,7 @@ STATIC mp_obj_t mod_trezorcrypto_secp256k1_verify_recover(mp_obj_t signature,
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_secp256k1_verify_recover_obj,
mod_trezorcrypto_secp256k1_verify_recover);
/// def multiply(secret_key: bytes, public_key: bytes) -> bytes:
/// def multiply(secret_key: secbytes, public_key: bytes) -> bytes:
/// """
/// Multiplies point defined by public_key with scalar defined by
/// secret_key. Useful for ECDH.

View File

@ -116,7 +116,7 @@ static const secp256k1_context *mod_trezorcrypto_get_secp256k1_context(
return o->secp256k1_ctx;
}
/// def generate_secret(self) -> bytes:
/// def generate_secret(self) -> secbytes:
/// """
/// Generate secret key.
/// """
@ -136,7 +136,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(
mod_trezorcrypto_secp256k1_zkp_generate_secret_obj,
mod_trezorcrypto_secp256k1_zkp_generate_secret);
/// def publickey(self, secret_key: bytes, compressed: bool = True) -> bytes:
/// def publickey(self, secret_key: secbytes, compressed: bool = True) -> bytes:
/// """
/// Computes public key from secret key.
/// """
@ -167,7 +167,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(
mod_trezorcrypto_secp256k1_context_publickey);
/// def sign(
/// self, secret_key: bytes, digest: bytes, compressed: bool = True
/// self, secret_key: secbytes, digest: bytes, compressed: bool = True
/// ) -> bytes:
/// """
/// Uses secret key to produce the signature of the digest.
@ -298,7 +298,7 @@ static int secp256k1_ecdh_hash_passthrough(uint8_t *output, const uint8_t *x,
return 1;
}
/// def multiply(self, secret_key: bytes, public_key: bytes) -> bytes:
/// def multiply(self, secret_key: secbytes, public_key: bytes) -> bytes:
/// """
/// Multiplies point defined by public_key with scalar defined by
/// secret_key. Useful for ECDH.

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha1_t {
STATIC mp_obj_t mod_trezorcrypto_Sha1_update(mp_obj_t self, mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -55,7 +55,7 @@ STATIC mp_obj_t mod_trezorcrypto_Sha1_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha256_t {
STATIC mp_obj_t mod_trezorcrypto_Sha256_update(mp_obj_t self, mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -55,7 +55,7 @@ STATIC mp_obj_t mod_trezorcrypto_Sha256_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -38,7 +38,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);
/// def __init__(self, data: bytes = None, keccak: bool = False) -> None:
/// def __init__(self, data: secbytes = None, keccak: bool = False) -> None:
/// """
/// Creates a hash context object.
/// """
@ -68,7 +68,7 @@ STATIC mp_obj_t mod_trezorcrypto_Sha3_256_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -38,7 +38,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);
/// def __init__(self, data: bytes = None, keccak: bool = False) -> None:
/// def __init__(self, data: secbytes = None, keccak: bool = False) -> None:
/// """
/// Creates a hash context object.
/// """
@ -68,7 +68,7 @@ STATIC mp_obj_t mod_trezorcrypto_Sha3_512_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """

View File

@ -37,7 +37,7 @@ typedef struct _mp_obj_Sha512_t {
STATIC mp_obj_t mod_trezorcrypto_Sha512_update(mp_obj_t self, mp_obj_t data);
/// def __init__(self, data: bytes = None) -> None:
/// def __init__(self, data: secbytes = None) -> None:
/// """
/// Creates a hash context object.
/// """
@ -54,7 +54,7 @@ STATIC mp_obj_t mod_trezorcrypto_Sha512_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(o);
}
/// def update(self, data: bytes) -> None:
/// def update(self, data: secbytes) -> None:
/// """
/// Update the hash context with hashed data.
/// """