Why computation definitions exist
When you write an encrypted instruction with Arcis, it compiles into an MPC circuit: a program that MPC nodes can execute securely on encrypted data. Computation definitions tell the nodes which circuit to run when your Solana program queues a computation. Computation Definition Accounts bridge your Solana program and the MPC network. They store the circuit metadata and, for onchain circuit sources, the circuit bytecode needed for execution.Computation definition accounts
When you define an encrypted instruction using Arcis, the MPC cluster that executes it needs access to the instruction interface, metadata, and circuit source. AComputationDefinitionAccount contains two parts:
- The encrypted instruction metadata and interface.
- The circuit source. For onchain sources, this references separate accounts that hold the raw MPC bytecode.
b"ComputationDefinitionAccount", mxe_program_id, comp_def_offset. The first seed is exported by the Arcium Anchor SDK, the second is your MXE program ID, and the third is an encrypted-instruction-specific offset. comp_def_offset is sha256(<encrypted_instruction_name>).slice(0,4) interpreted as a little-endian u32. The derive_comp_def_pda! macro computes the ComputationDefinitionAccount address for you.
For onchain circuit sources, the MPC bytecode is stored in accounts with the seeds b"ComputationDefinitionRaw", comp_def_acc, i. The first seed is exported by the Arcium Anchor SDK, the second is the computation definition account, and the third is an index from 0 through the number of accounts needed to store the full bytecode.
Usage
When working locally, the Arcium CLI creates and manages MPC bytecode accounts for you. You still need to create the interfaceComputationDefinitionAccount, which the Arcium Anchor tooling handles. For an encrypted instruction called add_together, define:
Offchain circuit sources
For larger circuits, you can store the compiled circuit offchain and pass anOffChainCircuitSource as the second argument to init_computation_def:
circuit_hash! macro embeds the SHA-256 hash from build/{circuit_name}.hash at compile time; Arx nodes verify it when fetching the circuit. For the full offchain workflow, see Deployment.