UNPKG

3.3 kBTypeScriptView Raw
1/** Is `bignum` a negative number? */
2export declare const isNegative: (bignum: Uint8Array) => boolean;
3/** Negate `bignum` */
4export declare const negate: (bignum: Uint8Array) => void;
5/**
6 * Convert an unsigned decimal number in `s` to a bignum
7 *
8 * @param size bignum size (bytes)
9 */
10export declare const decimalToBinary: (size: number, s: string) => Uint8Array;
11/**
12 * Convert a signed decimal number in `s` to a bignum
13 *
14 * @param size bignum size (bytes)
15 */
16export declare const signedDecimalToBinary: (size: number, s: string) => Uint8Array;
17/**
18 * Convert `bignum` to an unsigned decimal number
19 *
20 * @param minDigits 0-pad result to this many digits
21 */
22export declare const binaryToDecimal: (bignum: Uint8Array, minDigits?: number) => string;
23/**
24 * Convert `bignum` to a signed decimal number
25 *
26 * @param minDigits 0-pad result to this many digits
27 */
28export declare const signedBinaryToDecimal: (bignum: Uint8Array, minDigits?: number) => string;
29/**
30 * Convert an unsigned base-58 number in `s` to a bignum
31 *
32 * @param size bignum size (bytes)
33 */
34export declare const base58ToBinary: (size: number, s: string) => Uint8Array;
35/**
36 * Convert `bignum` to a base-58 number
37 *
38 * @param minDigits 0-pad result to this many digits
39 */
40export declare const binaryToBase58: (bignum: Uint8Array, minDigits?: number) => string;
41/** Convert an unsigned base-64 number in `s` to a bignum */
42export declare const base64ToBinary: (s: string) => Uint8Array;
43/** Key types this library supports */
44export declare enum KeyType {
45 k1 = 0,
46 r1 = 1,
47 wa = 2
48}
49/** Public key data size, excluding type field */
50export declare const publicKeyDataSize = 33;
51/** Private key data size, excluding type field */
52export declare const privateKeyDataSize = 32;
53/** Signature data size, excluding type field */
54export declare const signatureDataSize = 65;
55/** Public key, private key, or signature in binary form */
56export interface Key {
57 type: KeyType;
58 data: Uint8Array;
59}
60/** Convert key in `s` to binary form */
61export declare const stringToPublicKey: (s: string) => Key;
62/** Convert public `key` to legacy string (base-58) form */
63export declare const publicKeyToLegacyString: (key: Key) => string;
64/** Convert `key` to string (base-58) form */
65export declare const publicKeyToString: (key: Key) => string;
66/** If a key is in the legacy format (`EOS` prefix), then convert it to the new format (`PUB_K1_`).
67 * Leaves other formats untouched
68 */
69export declare const convertLegacyPublicKey: (s: string) => string;
70/** If a key is in the legacy format (`EOS` prefix), then convert it to the new format (`PUB_K1_`).
71 * Leaves other formats untouched
72 */
73export declare const convertLegacyPublicKeys: (keys: string[]) => string[];
74/** Convert key in `s` to binary form */
75export declare const stringToPrivateKey: (s: string) => Key;
76/** Convert private `key` to legacy string (base-58) form */
77export declare const privateKeyToLegacyString: (key: Key) => string;
78/** Convert `key` to string (base-58) form */
79export declare const privateKeyToString: (key: Key) => string;
80/** Convert key in `s` to binary form */
81export declare const stringToSignature: (s: string) => Key;
82/** Convert `signature` to string (base-58) form */
83export declare const signatureToString: (signature: Key) => string;