docsFunctionsOverview

Functions Overview

The Keypo SDK provides functions organized into four main categories for different aspects of data encryption and management.

Data Processing

Functions for preparing and restoring data:

  • preProcess - Prepare data for encryption by converting it to Uint8Array format
  • postProcess - Restore decrypted data to its original format

Data Encryption

Functions for encrypting data with different access patterns:

  • encrypt - Encrypt data with standard access control using EIP-7702 smart accounts
  • encryptForProxy - Encrypt API keys for proxy execution using EIP-7702 smart accounts

Data Access

Functions for accessing and using encrypted data:

  • decrypt - Decrypt and access encrypted data
  • proxyExecute - Execute API calls using encrypted API keys

Data Management

Functions for managing access and lifecycle of encrypted data:

  • share - Share access to encrypted data with other wallets
  • delete - Permanently delete encrypted data
  • list - View all accessible encrypted data with filtering and pagination
  • getDataInfo - Get detailed information about specific encrypted data
  • search - Search for encrypted data by name

Common Workflow Patterns

Standard Encryption/Decryption

// 1. Load Keypo configuration
const config = await keypo.init("https://api.keypo.io");
 
// 2. Prepare data
const { dataOut, metadataOut } = keypo.preProcess(data, 'my-data');
 
// 3. Encrypt
const result = await keypo.encrypt(
    dataOut, 
    walletClient, 
    metadataOut, 
    authorization, 
    config.encryptConfig
    );
 
// 4. Later, decrypt
const { decryptedData, metadata } = await keypo.decrypt(
    result.dataIdentifier, 
    wallet, 
    config.decryptConfig
    );
 
// 5. Restore original format
const originalData = keypo.postProcess(decryptedData, metadata);

API Key Proxy Execution

// 1. Load Keypo configuration
const config = await keypo.init("https://api.keypo.io");
 
// 2. Prepare API key
const { dataOut, metadataOut } = keypo.preProcess(apiKey, 'api-key');
 
// 3. Encrypt for proxy
const result = await keypo.encryptForProxy(
    dataOut, 
    walletClient, 
    metadataOut, 
    config.encryptForProxyConfig, 
    authorization
    );
 
// 3. Execute API calls (example: OpenAI API)
const response = await proxyExecute(
  result.dataIdentifier,
  wallet,
  {
    method: "POST",
    url: "https://api.openai.com/v1/chat/completions",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer ${apiKey}" // This will be replaced with the actual API key
    },
    body: {
      model: "gpt-3.5-turbo",
      messages: [{ role: "user", content: "Write one sentence about a cat" }]
    }
  },
  config.proxyExecuteConfig
);

Data Management

// List all accessible data
const allData = await keypo.list(wallet.address);
 
// Search for specific data
const apiKeys = await keypo.search('OpenAI API Key', wallet.address);
 
// Share with another wallet
const config = await keypo.init("https://api.keypo.io");
await keypo.shareData(
    dataIdentifier, 
    walletClient, 
    [recipientAddress], 
    config.shareConfig, 
    authorization
    );
 
// Get detailed info
const info = await keypo.getDataInfo(dataIdentifier);

Function Categories

All functions are organized by their primary purpose. Use the navigation menu to explore each category in detail.