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
- Custom RISC-V instructions: Inlines compile to special
.insndirectives that the Jolt VM recognizes - 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:Host-Side Proving
When the Jolt VM encounters an inline instruction:- The tracer recognizes the custom opcode and funct3/funct7 values
- Instead of emulating the operation instruction-by-instruction, it executes a pre-built instruction sequence
- The prover generates efficient constraints for the entire operation
Available Inlines
Jolt provides several categories of cryptographic inlines:Hash Functions
- SHA-256 - SHA-2 family hash function with 256-bit output
- Keccak-256 - Keccak/SHA-3 hash function
- BLAKE2 - BLAKE2b hash function (512-bit output)
- BLAKE3 - BLAKE3 hash function optimized for single-block inputs
Elliptic Curve Cryptography
- secp256k1 - Bitcoin/Ethereum curve with ECDSA signature verification
- Grumpkin - Cycle curve for BN254, useful for recursive proofs
Arithmetic
- BigInt - 256-bit × 256-bit multiplication for large integer operations
Using Inlines in Your Project
To use inlines in your Jolt guest program:- Add the inline crate to your guest’s
Cargo.toml:
- Import and use the inline in your guest code:
- Build with the host feature enabled when running on the prover:
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 importsexec.rs: Host-side reference implementation (feature-gated behindhost)sequence_builder.rs: Generates the instruction sequence for the tracerhost.rs: Registration and initialization code
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
hostfeature, and prover code with it
Next Steps
- Explore individual inline documentation for detailed API references
- Check the examples directory for complete working examples
- Read the source code in
jolt-inlines/for implementation details