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
ExecutorAccountPDA with seeds[b"executor"] - Sets up the executor account with 8 bytes of space (account discriminator only)
- No additional initialization logic required
- Creates an
add
- Params:
lhs:Euint64– Left-hand side encrypted handle/pointerrhs: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 byte0 - Returns new
Euint64with 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/pointerrhs: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 byte0 - Returns new
Euint64with 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/pointerrhs: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 byte0 - Returns
Eboolwith encrypted boolean result (type 0) - Result indicates whether the encrypted values are equal
le
- Params:
lhs:Euint64– Left-hand side encrypted handle/pointerrhs: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 byte0 - Returns
Eboolwith encrypted boolean result (type 0) - Result indicates whether
lhs ≤ rhs
select
- Params:
control:Ebool– Encrypted boolean control valuelhs:Euint64– Value to return if control is truerhs: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
controlis type 0 (boolean) andlhs/rhshave same type - Supports all encrypted types (0–11)
- Calls
pet_select()with control, true value, and false value handles - Returns
Euint64with selected value - Preserves the type of the selected operands
- Validates
as_euint64
- Params:
einput:Einput– Generic encrypted input
- Purpose: Converts generic encrypted input to
Euint64format. - Use Case: Type conversion to encrypted 64-bit integer.
- Process:
- Extracts handle and proof from
Einput - Creates new
Euint64with extracted handle and proof - Sets empty context vector
- Returns converted
Euint64structure
- Extracts handle and proof from
as_eaddress
- Params:
einput:Einput– Generic encrypted input
- Purpose: Converts generic encrypted input to
EAddressformat. - Use Case: Converting encrypted data to address format.
- Process:
- Extracts handle from
Einput - Creates new
EAddresswith extracted handle - Returns converted
EAddressstructure
- Extracts handle from
as_esignature
- Params:
einput:Einput– Generic encrypted input
- Purpose: Converts generic encrypted input to
ESignatureformat. - Use Case: Converting encrypted data to signature format.
- Process:
- Extracts handle from
Einput - Creates new
ESignaturewith extracted handle - Returns converted
ESignaturestructure
- Extracts handle from
to_euint64
- Params:
value:u128– Plaintext value to encrypt
- Purpose: Encrypts a plaintext 128-bit value to
Euint64format. - Use Case: Converting plaintext to encrypted format.
- Process:
- Calls
trivial_encrypt()withvalueand type 5 (Euint64) - Creates hash input with operator, value, and type
- Generates deterministic encrypted handle
- Returns
Euint64with handle and empty proof/context
- Calls
is_allowed
- Params:
value:Euint64– Encrypted handle/pointer to checkaccessor: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
Eboolindicating access permission
set_access
- Params:
value:Euint64– Encrypted handle/pointeraccessor:Pubkey– Public key of accessoraccess: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
- Currently returns