UNPKG

1.6 kBTypeScriptView Raw
1/// <reference types="node" />
2export declare function bytesToHex(bytes: Uint8Array): string;
3export declare function numberToHex(num: number): string;
4export declare function hexToNumber(hex: string): number;
5export declare function bytesToHexAddr(bytes: Uint8Array): string;
6export declare function getGUID(): string;
7export declare const SIGNATURE_LENGTH: number;
8export declare const PRIVATE_KEY_LENGTH: number;
9export declare const PUBLIC_KEY_LENGTH: number;
10/**
11 * Generates a private key for signing.
12 * @returns 64-byte private key.
13 */
14export declare function generatePrivateKey(): Uint8Array;
15/**
16 * Generates the public key that corresponds to the given private key.
17 * @param privateKey 64-byte private key.
18 * @returns 32-byte public key.
19 */
20export declare function publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
21/**
22 * Signs a message with the given private key.
23 * @param msg Message to be signed.
24 * @param privateKey 64-byte private key to sign with.
25 * @returns The generated signature.
26 */
27export declare function sign(msg: Uint8Array, privateKey: Uint8Array): Uint8Array;
28/**
29 * Encodes bytes to a base64 string.
30 * @param bytes Array of bytes to encode to string.
31 * @returns base64 encoded string.
32 */
33export declare function Uint8ArrayToB64(bytes: Uint8Array): string;
34/**
35 * Decodes bytes from a base64 string.
36 * @param s String to decode.
37 * @returns Array of bytes.
38 */
39export declare function B64ToUint8Array(s: string): Uint8Array;
40export declare function bufferToProtobufBytes(input: Buffer | Uint8Array): Uint8Array;