|
|
@ -1,7 +1,7 @@ |
|
|
|
from asn1crypto.keys import ECDomainParameters, ECPointBitString, ECPrivateKey, PrivateKeyAlgorithm, PrivateKeyInfo |
|
|
|
|
|
|
|
from coincurve.context import GLOBAL_CONTEXT |
|
|
|
from coincurve.ecdsa import cdata_to_der, der_to_cdata, deserialize_recoverable, recover, serialize_recoverable |
|
|
|
from coincurve.ecdsa import parse_compact, cdata_to_der, der_to_cdata, deserialize_recoverable, recover, serialize_recoverable |
|
|
|
from coincurve.flags import EC_COMPRESSED, EC_UNCOMPRESSED |
|
|
|
from coincurve.utils import ( |
|
|
|
bytes_to_hex, |
|
|
@ -249,6 +249,16 @@ class PublicKey: |
|
|
|
# A performance hack to avoid global bool() lookup. |
|
|
|
return not not verified |
|
|
|
|
|
|
|
def verify_compact(self, signature, message, hasher=sha256): |
|
|
|
msg_hash = hasher(message) if hasher is not None else message |
|
|
|
if len(msg_hash) != 32: |
|
|
|
raise ValueError('Message hash must be 32 bytes long.') |
|
|
|
|
|
|
|
verified = lib.secp256k1_ecdsa_verify(self.context.ctx, parse_compact(signature), msg_hash, self.public_key) |
|
|
|
|
|
|
|
# A performance hack to avoid global bool() lookup. |
|
|
|
return not not verified |
|
|
|
|
|
|
|
def add(self, scalar, update=False): |
|
|
|
scalar = pad_scalar(scalar) |
|
|
|
|
|
|
|