> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/a16z/jolt/llms.txt
> Use this file to discover all available pages before exploring further.

# UntrustedAdvice<T>

> A wrapper type to mark guest program inputs as untrusted advice in Jolt zkVM

## Overview

`UntrustedAdvice<T>` is a wrapper type that marks guest program inputs as untrusted advice. Unlike trusted advice, untrusted advice values must be verified within the zkVM to ensure correctness. This is the safer option for inputs that need to be validated as part of the proof.

## Type Definition

```rust theme={null}
pub struct UntrustedAdvice<T> {
    value: T,
}
```

<ResponseField name="value" type="T">
  The wrapped value provided as untrusted advice
</ResponseField>

## Methods

### new

Creates a new `UntrustedAdvice` wrapper around a value.

```rust theme={null}
pub fn new(value: T) -> Self
```

<ParamField path="value" type="T" required>
  The value to wrap as untrusted advice
</ParamField>

**Returns:** A new `UntrustedAdvice<T>` instance

**Example:**

```rust theme={null}
use jolt_sdk::UntrustedAdvice;

let untrusted_value = UntrustedAdvice::new(42u64);
```

## Trait Implementations

### `From<T>`

Allows automatic conversion from any value `T` into `UntrustedAdvice<T>`.

```rust theme={null}
impl<T> From<T> for UntrustedAdvice<T>
```

**Example:**

```rust theme={null}
use jolt_sdk::UntrustedAdvice;

let untrusted: UntrustedAdvice<u64> = 42u64.into();
```

### Deref

Provides automatic dereferencing to access the wrapped value.

```rust theme={null}
impl<T> core::ops::Deref for UntrustedAdvice<T> {
    type Target = T;
}
```

**Example:**

```rust theme={null}
use jolt_sdk::UntrustedAdvice;

let untrusted = UntrustedAdvice::new(42u64);
let value: u64 = *untrusted; // Dereferences to 42
```

## Usage Example

```rust theme={null}
use jolt_sdk::{UntrustedAdvice, check_advice};

#[jolt::provable]
fn verify_sorted_indices(data: Vec<u64>, indices: UntrustedAdvice<Vec<usize>>) -> bool {
    // Verify that the untrusted indices actually sort the data
    check_advice!(indices.len() == data.len());
    
    for i in 0..indices.len() - 1 {
        check_advice!(data[indices[i]] <= data[indices[i + 1]]);
    }
    
    true
}

fn main() {
    let data = vec![5, 2, 8, 1, 9];
    let sorted_indices = vec![3, 1, 0, 2, 4]; // Indices that sort the data
    
    let result = verify_sorted_indices(
        data,
        UntrustedAdvice::new(sorted_indices)
    );
    println!("Verified: {}", result);
}
```

## When to Use

Use `UntrustedAdvice<T>` when:

* The input comes from an external source and needs verification
* You want to provide a hint or witness that will be checked within the zkVM
* You need to verify properties of the input as part of the proof
* You want to use the safer default for advice inputs

<Note>
  `UntrustedAdvice` is the recommended default for most use cases. Always verify untrusted advice using `check_advice!` or `check_advice_eq!` macros to ensure correctness.
</Note>

## Verification Macros

When working with untrusted advice, use these macros to verify correctness:

* `check_advice!(condition)` - Asserts that a condition holds
* `check_advice_eq!(left, right)` - Asserts that two values are equal

See the [check\_advice! macro](/api/macros/check-advice) documentation for more details.

## See Also

* [TrustedAdvice\<T>](/api/types/trusted-advice) - For advice that doesn't require verification
* [AdviceWriter](/api/types/advice-writer) - Writing advice data to the advice tape
* [AdviceReader](/api/types/advice-reader) - Reading advice data from the advice tape
* [check\_advice! macro](/api/macros/check-advice) - Macro for verifying advice
