1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

Revert "trezor/utils: refactor 'serialize_identity()'"

This reverts commit de217f75df.
This commit is contained in:
Pavol Rusnak 2018-03-11 22:57:39 +01:00
parent 45b7a472c5
commit 2f440f17d3
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 16 additions and 16 deletions

View File

@ -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()

View File

@ -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):