latest.ipv8.keyvault.crypto

Module Contents

Classes

ECCrypto

A crypto object which provides a layer between Dispersy and low level eccrypographic features.

Attributes

_CURVES

logger

default_eccrypto

latest.ipv8.keyvault.crypto._CURVES: dict[str, tuple[cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve | None, str]]
latest.ipv8.keyvault.crypto.logger
class latest.ipv8.keyvault.crypto.ECCrypto

A crypto object which provides a layer between Dispersy and low level eccrypographic features.

Most methods are implemented by:

@author: Boudewijn Schoon @organization: Technical University Delft @contact: dispersy@frayja.com

However since then, most functionality was completely rewritten by:

@author: Niels Zeilemaker

property security_levels: list[str]

Returns the names of all available curves.

generate_key(security_level: str) latest.ipv8.types.PrivateKey

Generate a new Elliptic Curve object with a new public / private key pair.

Security can be u’low’, u’medium’, or u’high’ depending on how secure you need your Elliptic Curve to be. Currently these values translate into:

  • very-low: NID_sect163k1 ~42 byte signatures

  • low: NID_sect233k1 ~60 byte signatures

  • medium: NID_sect409k1 ~104 byte signatures

  • high: NID_sect571r1 ~144 byte signatures

Besides these predefined curves, all other curves provided by M2Crypto are also available. For a full list of available curves, see ec_get_curves().

@param security_level: Level of security {u’very-low’, u’low’, u’medium’, or u’high’}. @type security_level: unicode

key_to_bin(ec: latest.ipv8.keyvault.keys.Key) bytes

Convert the key to a binary format.

key_to_hash(ec: latest.ipv8.keyvault.keys.Key) bytes

Get a hash representation from a key.

is_valid_private_bin(string: bytes) bool

Returns True if the input is a valid public/private keypair stored in a binary format.

is_valid_public_bin(string: bytes) bool

Returns True if the input is a valid public key.

key_from_private_bin(string: bytes) latest.ipv8.types.PrivateKey

Get the EC from a public/private keypair stored in a binary format.

key_from_public_bin(string: bytes) latest.ipv8.types.PublicKey

Get the EC from a public key in binary format.

get_signature_length(ec: latest.ipv8.types.PublicKey) int

Returns the length, in bytes, of each signature made using EC.

create_signature(ec: latest.ipv8.types.PrivateKey, data: bytes) bytes

Returns the signature of DIGEST made using EC.

is_valid_signature(ec: latest.ipv8.types.PublicKey, data: bytes, signature: bytes) bool

Returns True when SIGNATURE matches the DIGEST made using EC.

latest.ipv8.keyvault.crypto.default_eccrypto