Skip to main content

Overview

TrustedAdvice<T> is a wrapper type that marks guest program inputs as trusted advice. Trusted advice values are assumed to be correct and do not require verification within the zkVM. This is useful for inputs that are inherently verifiable or when the correctness of the input is guaranteed by external means.

Type Definition

pub struct TrustedAdvice<T> {
    value: T,
}
value
T
The wrapped value provided as trusted advice

Methods

new

Creates a new TrustedAdvice wrapper around a value.
pub fn new(value: T) -> Self
value
T
required
The value to wrap as trusted advice
Returns: A new TrustedAdvice<T> instance Example:
use jolt_sdk::TrustedAdvice;

let trusted_value = TrustedAdvice::new(42u64);

Trait Implementations

From<T>

Allows automatic conversion from any value T into TrustedAdvice<T>.
impl<T> From<T> for TrustedAdvice<T>
Example:
use jolt_sdk::TrustedAdvice;

let trusted: TrustedAdvice<u64> = 42u64.into();

Deref

Provides automatic dereferencing to access the wrapped value.
impl<T> core::ops::Deref for TrustedAdvice<T> {
    type Target = T;
}
Example:
use jolt_sdk::TrustedAdvice;

let trusted = TrustedAdvice::new(42u64);
let value: u64 = *trusted; // Dereferences to 42

Usage Example

use jolt_sdk::TrustedAdvice;

#[jolt::provable]
fn process_trusted_data(data: TrustedAdvice<Vec<u64>>) -> u64 {
    // The zkVM assumes this data is correct and doesn't verify it
    data.iter().sum()
}

fn main() {
    let data = vec![1, 2, 3, 4, 5];
    let result = process_trusted_data(TrustedAdvice::new(data));
    println!("Sum: {}", result);
}

When to Use

Use TrustedAdvice<T> when:
  • The input is guaranteed to be correct by external verification
  • The correctness of the input can be verified through other computations in your program
  • You want to reduce proof generation overhead by not verifying certain inputs
Improperly using TrustedAdvice can compromise the security of your zkVM program. Only use it for values whose correctness is guaranteed or will be verified elsewhere in your computation.

See Also

Build docs developers (and LLMs) love