Skip to main content

EncryptedType

type EncryptedType = 'u8' | 'u32' | 'u64';

PendingEncrypted

interface PendingEncrypted<T extends EncryptedType> {
  type: T;
  data: Uint8Array;
  withUserRecovery(userCrypto: UserCrypto): Encrypted<T>;
}

Encrypted

interface Encrypted<T extends EncryptedType> {
  type: T;
  data: Uint8Array;
  userRecovery?: UserRecoveryData;
}

UserRecoveryData

interface UserRecoveryData {
  ciphertext: Uint8Array;
  nonce: Uint8Array;
}

EncryptionInput

interface EncryptionInput<T extends EncryptedType = EncryptedType> {
  value: number;
  type: T;
}

UserCrypto

class UserCrypto {
  constructor(keypair: Keypair);

  /** Decrypt user recovery data */
  decryptRecovery(recovery: UserRecoveryData): Uint8Array;

  /** Decrypt data encrypted to self */
  decryptFromSelf(ciphertext: Uint8Array, nonce: Uint8Array): Uint8Array | null;

  /** Decrypt data from MPC decryption */
  decryptFromMPC(
    ciphertext: Uint8Array,
    nonce: Uint8Array,
    ephemeralPubkey: Uint8Array
  ): Uint8Array;

  /** Encrypt data to self for recovery */
  encryptToSelf(plaintext: Uint8Array): { ciphertext: Uint8Array; nonce: Uint8Array };
}

TransactionBuilder

class TransactionBuilder {
  add(instruction: TransactionInstruction): TransactionBuilder;
  withFheData(hashes: string[]): TransactionBuilder;
  sign(signer: Keypair): TransactionBuilder;
  send(): Promise<string>;
  build(): Promise<Transaction>;
}

Account Types

CreateAccountParams

interface CreateAccountParams {
  /** The connection to use for rent calculation */
  connection: Connection;
  /** The payer for the account creation */
  payer: PublicKey;
  /** The new account's keypair */
  newAccountPubkey: PublicKey;
  /** Size of account data in bytes */
  space: number;
  /** Program that will own the account */
  programId: PublicKey;
}

BuildCreateAccountInstructionParams

interface BuildCreateAccountInstructionParams {
  /** The payer for the account creation */
  payer: PublicKey;
  /** The new account's public key */
  newAccountPubkey: PublicKey;
  /** Lamports to transfer to the new account */
  lamports: number;
  /** Size of account data in bytes */
  space: number;
  /** Program that will own the account */
  programId: PublicKey;
}

RPC Types

SendTransactionConfig

interface SendTransactionConfig {
  /** Skip preflight transaction checks */
  skipPreflight?: boolean;
  /** Preflight commitment level */
  preflightCommitment?: Commitment;
  /** Maximum retries */
  maxRetries?: number;
}

Re-exported Solana Types

For convenience, these Solana web3.js types are re-exported from @privora/sdk:
export type { Keypair, PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';