Logo Decentralized Social Network

moeralib.crypto

Functions

digest_fingerprint(fingerprint)

Calculate a cryptographic digest of the fingerprint.

Parameters:
fingerprint:  bytes – the fingerprint
Return value:
bytes – the digest

generate_key()

Generate a pair of cryptographic keys.

Return value:
ec.EllipticCurvePrivateKey – the keys

generate_mnemonic_key()

Generate a pair of cryptographic keys with a mnemonic for the private key.

Return value:
(str, ec.EllipticCurvePrivateKey) – the mnemonic and the keys

mnemonic_to_private_key(mnemonic)

Restore a private key from the given mnemonic.

Parameters:
mnemonic:  str – the mnemonic
Return value:
ec.EllipticCurvePrivateKey – the private key

raw_private_key(private_key)

Convert a private key to the raw format to pass to the client.

Parameters:
private_key:  ec.EllipticCurvePrivateKey – the private key
Return value:
bytes – the raw private key

raw_public_key(public_key)

Convert a public key to the raw format used by the naming server.

Parameters:
public_key:  ec.EllipticCurvePublicKey – the public key
Return value:
bytes – the raw public key

raw_to_private_key(raw_private_key)

Restore a private key from the raw format.

Parameters:
raw_private_key:  bytes – the raw private key
Return value:
ec.EllipticCurvePrivateKey – the private key

raw_to_public_key(raw_public_key)

Restore a public key from the raw format.

Parameters:
raw_public_key:  bytes – the raw public key
Return value:
ec.EllipticCurvePublicKey – the public key

sign_fingerprint(fingerprint, private_key)

Sign a fingerprint with a private key.

Parameters:
fingerprint:  bytes – the fingerprint to be signed
private_key:  ec.EllipticCurvePrivateKey – the private key
Return value:
bytes – the signature

verify_fingerprint_signature(fingerprint, signature, public_key)

Verify a fingerprint signature with the given public key.

Parameters:
fingerprint:  bytes – the original fingerprint
signature:  bytes – the signature to be verified
public_key:  ec.EllipticCurvePublicKey – the public key for verification
Return value:
bool – True, if the signature is correct, False otherwise