Logo Decentralized Social Network

moeralib/crypto

Functions

digestFingerprint(fingerprint)

Calculate a cryptographic digest of the fingerprint.

Parameters:
fingerprintBuffer – 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:
mnemonicstring – 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:
privateKeycrypto.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:
publicKeycrypto.KeyObject – the public key
Return value:
Buffer – the raw public key

rawToPrivateKey(rawPrivateKey)

Restore a private key from the raw format.

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

rawToPublicKey(rawPublicKey)

Restore a public key from the raw format.

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

signFingerprint(fingerprint, privateKey)

Sign a fingerprint with a private key.

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

verifyFingerprintSignature(fingerprint, signature, publicKey)

Verify a fingerprint signature with the given public key.

Parameters:
fingerprintBuffer – the original fingerprint
signatureBuffer – the signature to be verified
publicKeycrypto.KeyObject – the public key for verification
Return value:
booleantrue, if the signature is correct, false otherwise