mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
modify trezor.crypto.hash api to be similar to python api
This commit is contained in:
parent
7b702314a6
commit
60d45a5d34
@ -12,7 +12,7 @@ typedef struct _mp_obj_Base58_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Base58_t;
|
||||
|
||||
// def Base58.__init__(self):
|
||||
// def Base58.__init__(self)
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Base58_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Base58_t *o = m_new_obj(mp_obj_Base58_t);
|
||||
o->base.type = type;
|
||||
|
@ -6,34 +6,57 @@
|
||||
*/
|
||||
|
||||
#include "trezor-crypto/sha2.h"
|
||||
#include "py/objstr.h"
|
||||
|
||||
// class Sha256(object):
|
||||
typedef struct _mp_obj_Sha256_t {
|
||||
mp_obj_base_t base;
|
||||
SHA256_CTX ctx;
|
||||
} mp_obj_Sha256_t;
|
||||
|
||||
// def Sha256.__init__(self):
|
||||
// def Sha256.__init__(self, data: bytes = None)
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Sha256_t *o = m_new_obj(mp_obj_Sha256_t);
|
||||
o->base.type = type;
|
||||
sha256_Init(&(o->ctx));
|
||||
// constructor called with bytes/str as first parameter
|
||||
if (n_args == 1) {
|
||||
if (!MP_OBJ_IS_STR_OR_BYTES(args[0])) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Invalid argument"));
|
||||
}
|
||||
GET_STR_DATA_LEN(args[0], data, datalen);
|
||||
sha256_Update(&(o->ctx), data, datalen);
|
||||
} else if (n_args != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Invalid arguments"));
|
||||
}
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
// def Sha256.hash(self, data: bytes) -> bytes
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha256_hash(mp_obj_t self, mp_obj_t data) {
|
||||
// def Sha256.update(self, data: bytes) -> None
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha256_update(mp_obj_t self, mp_obj_t data) {
|
||||
mp_obj_Sha256_t *o = MP_OBJ_TO_PTR(self);
|
||||
mp_buffer_info_t databuf;
|
||||
mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ);
|
||||
sha256_Update(&(o->ctx), databuf.buf, databuf.len);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha256_update_obj, mod_TrezorCrypto_Sha256_update);
|
||||
|
||||
// def Sha256.digest(self) -> bytes
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha256_digest(mp_obj_t self) {
|
||||
mp_obj_Sha256_t *o = MP_OBJ_TO_PTR(self);
|
||||
vstr_t vstr;
|
||||
vstr_init_len(&vstr, 32); // 256 bit = 32 bytes
|
||||
sha256_Raw(databuf.buf, databuf.len, (uint8_t *)vstr.buf);
|
||||
sha256_Final((uint8_t *)vstr.buf, &(o->ctx));
|
||||
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha256_hash_obj, mod_TrezorCrypto_Sha256_hash);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha256_digest_obj, mod_TrezorCrypto_Sha256_digest);
|
||||
|
||||
// Sha256 stuff
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_TrezorCrypto_Sha256_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_hash), MP_ROM_PTR(&mod_TrezorCrypto_Sha256_hash_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&mod_TrezorCrypto_Sha256_update_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&mod_TrezorCrypto_Sha256_digest_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_TrezorCrypto_Sha256_locals_dict, mod_TrezorCrypto_Sha256_locals_dict_table);
|
||||
|
||||
|
@ -6,34 +6,57 @@
|
||||
*/
|
||||
|
||||
#include "trezor-crypto/sha2.h"
|
||||
#include "py/objstr.h"
|
||||
|
||||
// class Sha512(object):
|
||||
typedef struct _mp_obj_Sha512_t {
|
||||
mp_obj_base_t base;
|
||||
SHA512_CTX ctx;
|
||||
} mp_obj_Sha512_t;
|
||||
|
||||
// def Sha512.__init__(self):
|
||||
// def Sha512.__init__(self, data: bytes = None)
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha512_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Sha512_t *o = m_new_obj(mp_obj_Sha512_t);
|
||||
o->base.type = type;
|
||||
sha512_Init(&(o->ctx));
|
||||
// constructor called with bytes/str as first parameter
|
||||
if (n_args == 1) {
|
||||
if (!MP_OBJ_IS_STR_OR_BYTES(args[0])) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Invalid argument"));
|
||||
}
|
||||
GET_STR_DATA_LEN(args[0], data, datalen);
|
||||
sha512_Update(&(o->ctx), data, datalen);
|
||||
} else if (n_args != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Invalid arguments"));
|
||||
}
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
// def Sha512.hash(self, data: bytes) -> bytes
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha512_hash(mp_obj_t self, mp_obj_t data) {
|
||||
// def Sha512.hash(self, data: bytes) -> None
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha512_update(mp_obj_t self, mp_obj_t data) {
|
||||
mp_obj_Sha512_t *o = MP_OBJ_TO_PTR(self);
|
||||
mp_buffer_info_t databuf;
|
||||
mp_get_buffer_raise(data, &databuf, MP_BUFFER_READ);
|
||||
sha512_Update(&(o->ctx), databuf.buf, databuf.len);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha512_update_obj, mod_TrezorCrypto_Sha512_update);
|
||||
|
||||
// def Sha512.digest(self) -> bytes
|
||||
STATIC mp_obj_t mod_TrezorCrypto_Sha512_digest(mp_obj_t self) {
|
||||
mp_obj_Sha512_t *o = MP_OBJ_TO_PTR(self);
|
||||
vstr_t vstr;
|
||||
vstr_init_len(&vstr, 64); // 512 bit = 64 bytes
|
||||
sha512_Raw(databuf.buf, databuf.len, (uint8_t *)vstr.buf);
|
||||
sha512_Final((uint8_t *)vstr.buf, &(o->ctx));
|
||||
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_TrezorCrypto_Sha512_hash_obj, mod_TrezorCrypto_Sha512_hash);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_TrezorCrypto_Sha512_digest_obj, mod_TrezorCrypto_Sha512_digest);
|
||||
|
||||
// Sha512 stuff
|
||||
|
||||
STATIC const mp_rom_map_elem_t mod_TrezorCrypto_Sha512_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_hash), MP_ROM_PTR(&mod_TrezorCrypto_Sha512_hash_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&mod_TrezorCrypto_Sha512_update_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_digest), MP_ROM_PTR(&mod_TrezorCrypto_Sha512_digest_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mod_TrezorCrypto_Sha512_locals_dict, mod_TrezorCrypto_Sha512_locals_dict_table);
|
||||
|
||||
|
@ -32,7 +32,7 @@ typedef struct _mp_obj_Msg_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Msg_t;
|
||||
|
||||
// def Msg.__init__(self):
|
||||
// def Msg.__init__(self)
|
||||
STATIC mp_obj_t mod_TrezorMsg_Msg_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Msg_t *o = m_new_obj(mp_obj_Msg_t);
|
||||
o->base.type = type;
|
||||
|
@ -20,7 +20,7 @@ typedef struct _mp_obj_Protobuf_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Protobuf_t;
|
||||
|
||||
// def Protobuf.__init__(self):
|
||||
// def Protobuf.__init__(self)
|
||||
STATIC mp_obj_t mod_TrezorProtobuf_Protobuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Protobuf_t *o = m_new_obj(mp_obj_Protobuf_t);
|
||||
o->base.type = type;
|
||||
|
@ -156,7 +156,7 @@ typedef struct _mp_obj_Display_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Display_t;
|
||||
|
||||
// def Display.__init__(self):
|
||||
// def Display.__init__(self)
|
||||
STATIC mp_obj_t mod_TrezorUi_Display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
display_init();
|
||||
mp_obj_Display_t *o = m_new_obj(mp_obj_Display_t);
|
||||
|
@ -36,7 +36,7 @@ typedef struct _mp_obj_Touch_t {
|
||||
mp_obj_base_t base;
|
||||
} mp_obj_Touch_t;
|
||||
|
||||
// def Touch.__init__(self):
|
||||
// def Touch.__init__(self)
|
||||
STATIC mp_obj_t mod_TrezorUi_Touch_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_Touch_t *o = m_new_obj(mp_obj_Touch_t);
|
||||
o->base.type = type;
|
||||
|
@ -4,16 +4,45 @@ sys.path.append('../lib')
|
||||
import unittest
|
||||
import trezor.utils
|
||||
|
||||
import trezor.crypto.sha256
|
||||
import trezor.crypto.hash
|
||||
|
||||
class TestCryptoSha256(unittest.TestCase):
|
||||
|
||||
# vectors from http://www.di-mgt.com.au/sha_testvectors.html
|
||||
def test_hash(self):
|
||||
self.assertEqual(trezor.crypto.sha256.hash(b''), trezor.utils.unhexlify('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'))
|
||||
self.assertEqual(trezor.crypto.sha256.hash(b'abc'), trezor.utils.unhexlify('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'))
|
||||
self.assertEqual(trezor.crypto.sha256.hash(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'), trezor.utils.unhexlify('248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1'))
|
||||
self.assertEqual(trezor.crypto.sha256.hash(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'), trezor.utils.unhexlify('cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1'))
|
||||
|
||||
def test_digest(self):
|
||||
self.assertEqual(trezor.crypto.hash.sha256(b'').digest(), trezor.utils.unhexlify('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'))
|
||||
self.assertEqual(trezor.crypto.hash.sha256(b'abc').digest(), trezor.utils.unhexlify('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'))
|
||||
self.assertEqual(trezor.crypto.hash.sha256(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq').digest(), trezor.utils.unhexlify('248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1'))
|
||||
self.assertEqual(trezor.crypto.hash.sha256(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu').digest(), trezor.utils.unhexlify('cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1'))
|
||||
|
||||
def test_update(self):
|
||||
x = trezor.crypto.hash.sha256()
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'))
|
||||
|
||||
x = trezor.crypto.hash.sha256()
|
||||
x.update(b'abc')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'))
|
||||
|
||||
x = trezor.crypto.hash.sha256()
|
||||
x.update(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1'))
|
||||
|
||||
x = trezor.crypto.hash.sha256()
|
||||
x.update(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1'))
|
||||
|
||||
x = trezor.crypto.hash.sha256()
|
||||
for i in range(1000000):
|
||||
x.update(b'a')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0'))
|
||||
|
||||
'''
|
||||
x = trezor.crypto.hash.sha256()
|
||||
for i in range(16777216):
|
||||
x.update(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('50e72a0e26442fe2552dc3938ac58658228c0cbfb1d2ca872ae435266fcd055e'))
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -4,16 +4,45 @@ sys.path.append('../lib')
|
||||
import unittest
|
||||
import trezor.utils
|
||||
|
||||
import trezor.crypto.sha512
|
||||
import trezor.crypto.hash
|
||||
|
||||
class TestCryptoSha512(unittest.TestCase):
|
||||
|
||||
# vectors from http://www.di-mgt.com.au/sha_testvectors.html
|
||||
def test_hash(self):
|
||||
self.assertEqual(trezor.crypto.sha512.hash(b''), trezor.utils.unhexlify('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'))
|
||||
self.assertEqual(trezor.crypto.sha512.hash(b'abc'), trezor.utils.unhexlify('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'))
|
||||
self.assertEqual(trezor.crypto.sha512.hash(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'), trezor.utils.unhexlify('204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445'))
|
||||
self.assertEqual(trezor.crypto.sha512.hash(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'), trezor.utils.unhexlify('8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909'))
|
||||
|
||||
def test_digest(self):
|
||||
self.assertEqual(trezor.crypto.hash.sha512(b'').digest(), trezor.utils.unhexlify('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'))
|
||||
self.assertEqual(trezor.crypto.hash.sha512(b'abc').digest(), trezor.utils.unhexlify('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'))
|
||||
self.assertEqual(trezor.crypto.hash.sha512(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq').digest(), trezor.utils.unhexlify('204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445'))
|
||||
self.assertEqual(trezor.crypto.hash.sha512(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu').digest(), trezor.utils.unhexlify('8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909'))
|
||||
|
||||
def test_update(self):
|
||||
x = trezor.crypto.hash.sha512()
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'))
|
||||
|
||||
x = trezor.crypto.hash.sha512()
|
||||
x.update(b'abc')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'))
|
||||
|
||||
x = trezor.crypto.hash.sha512()
|
||||
x.update(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445'))
|
||||
|
||||
x = trezor.crypto.hash.sha512()
|
||||
x.update(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909'))
|
||||
|
||||
x = trezor.crypto.hash.sha512()
|
||||
for i in range(1000000):
|
||||
x.update(b'a')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b'))
|
||||
|
||||
'''
|
||||
x = trezor.crypto.hash.sha512()
|
||||
for i in range(16777216):
|
||||
x.update(b'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno')
|
||||
self.assertEqual(x.digest(), trezor.utils.unhexlify('b47c933421ea2db149ad6e10fce6c7f93d0752380180ffd7f4629a712134831d77be6091b819ed352c2967a2e2d4fa5050723c9630691f1a05a7281dbe6c1086'))
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -1,5 +1,5 @@
|
||||
from TrezorCrypto import Base58
|
||||
from . import sha256
|
||||
from .hash import sha256
|
||||
|
||||
_base58 = Base58()
|
||||
|
||||
@ -10,13 +10,13 @@ def decode(string):
|
||||
return _base58.decode(string)
|
||||
|
||||
def encode_check(data, hashlen=4):
|
||||
h = sha256.hash(sha256.hash(data))
|
||||
h = sha256(sha256(data).digest()).digest()
|
||||
return encode(data + h[:hashlen])
|
||||
|
||||
def decode_check(string, hashlen=4):
|
||||
data = decode(string)
|
||||
d, h1 = data[:-hashlen], data[-hashlen:]
|
||||
h2 = sha256.hash(sha256.hash(d))[:4]
|
||||
h2 = sha256(sha256(d).digest).digest()[:4]
|
||||
if h1 != h2:
|
||||
raise RuntimeError('Checksum error')
|
||||
return d
|
||||
|
2
src/trezor/crypto/hash.py
Normal file
2
src/trezor/crypto/hash.py
Normal file
@ -0,0 +1,2 @@
|
||||
from TrezorCrypto import Sha256 as sha256
|
||||
from TrezorCrypto import Sha512 as sha512
|
@ -1,6 +0,0 @@
|
||||
from TrezorCrypto import Sha256
|
||||
|
||||
_sha256 = Sha256()
|
||||
|
||||
def hash(data):
|
||||
return _sha256.hash(data)
|
@ -1,6 +0,0 @@
|
||||
from TrezorCrypto import Sha512
|
||||
|
||||
_sha512 = Sha512()
|
||||
|
||||
def hash(data):
|
||||
return _sha512.hash(data)
|
Loading…
Reference in New Issue
Block a user