Logo Decentralized Social Network

moeralib/crypto

Functions

digestFingerprint(fingerprint)

Calculate a cryptographic digest of the fingerprint.

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

generateKey()

Generate a pair of cryptographic keys.

Return value:
Promise<crypto.KeyPairKeyObjectResult> – the keys

generateMnemonicKey()

Generate a private cryptographic key with a mnemonic.

Return value:
Promise<[string, crypto.KeyObject]> – the mnemonic and the key

mnemonicToPrivateKey(mnemonic)

Restore a private key from the given mnemonic.

Parameters:
mnemonic:  string – the mnemonic
Return value:
Promise<crypto.KeyObject> – the private key

rawPrivateKey(privateKey)

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

Parameters:
privateKey:  crypto.KeyObject – the private key
Return value:
Buffer – the raw private key

rawPublicKey(publicKey)

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

Parameters:
publicKey:  crypto.KeyObject – the public key
Return value:
Buffer – the raw public key

rawToPrivateKey(rawPrivateKey)

Restore a private key from the raw format.

Parameters:
rawPrivateKey:  Buffer – the raw private key
Return value:
crypto.KeyObject – the private key

rawToPublicKey(rawPublicKey)

Restore a public key from the raw format.

Parameters:
rawPublicKey:  Buffer – the raw public key
Return value:
crypto.KeyObject – the public key

signFingerprint(fingerprint, privateKey)

Sign a fingerprint with a private key.

Parameters:
fingerprint:  Buffer – the fingerprint to be signed
privateKey:  crypto.KeyObject – the private key
Return value:
Buffer – the signature

verifyFingerprintSignature(fingerprint, signature, publicKey)

Verify a fingerprint signature with the given public key.

Parameters:
fingerprint:  Buffer – the original fingerprint
signature:  Buffer – the signature to be verified
publicKey:  crypto.KeyObject – the public key for verification
Return value:
boolean – true, if the signature is correct, false otherwise