Skip to content
Snippets Groups Projects
Commit 4f085da1 authored by Moul's avatar Moul
Browse files

[dep] #86: Replace pylibscrypt.scrypt by hashlib.scrypt

Specify parameters since they are mandatory
Remove pylibscrypt dependency
parent d8f0d6b6
No related branches found
No related tags found
No related merge requests found
Pipeline #9464 failed
...@@ -19,7 +19,6 @@ This library is used by two clients: ...@@ -19,7 +19,6 @@ This library is used by two clients:
## Requirements ## Requirements
- Python >= 3.5.3 - Python >= 3.5.3
- [aiohttp >= 3.6.1](https://pypi.org/pypi/aiohttp) - [aiohttp >= 3.6.1](https://pypi.org/pypi/aiohttp)
- [pylibscrypt](https://pypi.org/pypi/pylibscrypt)
- [libnacl](https://pypi.org/pypi/libnacl) - [libnacl](https://pypi.org/pypi/libnacl)
- [base58](https://pypi.org/pypi/base58) - [base58](https://pypi.org/pypi/base58)
- [attr](https://pypi.org/project/attr/) - [attr](https://pypi.org/project/attr/)
......
...@@ -6,7 +6,7 @@ duniter public and private keys ...@@ -6,7 +6,7 @@ duniter public and private keys
from typing import Union, Optional from typing import Union, Optional
import libnacl.public import libnacl.public
from pylibscrypt import scrypt from hashlib import scrypt
from .scrypt_params import ScryptParams from .scrypt_params import ScryptParams
from .base58 import Base58Encoder from .base58 import Base58Encoder
...@@ -38,11 +38,11 @@ class SecretKey(libnacl.public.SecretKey): ...@@ -38,11 +38,11 @@ class SecretKey(libnacl.public.SecretKey):
password = ensure_bytes(password) password = ensure_bytes(password)
seed = scrypt( seed = scrypt(
password, password,
salt, salt=salt,
scrypt_params.N, n=scrypt_params.N,
scrypt_params.r, r=scrypt_params.r,
scrypt_params.p, p=scrypt_params.p,
scrypt_params.seed_length, dklen=scrypt_params.seed_length,
) )
super().__init__(seed) super().__init__(seed)
......
...@@ -10,7 +10,7 @@ from typing import Optional, Union, TypeVar, Type ...@@ -10,7 +10,7 @@ from typing import Optional, Union, TypeVar, Type
import libnacl.sign import libnacl.sign
import pyaes import pyaes
from libnacl.utils import load_key from libnacl.utils import load_key
from pylibscrypt import scrypt from hashlib import scrypt
from .scrypt_params import ScryptParams from .scrypt_params import ScryptParams
from .base58 import Base58Encoder from .base58 import Base58Encoder
...@@ -56,11 +56,11 @@ class SigningKey(libnacl.sign.Signer): ...@@ -56,11 +56,11 @@ class SigningKey(libnacl.sign.Signer):
password = ensure_bytes(password) password = ensure_bytes(password)
seed = scrypt( seed = scrypt(
password, password,
salt, salt=salt,
scrypt_params.N, n=scrypt_params.N,
scrypt_params.r, r=scrypt_params.r,
scrypt_params.p, p=scrypt_params.p,
scrypt_params.seed_length, dklen=scrypt_params.seed_length,
) )
return cls(seed) return cls(seed)
...@@ -394,7 +394,7 @@ Data: {data}""".format( ...@@ -394,7 +394,7 @@ Data: {data}""".format(
# SCRYPT # SCRYPT
password_bytes = password.encode("utf-8") password_bytes = password.encode("utf-8")
scrypt_seed = scrypt(password_bytes, salt, 16384, 8, 8, 64) scrypt_seed = scrypt(password_bytes, salt=salt, n=16384, r=8, p=8, dklen=64)
derivedhalf1 = scrypt_seed[0:32] derivedhalf1 = scrypt_seed[0:32]
derivedhalf2 = scrypt_seed[32:64] derivedhalf2 = scrypt_seed[32:64]
...@@ -435,7 +435,7 @@ Data: {data}""".format( ...@@ -435,7 +435,7 @@ Data: {data}""".format(
# SCRYPT # SCRYPT
password_bytes = password.encode("utf-8") password_bytes = password.encode("utf-8")
scrypt_seed = scrypt(password_bytes, salt, 16384, 8, 8, 64) scrypt_seed = scrypt(password_bytes, salt=salt, n=16384, r=8, p=8, dklen=64)
derivedhalf1 = scrypt_seed[0:32] derivedhalf1 = scrypt_seed[0:32]
derivedhalf2 = scrypt_seed[32:64] derivedhalf2 = scrypt_seed[32:64]
......
...@@ -30,7 +30,6 @@ jsonschema = "^3.0.2" ...@@ -30,7 +30,6 @@ jsonschema = "^3.0.2"
pypeg2 = "^2.15.2" pypeg2 = "^2.15.2"
attrs = "^19.3.0" attrs = "^19.3.0"
base58 = "^2.0.0" base58 = "^2.0.0"
pylibscrypt = "^1.8.0"
libnacl = "^1.6.1" libnacl = "^1.6.1"
pyaes = "^1.6.1" pyaes = "^1.6.1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment