@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.
96 lines (95 loc) • 3.85 kB
TypeScript
/**
* Scalable Encryption System
* Seamlessly transitions from single recipient to multi-recipient encryption
*/
import { EncryptionMethod, EncryptionResult, EncryptionOptions } from './types.js';
import { SharedKeyManager, SharePermissions } from './shared-key-manager.js';
/**
* Scalable encryption configuration
*/
export interface ScalableEncryptionConfig {
/** Automatically transition to shared key when recipients exceed this threshold */
autoTransitionThreshold: number;
/** Default permissions for new recipients */
defaultRecipientPermissions: SharePermissions;
/** Enable automatic key rotation */
enableAutoKeyRotation: boolean;
/** Key rotation interval in seconds */
keyRotationInterval: number;
}
/**
* Encryption context for tracking recipients and keys
*/
export interface EncryptionContext {
/** Context ID */
contextId: string;
/** Current recipients */
recipients: string[];
/** Encryption method being used */
method: EncryptionMethod;
/** Shared key ID (if using shared encryption) */
sharedKeyId?: string;
/** Context metadata */
metadata: {
name: string;
purpose: string;
creator: string;
createdAt: number;
lastUpdated: number;
};
/** Auto-scaling configuration */
scalingConfig: ScalableEncryptionConfig;
}
/**
* Scalable encryption manager that automatically handles growth from single to multi-recipient
*/
export declare class ScalableEncryptionManager {
private sharedKeyManager;
private contexts;
private defaultConfig;
constructor(sharedKeyManager?: SharedKeyManager, defaultConfig?: Partial<ScalableEncryptionConfig>);
/**
* Create a new encryption context (starts with single recipient)
*/
createEncryptionContext(contextName: string, purpose: string, initialRecipient: string, creatorPrivateKey: string | Uint8Array, config?: Partial<ScalableEncryptionConfig>): Promise<EncryptionContext>;
/**
* Encrypt data within a context (automatically scales as needed)
*/
encryptInContext(contextId: string, data: string | Uint8Array, senderPrivateKey: string | Uint8Array, options?: EncryptionOptions): Promise<EncryptionResult>;
/**
* Decrypt data within a context
*/
decryptInContext(contextId: string, encryptionResult: EncryptionResult, recipientPrivateKey: string | Uint8Array, recipientPublicKey: string): Promise<Uint8Array>;
/**
* Add recipients to an encryption context
*/
addRecipientsToContext(contextId: string, newRecipients: string[], authorizerPrivateKey: string | Uint8Array, authorizerPublicKey: string, permissions?: Partial<SharePermissions>): Promise<EncryptionContext>;
/**
* Remove recipients from an encryption context
*/
removeRecipientsFromContext(contextId: string, recipientsToRemove: string[], authorizerPrivateKey: string | Uint8Array, authorizerPublicKey: string, rotateKeys?: boolean): Promise<EncryptionContext>;
/**
* Get context information
*/
getContextInfo(contextId: string): EncryptionContext | null;
/**
* List all contexts
*/
listContexts(): Array<{
contextId: string;
name: string;
recipients: number;
method: EncryptionMethod;
createdAt: number;
}>;
/**
* Update context configuration
*/
updateContextConfig(contextId: string, newConfig: Partial<ScalableEncryptionConfig>): boolean;
private transitionToSharedEncryption;
private encryptWithSharedKey;
}
export declare function createScalableEncryption(contextName: string, purpose: string, initialRecipient: string, creatorPrivateKey: string | Uint8Array, config?: Partial<ScalableEncryptionConfig>): Promise<{
manager: ScalableEncryptionManager;
context: EncryptionContext;
}>;