UNPKG

purity-identity

Version:

Key generation for the Purity users, tool to encrypt/decrypt messages with their identities and helpers for compressing decompressing public keys

36 lines (35 loc) 1.35 kB
import { Encrypted } from "eth-crypto"; export declare type IdentityType = { privateKey: string; publicKey: string; address: string; }; export declare type SerializedPublicKey = { pubKeyPrefix: boolean; pubKey: Array<number>; }; /** * Used for Premium Content's encryption/decryption and contract store for pubkeys **/ export declare class IdenityService { private identity; constructor(identity?: IdentityType | null); encryptData(data: string): Promise<Encrypted>; decryptEncryptedData(encryptedData: Encrypted): Promise<string>; getCompressedPublicKey(): string; getDecompressedPublicKey(): string; getSerializedPublicKey(): SerializedPublicKey; } export declare function createIdentity(): IdentityType; export declare function encryptData(pubKey: string, data: string): Promise<Encrypted>; export declare function decryptData(privKey: string, encryptedData: Encrypted): Promise<string>; export declare function compressPublicKey(pubKey: string): string; /** * For contract store, the public key has to be serialized and compressed * as much as possible **/ export declare function serializePublicKey(pubKey: string): SerializedPublicKey; /** * Get decompressed public key string from contract store **/ export declare function unserializePublicKey(pubKeyPrefix: boolean, pubKey: string): string;