@gorbchain-xyz/chaindecode
Version:
GorbchainSDK V1.3+ - Complete Solana development toolkit with advanced cryptography, messaging, and collaboration features. Build secure applications with blockchain, DeFi, and end-to-end encryption.
140 lines (139 loc) • 4.97 kB
TypeScript
/**
* Crypto Manager - Main interface for all cryptographic operations
*/
import { EncryptionMethod, EncryptionResult, CryptoConfig, SignatureGroupMetadata, MemberRole, GroupPermissions } from './types.js';
import { PersonalEncryptionSession } from './personal.js';
import { SecureChannel } from './direct.js';
/**
* Main crypto manager for the SDK
*/
export declare class CryptoManager {
private config;
private groupCache;
constructor(config?: Partial<CryptoConfig>);
/**
* Encrypt data using the specified method
*/
encrypt(data: string | Uint8Array, options?: {
method?: EncryptionMethod;
privateKey?: string | Uint8Array;
recipientPublicKey?: string;
recipientPublicKeys?: string[];
groupMetadata?: SignatureGroupMetadata;
groupId?: string;
compress?: boolean;
}): Promise<EncryptionResult>;
/**
* Decrypt data
*/
decrypt(encryptionResult: EncryptionResult, privateKey: string | Uint8Array, options?: {
publicKey?: string;
verifySignature?: boolean;
}): Promise<Uint8Array>;
/**
* Decrypt data and return as string
*/
decryptString(encryptionResult: EncryptionResult, privateKey: string | Uint8Array, options?: {
publicKey?: string;
verifySignature?: boolean;
}): Promise<string>;
/**
* Create a new signature-based group
*/
createSignatureGroup(groupName: string, creatorPrivateKey: string | Uint8Array, initialMembers?: {
publicKey: string;
role: MemberRole;
}[], permissions?: Partial<GroupPermissions>): Promise<SignatureGroupMetadata>;
/**
* Add a member to a signature group
*/
addMemberToGroup(groupId: string, newMember: {
publicKey: string;
role: MemberRole;
}, authorizedMemberPrivateKey: string | Uint8Array, authorizedMemberPublicKey: string): Promise<SignatureGroupMetadata>;
/**
* Remove a member from a signature group
*/
removeMemberFromGroup(groupId: string, memberToRemove: string, authorizedMemberPrivateKey: string | Uint8Array, authorizedMemberPublicKey: string, rotateKeys?: boolean): Promise<SignatureGroupMetadata>;
/**
* Create a secure channel between two parties
*/
createSecureChannel(localPrivateKey: string | Uint8Array, remotePublicKey: string): SecureChannel;
/**
* Create a personal encryption session
*/
createPersonalSession(privateKey: string | Uint8Array): PersonalEncryptionSession;
/**
* Sign data
*/
sign(data: string | Uint8Array, privateKey: string | Uint8Array): string;
/**
* Verify signature
*/
verify(data: string | Uint8Array, signature: string, publicKey: string): boolean;
/**
* Get group metadata (from cache or storage)
*/
getGroupMetadata(groupId: string): Promise<SignatureGroupMetadata | null>;
/**
* Store group metadata
*/
storeGroupMetadata(group: SignatureGroupMetadata): Promise<void>;
/**
* List all cached groups
*/
listCachedGroups(): string[];
/**
* Clear group cache
*/
clearGroupCache(): void;
/**
* Validate a public key
*/
validatePublicKey(publicKey: string): boolean;
/**
* Generate a new keypair
*/
generateKeypair(): {
publicKey: string;
privateKey: string;
};
/**
* Encrypt data using personal encryption
*/
encryptPersonal(data: string | Uint8Array, privateKey: string | Uint8Array, options?: {
compress?: boolean;
}): Promise<EncryptionResult>;
/**
* Decrypt personal encrypted data
*/
decryptPersonal(encryptionResult: EncryptionResult, privateKey: string | Uint8Array): Promise<Uint8Array>;
/**
* Decrypt personal encrypted data and return as string
*/
decryptPersonalString(encryptionResult: EncryptionResult, privateKey: string | Uint8Array): Promise<string>;
/**
* Encrypt data for direct communication
*/
encryptDirect(data: string | Uint8Array, recipientPublicKey: string, senderPrivateKey: string | Uint8Array, options?: {
compress?: boolean;
}): Promise<EncryptionResult>;
/**
* Decrypt direct encrypted data
*/
decryptDirect(encryptionResult: EncryptionResult, recipientPrivateKey: string | Uint8Array): Promise<Uint8Array>;
/**
* Decrypt direct encrypted data and return as string
*/
decryptDirectString(encryptionResult: EncryptionResult, recipientPrivateKey: string | Uint8Array): Promise<string>;
/**
* Encrypt data for group
*/
encryptGroup(data: string | Uint8Array, groupMetadata: SignatureGroupMetadata, options?: {
compress?: boolean;
}): Promise<EncryptionResult>;
/**
* Decrypt group encrypted data
*/
decryptGroup(encryptionResult: EncryptionResult, privateKey: string | Uint8Array, publicKey: string): Promise<Uint8Array>;
}