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

src/apps/common: add smartcash curve

This commit is contained in:
Leandro Reinaux 2018-10-12 23:13:18 -03:00 committed by Pavol Rusnak
parent ef464e1596
commit 33e9dac2fe
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# generated from coininfo.py.mako
# do not edit manually!
from trezor.crypto.base58 import blake256_32, groestl512d_32, sha256d_32
from trezor.crypto.base58 import blake256_32, groestl512d_32, sha3k_256, sha256d_32
from trezor.crypto.scripts import blake256_ripemd160_digest, sha256_ripemd160_digest
@ -54,6 +54,10 @@ class CoinInfo:
self.b58_hash = blake256_32
self.sign_hash_double = False
self.script_hash = blake256_ripemd160_digest
elif curve_name == "secp256k1-smart":
self.b58_hash = sha3k_256
self.sign_hash_double = False
self.script_hash = sha256_ripemd160_digest
else:
self.b58_hash = sha256d_32
self.sign_hash_double = True

View File

@ -1,6 +1,6 @@
# generated from coininfo.py.mako
# do not edit manually!
from trezor.crypto.base58 import blake256_32, groestl512d_32, sha256d_32
from trezor.crypto.base58 import blake256_32, groestl512d_32, sha3k_256, sha256d_32
from trezor.crypto.scripts import blake256_ripemd160_digest, sha256_ripemd160_digest
@ -54,6 +54,10 @@ class CoinInfo:
self.b58_hash = blake256_32
self.sign_hash_double = False
self.script_hash = blake256_ripemd160_digest
elif curve_name == "secp256k1-smart":
self.b58_hash = sha3k_256
self.sign_hash_double = False
self.script_hash = sha256_ripemd160_digest
else:
self.b58_hash = sha256d_32
self.sign_hash_double = True

View File

@ -77,6 +77,12 @@ def blake256_32(data: bytes) -> bytes:
return blake256(blake256(data).digest()).digest()[:4]
def sha3k_256(data: bytes) -> bytes:
from .hashlib import sha3_256
return sha3_256(data, keccak=True).digest()[:4]
def encode_check(data: bytes, digestfunc=sha256d_32) -> str:
"""
Convert bytes to base58 encoded string, append checksum.