mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
more changes to api
This commit is contained in:
parent
0c954769d5
commit
8a0868c1f7
72
docs/api.md
72
docs/api.md
@ -2,16 +2,27 @@
|
||||
|
||||
Syntax used below are valid Python function declarations with anotations defined in [PEP 3107](https://www.python.org/dev/peps/pep-3107/).
|
||||
|
||||
``` python
|
||||
class bytes20(bytes): pass # bytes variable of exactly 20 bytes
|
||||
class bytes21(bytes): pass # bytes variable of exactly 21 bytes
|
||||
class bytes32(bytes): pass # bytes variable of exactly 32 bytes
|
||||
class bytes33(bytes): pass # bytes variable of exactly 33 bytes
|
||||
class bytes64(bytes): pass # bytes variable of exactly 64 bytes
|
||||
class bytes65(bytes): pass # bytes variable of exactly 65 bytes
|
||||
|
||||
class uint32(int): pass # 32-bit unsigned int
|
||||
```
|
||||
|
||||
##trezor.crypto
|
||||
|
||||
###trezor.crypto.ed25519
|
||||
|
||||
``` python
|
||||
def to_public(secret_key: bytes[32]) -> bytes[32]: # public_key
|
||||
def to_public(secret_key: bytes32) -> bytes32: # public_key
|
||||
|
||||
def sign(message: bytes, secret_key: bytes[32], public_key: bytes[32] = None) -> bytes[64]: # signature
|
||||
def sign(message: bytes, secret_key: bytes32, public_key: bytes32 = None) -> bytes64: # signature
|
||||
|
||||
def verify(message: bytes, public_key: bytes[32], signature: bytes[64]) -> bool: # valid
|
||||
def verify(message: bytes, public_key: bytes32, signature: bytes64) -> bool: # valid
|
||||
```
|
||||
|
||||
###trezor.crypto.func
|
||||
@ -19,58 +30,77 @@ def verify(message: bytes, public_key: bytes[32], signature: bytes[64]) -> bool:
|
||||
``` python
|
||||
def aes():
|
||||
|
||||
def base58():
|
||||
def base58_encode(data: bytes) -> bytes: # encoded
|
||||
|
||||
def hmac():
|
||||
def base58_decode(data: bytes) -> bytes: # decoded
|
||||
|
||||
def sha256():
|
||||
def base58_encode_check(data: bytes) -> bytes: # encoded
|
||||
|
||||
def ripemd160():
|
||||
def base58_decode_check(data: bytes) -> bytes: # decoded
|
||||
|
||||
def pbkdf2():
|
||||
def hmac_sha256(key: bytes, message: bytes) -> bytes32: # hmac
|
||||
|
||||
def hmac_sha512(key: bytes, message: bytes) -> bytes64: # hmac
|
||||
|
||||
def sha256(data: bytes) -> bytes32: # hashed
|
||||
|
||||
def sha512(data: bytes) -> bytes64: # hashed
|
||||
|
||||
def ripemd160(data: bytes) -> bytes20: # hashed
|
||||
|
||||
def pbkdf2_hmac_sha256(password: bytes, salt: bytes, iterations: uint32, keylen: uint32) -> bytes32: # key
|
||||
|
||||
def pbkdf2_hmac_sha512(password: bytes, salt: bytes, iterations: uint32, keylen: uint32) -> bytes32: # key
|
||||
```
|
||||
|
||||
###trezor.crypto.hd
|
||||
|
||||
TODO
|
||||
|
||||
###trezor.crypto.mnemonic
|
||||
|
||||
TODO
|
||||
|
||||
###trezor.crypto.nistp256
|
||||
|
||||
``` python
|
||||
def to_public(secret_key: bytes[32]) -> bytes[33]: # public_key
|
||||
def to_public(secret_key: bytes32) -> bytes33: # public_key
|
||||
|
||||
def sign(message: bytes, secret_key: bytes[32], public_key: bytes[33] = None) -> bytes[65]: # signature
|
||||
def sign(message: bytes, secret_key: bytes32, public_key: bytes33 = None) -> bytes65: # signature
|
||||
|
||||
def verify(message: bytes, public_key: bytes[33], signature: bytes[65]) -> bool: # valid
|
||||
def verify(message: bytes, public_key: bytes33, signature: bytes65) -> bool: # valid
|
||||
```
|
||||
|
||||
###trezor.crypto.secp256k1
|
||||
|
||||
``` python
|
||||
def to_public(secret_key: bytes[32]) -> bytes[33]: # public_key
|
||||
def to_public(secret_key: bytes32) -> bytes33: # public_key
|
||||
|
||||
def sign(message: bytes, secret_key: bytes[32], public_key: bytes[33] = None) -> bytes[65]: # signature
|
||||
def sign(message: bytes, secret_key: bytes32, public_key: bytes33 = None) -> bytes65: # signature
|
||||
|
||||
def verify(message: bytes, public_key: bytes[33], signature: bytes[65]) -> bool: # valid
|
||||
def verify(message: bytes, public_key: bytes33, signature: bytes65) -> bool: # valid
|
||||
```
|
||||
|
||||
##trezor.hw
|
||||
|
||||
###trezor.hw.button
|
||||
|
||||
TODO
|
||||
|
||||
###trezor.hw.display
|
||||
|
||||
TODO
|
||||
|
||||
##trezor.utils
|
||||
|
||||
###trezor.utils.qrenc
|
||||
|
||||
``` python
|
||||
enum QRLEVEL {
|
||||
L = 0,
|
||||
M = 1,
|
||||
Q = 2,
|
||||
H = 3,
|
||||
}
|
||||
class QrLevel(Enum):
|
||||
L = 0
|
||||
M = 1
|
||||
Q = 2
|
||||
H = 3
|
||||
|
||||
def encode(source: bytes, level: QRLEVEL = QRLEVEL.H) -> bool[][]: # qrcode
|
||||
def encode(source: bytes, level: QrLevel = QrLevel.H) -> (int, list): # size, data
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user