mirror of https://github.com/nucypher/nucypher.git
Remove the dependency on coincurve
parent
484f8b91e2
commit
687830bd4d
1
Pipfile
1
Pipfile
|
@ -31,7 +31,6 @@ flask = "*"
|
||||||
# Third-Party Ethereum
|
# Third-Party Ethereum
|
||||||
py-evm = "*"
|
py-evm = "*"
|
||||||
eth-tester = "*"
|
eth-tester = "*"
|
||||||
coincurve = "*"
|
|
||||||
web3 = "<=5.12.3"
|
web3 = "<=5.12.3"
|
||||||
eth-utils = "<1.10"
|
eth-utils = "<1.10"
|
||||||
py-geth = "*"
|
py-geth = "*"
|
||||||
|
|
|
@ -18,7 +18,6 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import coincurve
|
|
||||||
import pytest
|
import pytest
|
||||||
from cryptography.hazmat.backends.openssl import backend
|
from cryptography.hazmat.backends.openssl import backend
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
@ -60,11 +59,15 @@ def get_signature_recovery_value(message: bytes,
|
||||||
if len(signature) != ecdsa_signature_size:
|
if len(signature) != ecdsa_signature_size:
|
||||||
raise ValueError(f"The signature size should be {ecdsa_signature_size} B.")
|
raise ValueError(f"The signature size should be {ecdsa_signature_size} B.")
|
||||||
|
|
||||||
|
hash_ctx = hashes.Hash(hashes.SHA256(), backend=backend)
|
||||||
|
hash_ctx.update(message)
|
||||||
|
message_hash = hash_ctx.finalize()
|
||||||
|
|
||||||
|
address = canonical_address_from_umbral_key(public_key)
|
||||||
for v in (0, 1):
|
for v in (0, 1):
|
||||||
v_byte = bytes([v])
|
v_byte = bytes([v])
|
||||||
recovered_pubkey = coincurve.PublicKey.from_signature_and_message(signature=signature + v_byte,
|
recovered = to_canonical_address(Account.recoverHash(message_hash, signature=signature + v_byte))
|
||||||
message=message)
|
if recovered == address:
|
||||||
if bytes(public_key) == recovered_pubkey.format(compressed=True):
|
|
||||||
return v_byte
|
return v_byte
|
||||||
else:
|
else:
|
||||||
raise ValueError("Signature recovery failed. "
|
raise ValueError("Signature recovery failed. "
|
||||||
|
|
Loading…
Reference in New Issue