UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

56 lines (55 loc) 2.22 kB
/// <reference types="node" /> import { Buffer } from "buffer"; import { KeyPair } from "./types"; export declare function createPublicKey(privKey: Buffer): Buffer; export declare function randomBytes(size: number): Buffer; export declare function sha256(buffer: Buffer): Buffer; export declare const hash256: typeof sha256; export declare function hashConcat(items: Buffer[]): Buffer; /** * @param content the content that the signature signs. It will be digested before validating. * @param pubKey The pubKey to validate the signature with * @param signature the signature to validate * * @return true if signature ok, false otherwise */ export declare function checkSignature(content: Buffer, pubKey: Buffer, signature: Buffer): boolean; /** * @param digest the signed digest. It will not be digested before validating. * @param pubKey The pubKey to validate the signature with * @param signature the signature to validate * * @return true if signature ok, false otherwise */ export declare function checkDigestSignature(digest: Buffer, pubKey: Buffer, signature: Buffer | undefined): boolean; /** * @param content to sign. It will be digested before signing. * @param privKey The private key to sign the content with * * @return the signature */ export declare function sign(content: Buffer, privKey: Buffer): Buffer; /** * @param digestBuffer to sign. It will not be digested before signing. * @param privKey The private key to sign the digest with * * @return the signature */ export declare function signDigest(digestBuffer: Buffer, privKey: Buffer): Buffer; /** * Creates a key pair (which usually represents one user) * @param privKey to create key pair based on * @returns {{pubKey: Buffer, privKey: Buffer}} */ export declare function makeKeyPair(privKey?: Buffer | string): KeyPair; /** * Generates a 16bytes TUID (Text unique ID) (a 32characters long string) * @returns string */ export declare function makeTuid(): string; /** * Verify that keypair is correct. Providing the private key, this function returns its associated public key * @param privKey: Buffer * @returns {{pubKey: Buffer, privKey: Buffer}} */ export declare function verifyKeyPair(privKey: Buffer): KeyPair;