yuan-xy / libra-client

A python client for Libra network.
MIT License
30 stars 7 forks source link

Is sha3-256 hash type unsupported by hashlib.pbkdf2_hmac? #1

Closed sabgkang closed 5 years ago

sabgkang commented 5 years ago

Hi,

I tried to run py.test for test_client.py, 7 passed and only "test_transfer_coin()" failed. Anything I did wrong?

(py3Libra) D:\pythonEnvs\py3Libra\libra-client>py.test test\test_client.py ====== test session starts ======== platform win32 -- Python 3.7.2, pytest-5.1.2, py-1.8.0, pluggy-0.13.0 rootdir: D:\pythonEnvs\py3Libra\libra-client collected 8 items

test\test_client.py .......F [100%]

=======FAILURES ====== ___ test_transfer_coin ____

def test_transfer_coin():
  kfac = libra.KeyFactory.read_wallet_file('test/test.wallet')

test\test_client.py:53:


d:\pythonenvs\py3libra\lib\site-packages\libra_client-0.0.1-py3.7.egg\libra\key_factory.py:48: in read_wallet_file seed = cls.to_seed(arr[0])


cls = <class 'libra.key_factory.KeyFactory'> mnemonic = b'whip gain explain arrange oil siren senior cricket labor usage sport actor series cattle settle cradle hint real proud dizzy stumble amused vintage physical' passphrase = b'LIBRA WALLET: mnemonic salt prefix$LIBRA'

@classmethod
def to_seed(cls, mnemonic, passphrase="LIBRA"):
    mnemonic = mnemonic.encode("utf-8")
    passphrase = b"LIBRA WALLET: mnemonic salt prefix$" + passphrase.encode("utf-8")
  stretched = hashlib.pbkdf2_hmac("sha3-256", mnemonic, passphrase, 2048)

E ValueError: unsupported hash type

d:\pythonenvs\py3libra\lib\site-packages\libra_client-0.0.1-py3.7.egg\libra\key_factory.py:11: ValueError ======= warnings summary ========== d:\pythonenvs\py3libra\lib\site-packages\google\protobuf\descriptor.py:47 d:\pythonenvs\py3libra\lib\site-packages\google\protobuf\descriptor.py:47: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from google.protobuf.pyext import _message

-- Docs: https://docs.pytest.org/en/latest/warnings.html ======== 1 failed, 7 passed, 1 warnings in 5.80s =======

(py3Libra) D:\pythonEnvs\py3Libra\libra-client>`

yuan-xy commented 5 years ago

sha3-256 is noly optional in python3.7. If the system has openssl 1.1.0 above, seems there are sha3-* in python. May be you can update openssl and try again.

sabgkang commented 5 years ago

@yuan-xy Thank you very much for pointing out the direction. I tried on the latest Ubuntu (19.04),all tests passed nicely.