ikeys

Module with interfaces for public/private keys classes.

class IPublicKey

Bases: ABC

Interface for a generic elliptic curve public key. Verify method is missing because not needed.

abstract classmethod FromBytes(key_bytes: bytes) IPublicKey

Construct class from key bytes.

Parameters:

key_bytes (bytes) – Key bytes

Returns:

IPublicKey object

Return type:

IPublicKey

Raises:

ValueError – If key bytes are not valid

abstract classmethod FromPoint(key_point: IPoint) IPublicKey

Construct class from key point.

Parameters:

key_point (IPoint object) – Key point

Returns:

IPublicKey object

Return type:

IPublicKey

Raises:

ValueError – If key point is not valid

abstract static CurveType() EllipticCurveTypes

Get the elliptic curve type.

Returns:

Elliptic curve type

Return type:

EllipticCurveTypes

classmethod IsValidBytes(key_bytes: bytes) bool

Return if the specified bytes represents a valid public key.

Parameters:

key_bytes (bytes) – Key bytes

Returns:

True if valid, false otherwise

Return type:

bool

classmethod IsValidPoint(key_point: IPoint) bool

Return if the specified point represents a valid public key.

Parameters:

key_point (IPoint object) – Key point

Returns:

True if valid, false otherwise

Return type:

bool

abstract static CompressedLength() int

Get the compressed key length.

Returns:

Compressed key length

Return type:

int

abstract static UncompressedLength() int

Get the uncompressed key length.

Returns:

Uncompressed key length

Return type:

int

abstract UnderlyingObject() Any

Get the underlying object.

Returns:

Underlying object

Return type:

Any

abstract RawCompressed() DataBytes

Return raw compressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

abstract RawUncompressed() DataBytes

Return raw uncompressed public key.

Returns:

DataBytes object

Return type:

DataBytes object

abstract Point() IPoint

Return the public key point.

Returns:

IPoint object

Return type:

IPoint object

class IPrivateKey

Bases: ABC

Interface for a generic elliptic curve private key. Sign method is missing because not needed.

abstract classmethod FromBytes(key_bytes: bytes) IPrivateKey

Construct class from key bytes.

Parameters:

key_bytes (bytes) – Key bytes

Returns:

IPrivateKey object

Return type:

IPrivateKey

Raises:

ValueError – If key bytes are not valid

abstract static CurveType() EllipticCurveTypes

Get the elliptic curve type.

Returns:

Elliptic curve type

Return type:

EllipticCurveTypes

classmethod IsValidBytes(key_bytes: bytes) bool

Return if the specified bytes represent a valid private key.

Parameters:

key_bytes (bytes) – key bytes

Returns:

True if valid, false otherwise

Return type:

bool

abstract static Length() int

Get the key length.

Returns:

Key length

Return type:

int

abstract UnderlyingObject() Any

Get the underlying object.

Returns:

Underlying object

Return type:

Any

abstract Raw() DataBytes

Return raw private key.

Returns:

DataBytes object

Return type:

DataBytes object

abstract PublicKey() IPublicKey

Get the public key correspondent to the private one.

Returns:

IPublicKey object

Return type:

IPublicKey object