Skip to main content

Rust integration

Rust provides public Wallets, stateless preparation, local proving and separate Session support for native applications and services. The host owns accounts, signing, viewing decryption and submission. The SDK does not read mnemonics or system keystores.

Crates​

invisi-sdk orchestrates operations. invisi-sdk-primitives and invisi-sdk-protocol contain pure models and codecs. invisi-sdk-prover, invisi-sdk-rpc and invisi-sdk-session provide proving, transport and persistent inventory. Enable the Session SQLite feature when required.

Use a compatible release cohort as described in compatibility. Before installing, confirm that your selected crate versions export the methods used here. An API version does not establish crates.io availability.

Construct a Note offline​

This complete program requires compatible invisi-sdk and alloy-primitives dependencies. It needs no private key, service or BB process. Save it as your project’s src/main.rs and use cargo run. Contract addresses are offline illustrations only.

use alloy_primitives::{address, U256};
use invisi_sdk::{note::ProtocolContext, sdk::{NoteOutput, Wallet}};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let recipient = Wallet::from_address("0i0e0525SFRf53yh2aljmm3sn9JQ5nJk7LqWt0G2ajnRY2pe698y550QXhp9uELXpcCZMf5Y608rRDJ68jJgfEWy5j7U5e5eVNPVz8vW2W2kmyw4p9lVLwW3z3WeFHQs5KdfR980CX")?;
let context = ProtocolContext {
chain_id: 31337,
protocol_address: U256::from(0x1234),
};
let output = NoteOutput::for_recipient(
context,
address!("0000000000000000000000000000000000005678"),
&recipient,
U256::from(10),
Vec::new(),
)?;
println!("{}", output.commitment());
Ok(())
}

U256::from(10) means token base units. This only constructs an intent and encrypted delivery, not a funded on-chain Note.

Operation flow​

  1. Parse full 0i material with Wallet::from_address; use owner addresses separately for identity-only operations.
  2. Configure trusted deployments, independent chain reads, Protocol RPC and a local prover.
  3. Prepare Note or Credit operations, fixing the final fee and execution mode.
  4. For operations requiring private wallet authorization, export typed data using export_wallet_authorization(), sign through the application, and attach with with_wallet_signature().
  5. Use ready() for Shield and the matching prove(...) flow for private operations requiring ZK evidence before obtaining calldata. Credit revocation uses its separate owner-authorization path without a ZK proof. The host separately signs and submits the EVM transaction.
  6. Associate the hash in a durable journal, reconcile outcomes and retain uncertain reservations.

DeliveryDecryptor returns authenticated plaintext or None for a known nonrecipient. Errors reject the batch without advancing its inventory cursor. Synchronize and count Notes and Credit separately; creating Credit does not add available funds.

For FFI integration, check its capability scope separately: pure cryptographic interfaces do not imply HTTP, proving or Session support. See local proving for runtime choices.

Download the complete offline example