Logo Decentralized Social Network

moeralib.crypto

Functions

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:
mnemonicstr – the mnemonic
Return value:
ec.EllipticCurvePrivateKey – the private key

raw_public_key(public_key)

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

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

digest_fingerprint(fingerprint)

Calculate a cryptographic digest of the fingerprint.

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

sign_fingerprint(fingerprint, private_key)

Sign a fingerprint with a private key.

Parameters:
fingerprintbytes – the fingerprint to be signed
private_keyec.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:
fingerprintbytes – the original fingerprint
signaturebytes – the signature to be verified
public_keyec.EllipticCurvePublicKey – the public key for verification
Return value:
boolTrue, if the signature is correct, False otherwise