You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tongsuo_test.py", line 13, in
ciphertext = pubkey2.encrypt(msg)
^^^^^^^^^^^^^^^
AttributeError: '_EllipticCurvePublicKey' object has no attribute 'encrypt'
按照咱们readme里例子写的
实际检查发现问题在这里, pip install tongsuopy 的版本缺少了encrypt
class EllipticCurvePublicKey(metaclass=abc.ABCMeta):
@abc.abstractproperty
def curve(self) -> EllipticCurve:
"""
The EllipticCurve that this key is on.
"""
@abc.abstractproperty
def key_size(self) -> int:
"""
Bit size of a secret scalar for the curve.
"""
@abc.abstractmethod
def public_numbers(self) -> "EllipticCurvePublicNumbers":
"""
Returns an EllipticCurvePublicNumbers.
"""
@abc.abstractmethod
def public_bytes(
self,
encoding: _serialization.Encoding,
format: _serialization.PublicFormat,
) -> bytes:
"""
Returns the key serialized as bytes.
"""
@abc.abstractmethod
def verify(
self,
signature: bytes,
data: bytes,
signature_algorithm: EllipticCurveSignatureAlgorithm,
) -> None:
"""
Verifies the signature of the data.
"""
@classmethod
def from_encoded_point(
cls, curve: EllipticCurve, data: bytes
) -> "EllipticCurvePublicKey":
utils._check_bytes("data", data)
if not isinstance(curve, EllipticCurve):
raise TypeError("curve must be an EllipticCurve instance")
if len(data) == 0:
raise ValueError("data must not be an empty byte string")
if data[0] not in [0x02, 0x03, 0x04]:
raise ValueError("Unsupported elliptic curve point type")
from tongsuopy.backends.tongsuo import backend
return backend.load_elliptic_curve_public_bytes(curve, data)
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
仓库里的版本
class EllipticCurvePublicKey(metaclass=abc.ABCMeta):
@abc.abstractproperty
def curve(self) -> EllipticCurve:
"""
The EllipticCurve that this key is on.
"""
@abc.abstractproperty
def key_size(self) -> int:
"""
Bit size of a secret scalar for the curve.
"""
@abc.abstractmethod
def public_numbers(self) -> "EllipticCurvePublicNumbers":
"""
Returns an EllipticCurvePublicNumbers.
"""
@abc.abstractmethod
def public_bytes(
self,
encoding: _serialization.Encoding,
format: _serialization.PublicFormat,
) -> bytes:
"""
Returns the key serialized as bytes.
"""
@abc.abstractmethod
def verify(
self,
signature: bytes,
data: bytes,
signature_algorithm: EllipticCurveSignatureAlgorithm,
) -> None:
"""
Verifies the signature of the data.
"""
@abc.abstractmethod
def encrypt(self, data: bytes) -> bytes:
"""
Encrypts the data
"""
@classmethod
def from_encoded_point(
cls, curve: EllipticCurve, data: bytes
) -> "EllipticCurvePublicKey":
utils._check_bytes("data", data)
if not isinstance(curve, EllipticCurve):
raise TypeError("curve must be an EllipticCurve instance")
if len(data) == 0:
raise ValueError("data must not be an empty byte string")
if data[0] not in [0x02, 0x03, 0x04]:
raise ValueError("Unsupported elliptic curve point type")
from tongsuopy.backends.tongsuo import backend
return backend.load_elliptic_curve_public_bytes(curve, data)
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
The text was updated successfully, but these errors were encountered:
tongsuo_test.py", line 13, in
ciphertext = pubkey2.encrypt(msg)
^^^^^^^^^^^^^^^
AttributeError: '_EllipticCurvePublicKey' object has no attribute 'encrypt'
按照咱们readme里例子写的
实际检查发现问题在这里, pip install tongsuopy 的版本缺少了encrypt
仓库里的版本
The text was updated successfully, but these errors were encountered: