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:
- Parses the graph binary from instruction data
- Verifies each input ciphertext’s
fhe_typematches the graph - Verifies each input’s
authorizedmatches the caller - Charges fees (per input + constant + plaintext input + output + operation)
- Creates or updates output ciphertext accounts (status=PENDING)
- Emits
GraphExecutedEventfor the executor
Instruction Data
discriminator(1) | graph_data_len(2) | graph_data(N) | num_inputs(2)
Account Layout
| Position | Account | Writable | Signer |
|---|---|---|---|
| 0 | config | no | no |
| 1 | deposit | yes | no |
| 2 | caller | no | yes (signer path) |
| 3 | network_encryption_key | no | no |
| 4 | payer | yes | yes |
| 5 | event_authority | no | no |
| 6 | program | no | no |
| 7..7+N | input ciphertexts | no | no |
| 7+N..7+N+M | output ciphertexts | yes | no |
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_digestandstatusto 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↑
}