mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
Revert "trezor/utils: refactor 'serialize_identity()'"
This reverts commit de217f75df
.
This commit is contained in:
parent
45b7a472c5
commit
2f440f17d3
@ -2,7 +2,7 @@ from trezor import ui
|
||||
from trezor.crypto.hashlib import sha256
|
||||
from trezor.messages.SignedIdentity import SignedIdentity
|
||||
from ustruct import pack, unpack
|
||||
from trezor.utils import chunks, serialize_identity
|
||||
from trezor.utils import chunks
|
||||
from apps.common.confirm import require_confirm
|
||||
from trezor.ui.text import Text
|
||||
|
||||
@ -51,6 +51,21 @@ async def require_confirm_sign_identity(ctx, identity, challenge_visual):
|
||||
await require_confirm(ctx, content)
|
||||
|
||||
|
||||
def serialize_identity(identity):
|
||||
s = ''
|
||||
if identity.proto:
|
||||
s += identity.proto + '://'
|
||||
if identity.user:
|
||||
s += identity.user + '@'
|
||||
if identity.host:
|
||||
s += identity.host
|
||||
if identity.port:
|
||||
s += ':' + identity.port
|
||||
if identity.path:
|
||||
s += identity.path
|
||||
return s
|
||||
|
||||
|
||||
def get_identity_path(identity: str, index: int):
|
||||
identity_hash = sha256(pack('<I', index) + identity).digest()
|
||||
|
||||
|
@ -64,21 +64,6 @@ def format_ordinal(number):
|
||||
return str(number) + {1: 'st', 2: 'nd', 3: 'rd'}.get(4 if 10 <= number % 100 < 20 else number % 10, 'th')
|
||||
|
||||
|
||||
def serialize_identity(identity):
|
||||
s = ''
|
||||
if identity.proto:
|
||||
s += identity.proto + '://'
|
||||
if identity.user:
|
||||
s += identity.user + '@'
|
||||
if identity.host:
|
||||
s += identity.host
|
||||
if identity.port:
|
||||
s += ':' + identity.port
|
||||
if identity.path:
|
||||
s += identity.path
|
||||
return s
|
||||
|
||||
|
||||
class HashWriter:
|
||||
|
||||
def __init__(self, hashfunc):
|
||||
|
Loading…
Reference in New Issue
Block a user