Logo Decentralized Social Network

moeralib.crypto

Functions

digest_fingerprint(fingerprint)

Calculate a cryptographic digest of the fingerprint.

Parameters:
fingerprintbytes – 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:
mnemonicstr – 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_keyec.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_keyec.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_keybytes – 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_keybytes – the raw public key
Return value:
ec.EllipticCurvePublicKey – the public key

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