Encifher

PET Executor Program

Description of PET executor program and its Functions

Overview

The PetExecutor Program is a Solana program that provides computation capabilities for pointers (symbolic execution on onchain pointers). It serves as the computational interface for the Encifher protocol, enabling operations on encrypted values without revealing the underlying data.

Functions and Use Cases

initialize

  • Params: None
  • Purpose: Initializes the executor program by creating the executor account PDA.
  • Use Case: One-time setup to create the executor account that tracks program state.
  • Process:
    • Creates an ExecutorAccount PDA with seeds [b"executor"]
    • Sets up the executor account with 8 bytes of space (account discriminator only)
    • No additional initialization logic required

add

  • Params:
    • lhs: Euint64 – Left-hand side encrypted handle/pointer
    • rhs: Euint64 – Right-hand side encrypted handle/pointer
  • Purpose: Calculates resultant pointer/handle which represents addition operation on two input handles/pointers (lhs, rhs)
  • Use Case: Adding encrypted token amounts, balances, or any encrypted numeric values without revealing the actual amounts.
  • Process:
    • Validates both operands have compatible types (types 1–6, 8)
    • Calls pet_add() with handles and scalar byte 0
    • Returns new Euint64 with computed handle and empty proof/context
    • Preserves the type of the left operand in the result

sub

  • Params:
    • lhs: Euint64 – Left-hand side encrypted handle/pointer
    • rhs: Euint64 – Right-hand side encrypted handle/pointer
  • Purpose: Calculates resultant pointer/handle which represents subtract operation on two input handles/pointers (lhs, rhs)
  • Use Case: Subtracting encrypted amounts, calculating differences, or reducing balances without revealing actual values.
  • Process:
    • Validates both operands have compatible types (types 1–6, 8)
    • Calls pet_sub() with handles and scalar byte 0
    • Returns new Euint64 with computed handle and empty proof/context
    • Preserves the type of the left operand in the result

eq

  • Params:
    • lhs: Euint64 – Left-hand side encrypted handle/pointer
    • rhs: Euint64 – Right-hand side encrypted handle/pointer
  • Purpose: Calculates resultant pointer/handle which represents equality check operation on two input handles/pointers (lhs, rhs). The resultant handle/pointer would gonna storage the ciphertext boolean result of the equality check.
  • Use Case: Checking if two encrypted amounts are equal, validating encrypted conditions, or implementing encrypted conditional logic.
  • Process:
    • Supports all encrypted types (0–11)
    • Calls pet_eq() with handles and scalar byte 0
    • Returns Ebool with encrypted boolean result (type 0)
    • Result indicates whether the encrypted values are equal

le

  • Params:
    • lhs: Euint64 – Left-hand side encrypted handle/pointer
    • rhs: Euint64 – Right-hand side encrypted handle/pointer
  • Purpose: Calculates resultant pointer/handle which represents less than equal check operation on two input handles/pointers (lhs, rhs). The resultant handle/pointer would gonna storage the ciphertext boolean result of the equality check.
  • Use Case: Validating encrypted constraints, range checks, or comparisons.
  • Process:
    • Supports encrypted integer types (1–6, 8)
    • Calls pet_le() with handles and scalar byte 0
    • Returns Ebool with encrypted boolean result (type 0)
    • Result indicates whether lhs ≤ rhs

select

  • Params:
    • control: Ebool – Encrypted boolean control value
    • lhs: Euint64 – Value to return if control is true
    • rhs: Euint64 – Value to return if control is false
  • Purpose: Performs conditional selection based on encrypted boolean control value.
  • Use Case: Encrypted branching operations (if-then-else).
  • Process:
    • Validates control is type 0 (boolean) and lhs/rhs have same type
    • Supports all encrypted types (0–11)
    • Calls pet_select() with control, true value, and false value handles
    • Returns Euint64 with selected value
    • Preserves the type of the selected operands

as_euint64

  • Params:
    • einput: Einput – Generic encrypted input
  • Purpose: Converts generic encrypted input to Euint64 format.
  • Use Case: Type conversion to encrypted 64-bit integer.
  • Process:
    • Extracts handle and proof from Einput
    • Creates new Euint64 with extracted handle and proof
    • Sets empty context vector
    • Returns converted Euint64 structure

as_eaddress

  • Params:
    • einput: Einput – Generic encrypted input
  • Purpose: Converts generic encrypted input to EAddress format.
  • Use Case: Converting encrypted data to address format.
  • Process:
    • Extracts handle from Einput
    • Creates new EAddress with extracted handle
    • Returns converted EAddress structure

as_esignature

  • Params:
    • einput: Einput – Generic encrypted input
  • Purpose: Converts generic encrypted input to ESignature format.
  • Use Case: Converting encrypted data to signature format.
  • Process:
    • Extracts handle from Einput
    • Creates new ESignature with extracted handle
    • Returns converted ESignature structure

to_euint64

  • Params:
    • value: u128 – Plaintext value to encrypt
  • Purpose: Encrypts a plaintext 128-bit value to Euint64 format.
  • Use Case: Converting plaintext to encrypted format.
  • Process:
    • Calls trivial_encrypt() with value and type 5 (Euint64)
    • Creates hash input with operator, value, and type
    • Generates deterministic encrypted handle
    • Returns Euint64 with handle and empty proof/context

is_allowed

  • Params:
    • value: Euint64 – Encrypted handle/pointer to check
    • accessor: Pubkey – Public key of accessor
  • Purpose: Checks if accessor has permission to access encrypted data.
  • Use Case: Encrypted access control validation.
  • Process:
    • Generates permission hash from accessor pubkey and value handle
    • Calls pet_is_allowed() with permission hash
    • Returns Ebool indicating access permission

set_access

  • Params:
    • value: Euint64 – Encrypted handle/pointer
    • accessor: Pubkey – Public key of accessor
    • access: bool – Access permission
  • Purpose: Sets access permissions (currently a no-op).
  • Use Case: Placeholder for future ACL support.
  • Process:
    • Currently returns Ok(()) without operation
    • Intended for future implementation