UNPKG

@coti-io/coti-sdk-typescript

Version:

A library for encryption, decryption and cryptographic utilities for the COTI blockchain.

35 lines (34 loc) 1.85 kB
import { BaseWallet } from "ethers"; import { ctString, ctUint, itString, itUint } from './types'; export declare function encrypt(key: Uint8Array, plaintext: Uint8Array): { ciphertext: Uint8Array; r: Uint8Array; }; export declare function decrypt(key: Uint8Array, r: Uint8Array, ciphertext: Uint8Array): Uint8Array; export declare function generateRSAKeyPair(): { publicKey: Uint8Array; privateKey: Uint8Array; }; export declare function decryptRSA(privateKey: Uint8Array, ciphertext: string): string; export declare function recoverUserKey(privateKey: Uint8Array, encryptedKeyShare0: string, encryptedKeyShare1: string): string; export declare function sign(message: string, privateKey: string): Uint8Array; export declare function signInputText(sender: { wallet: BaseWallet; userKey: string; }, contractAddress: string, functionSelector: string, ct: bigint): Uint8Array; export declare function buildInputText(plaintext: bigint, sender: { wallet: BaseWallet; userKey: string; }, contractAddress: string, functionSelector: string): itUint; export declare function buildStringInputText(plaintext: string, sender: { wallet: BaseWallet; userKey: string; }, contractAddress: string, functionSelector: string): itString; export declare function decryptUint(ciphertext: ctUint, userKey: string): bigint; export declare function decryptString(ciphertext: ctString, userKey: string): string; export declare function generateRandomAesKeySizeNumber(): string; export declare function encodeString(str: string): Uint8Array; export declare function encodeKey(userKey: string): Uint8Array; export declare function encodeUint(plaintext: bigint): Uint8Array; export declare function decodeUint(plaintextBytes: Uint8Array): bigint; export declare function encryptNumber(r: string | Uint8Array, key: Uint8Array): Uint8Array;