> ## 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.

# Cryptographic Inlines Overview

> High-performance cryptographic primitives for Jolt zkVM

## What are Inlines?

Inlines are optimized cryptographic primitives that replace standard guest-side computation with efficient constraint-native implementations in the Jolt zkVM. They provide significant performance improvements for common cryptographic operations by:

* **Reducing proving overhead**: Complex operations are replaced with efficient RISC-V custom instructions
* **Lowering cycle counts**: Cryptographic operations execute in dramatically fewer VM cycles
* **Maintaining security**: All operations are fully verified within the zkVM's proof system

## Performance Benefits

When you use inline instructions instead of standard library implementations:

* **Hash functions**: 10-100x faster proving time for SHA-256, Keccak-256, BLAKE2, and BLAKE3
* **Elliptic curve operations**: Efficient field arithmetic for secp256k1 and Grumpkin curves
* **BigInt arithmetic**: Optimized 256-bit multiplication for large integer operations

The performance gains come from two key optimizations:

1. **Custom RISC-V instructions**: Inlines compile to special `.insn` directives that the Jolt VM recognizes
2. **Optimized constraint systems**: The prover uses specialized polynomial commitments for these operations

## How Inlines Work

Inlines operate through a two-layer architecture:

### Guest Code (RISC-V)

In your guest program, inlines appear as normal Rust functions:

```rust theme={null}
use sha2_inline::Sha256;

let hash = Sha256::digest(b"hello world");
```

The inline library generates custom RISC-V instructions using inline assembly:

```rust theme={null}
core::arch::asm!(
    ".insn r {opcode}, {funct3}, {funct7}, {rd}, {rs1}, {rs2}",
    opcode = const INLINE_OPCODE,
    funct3 = const SHA256_FUNCT3,
    funct7 = const SHA256_FUNCT7,
    // ...
);
```

### Host-Side Proving

When the Jolt VM encounters an inline instruction:

1. The tracer recognizes the custom opcode and funct3/funct7 values
2. Instead of emulating the operation instruction-by-instruction, it executes a pre-built instruction sequence
3. The prover generates efficient constraints for the entire operation

## Available Inlines

Jolt provides several categories of cryptographic inlines:

### Hash Functions

* [SHA-256](/api/inlines/sha2) - SHA-2 family hash function with 256-bit output
* [Keccak-256](/api/inlines/keccak256) - Keccak/SHA-3 hash function
* [BLAKE2](/api/inlines/blake2) - BLAKE2b hash function (512-bit output)
* [BLAKE3](/api/inlines/blake3) - BLAKE3 hash function optimized for single-block inputs

### Elliptic Curve Cryptography

* [secp256k1](/api/inlines/secp256k1) - Bitcoin/Ethereum curve with ECDSA signature verification
* [Grumpkin](/api/inlines/grumpkin) - Cycle curve for BN254, useful for recursive proofs

### Arithmetic

* [BigInt](/api/inlines/bigint) - 256-bit × 256-bit multiplication for large integer operations

## Using Inlines in Your Project

To use inlines in your Jolt guest program:

1. **Add the inline crate** to your guest's `Cargo.toml`:

```toml theme={null}
[dependencies]
sha2-inline = { path = "path/to/jolt-inlines/sha2" }
```

2. **Import and use** the inline in your guest code:

```rust theme={null}
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

use sha2_inline::Sha256;

#[jolt::provable]
fn hash_data(input: &[u8]) -> [u8; 32] {
    Sha256::digest(input)
}
```

3. **Build with the host feature** enabled when running on the prover:

```bash theme={null}
cargo build --release --features host
```

## Feature Flags

All inline crates support the following feature flags:

* **`host`**: Enables host-side execution using reference implementations (required for proving)
* **Default (no features)**: Compiles to RISC-V custom instructions for guest execution

## Architecture Details

Each inline crate is organized into several modules:

* **`sdk.rs`**: High-level Rust API that guest code imports
* **`exec.rs`**: Host-side reference implementation (feature-gated behind `host`)
* **`sequence_builder.rs`**: Generates the instruction sequence for the tracer
* **`host.rs`**: Registration and initialization code

The inline opcode is `0x0B`, and each inline has unique `funct3` and `funct7` values to distinguish operations.

## Performance Considerations

* **Input size**: Some inlines (like BLAKE3) are optimized for specific input sizes (e.g., ≤64 bytes)
* **Memory alignment**: Inline instructions expect properly aligned pointers (typically 8-byte alignment)
* **Feature flags**: Always compile guest code without `host` feature, and prover code with it

## Next Steps

* Explore individual inline documentation for detailed API references
* Check the [examples directory](https://github.com/a16z/jolt/tree/main/examples) for complete working examples
* Read the source code in `jolt-inlines/` for implementation details
