UNPKG

moeralib

Version:

Library to interact with Moera decentralized social network

82 lines 3.15 kB
import crypto from 'crypto'; import { Fingerprint, FingerprintSchema } from "./fingerprint"; /** * Generate a pair of cryptographic keys. * * @return {Promise<crypto.KeyPairKeyObjectResult>} the keys */ export declare function generateKey(): Promise<crypto.KeyPairKeyObjectResult>; /** * Generate a private cryptographic key with a mnemonic. * * @return {Promise<[string, crypto.KeyObject]>} the mnemonic and the key */ export declare function generateMnemonicKey(): Promise<[string, crypto.KeyObject]>; /** * Restore a private key from the given mnemonic. * * @param {string} mnemonic - the mnemonic * @return {Promise<crypto.KeyObject>} the private key */ export declare function mnemonicToPrivateKey(mnemonic: string): Promise<crypto.KeyObject>; /** * Convert a public key to the raw format used by the naming server. * * @param {crypto.KeyObject} publicKey - the public key * @return {Buffer} the raw public key */ export declare function rawPublicKey(publicKey: crypto.KeyObject): Buffer; /** * Restore a public key from the raw format. * * @param {Buffer} rawPublicKey - the raw public key * @return {crypto.KeyObject} the public key */ export declare function rawToPublicKey(rawPublicKey: Buffer): crypto.KeyObject; /** * Convert a private key to the raw format to pass to the client. * * @param {crypto.KeyObject} privateKey - the private key * @return {Buffer} the raw private key */ export declare function rawPrivateKey(privateKey: crypto.KeyObject): Buffer; /** * Restore a private key from the raw format. * * @param {Buffer} rawPrivateKey - the raw private key * @return {crypto.KeyObject} the private key */ export declare function rawToPrivateKey(rawPrivateKey: Buffer): crypto.KeyObject; /** * Encode a fingerprint in the binary form, using the given fingerprint data and schema. * * @param {Fingerprint} fingerprint - the fingerprint data * @param {FingerprintSchema} schema - the fingerprint schema * @return {Buffer} the fingerprint in the binary form */ export declare function fingerprintBytes(fingerprint: Fingerprint, schema: FingerprintSchema): Buffer; /** * Calculate a cryptographic digest of the fingerprint. * * @param {Buffer} fingerprint - the fingerprint * @return {Buffer} the digest */ export declare function digestFingerprint(fingerprint: Buffer): Buffer; /** * Sign a fingerprint with a private key. * * @param {Buffer} fingerprint - the fingerprint to be signed * @param {crypto.KeyObject} privateKey - the private key * @return {Buffer} the signature */ export declare function signFingerprint(fingerprint: Buffer, privateKey: crypto.KeyObject): Buffer; /** * Verify a fingerprint signature with the given public key. * * @param {Buffer} fingerprint - the original fingerprint * @param {Buffer} signature - the signature to be verified * @param {crypto.KeyObject} publicKey - the public key for verification * @return {boolean} `true`, if the signature is correct, `false` otherwise */ export declare function verifyFingerprintSignature(fingerprint: Buffer, signature: Buffer, publicKey: crypto.KeyObject): boolean; //# sourceMappingURL=crypto.d.ts.map