Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Execute Graph

Pre-Alpha Disclaimer: This is an early pre-alpha release for exploring the SDK and starting development only. There is no real encryption — all data is completely public and stored as plaintext on-chain. Do not submit any sensitive or real data. Encryption keys and the trust model are not final; do not rely on any encryption guarantees or key material until mainnet. All interfaces, APIs, and data formats are subject to change without notice. The Solana program and all on-chain data will be wiped periodically and everything will be deleted when we transition to Encrypt Alpha 1. This software is provided “as is” without warranty of any kind; use is entirely at your own risk and dWallet Labs assumes no liability for any damages arising from its use.

How It Works

execute_graph (disc 4) processes a computation graph:

  1. Parses the graph binary from instruction data
  2. Verifies each input ciphertext’s fhe_type matches the graph
  3. Verifies each input’s authorized matches the caller
  4. Charges fees (per input + constant + plaintext input + output + operation)
  5. Creates or updates output ciphertext accounts (status=PENDING)
  6. Emits GraphExecutedEvent for the executor

Instruction Data

discriminator(1) | graph_data_len(2) | graph_data(N) | num_inputs(2)

Account Layout

PositionAccountWritableSigner
0confignono
1deposityesno
2callernoyes (signer path)
3network_encryption_keynono
4payeryesyes
5event_authoritynono
6programnono
7..7+Ninput ciphertextsnono
7+N..7+N+Moutput ciphertextsyesno

For CPI path: cpi_authority is inserted at position 3, shifting subsequent accounts.

Update Mode

Output accounts can be existing ciphertexts:

  • If the output account already has data → update mode: resets ciphertext_digest and status to PENDING
  • If the output account is empty → create mode: creates a new Ciphertext

This means the same account can be used as both input and output (e.g., yes_count is read, then updated in the same execute_graph call).

Type Verification

The processor verifies each input ciphertext’s fhe_type matches the graph’s Input node fhe_type. If they don’t match, the transaction fails with InvalidArgument.

Using the DSL

Instead of building instruction data manually, use the generated CPI method:

#![allow(unused)]
fn main() {
// Generated by #[encrypt_fn]:
ctx.cast_vote_graph(yes_ct, no_ct, vote_ct, yes_ct, no_ct)?;
//                   ↑inputs↑              ↑outputs↑
}