Problem: Expensive RISC-V Execution
Proving RISC-V execution of cryptographic operations is inefficient:Solution: Constraint-Native Primitives
Inlines replace the RISC-V trace with a pre-computed sequence of constraint-native operations:Available Inlines
Jolt provides optimized inlines for common cryptographic primitives:Hash Functions
SHA-256
- Module:
jolt-inlines/sha2 - Operations: Block compression, initial compression
- Speedup: ~10-15x vs. RISC-V
Keccak-256
- Module:
jolt-inlines/keccak256 - Operations: Permutation function
- Speedup: ~20-30x vs. RISC-V
BLAKE2b
- Module:
jolt-inlines/blake2 - Operations: Compression function
- Speedup: ~12-18x vs. RISC-V
BLAKE3
- Module:
jolt-inlines/blake3 - Operations: Compression function
- Speedup: ~12-18x vs. RISC-V
Elliptic Curve Operations
secp256k1
- Module:
jolt-inlines/secp256k1 - Operations: Point multiplication, ECDSA
- Speedup: ~50-100x vs. RISC-V
Grumpkin
- Module:
jolt-inlines/grumpkin - Operations: Curve arithmetic
- Speedup: ~50-100x vs. RISC-V
Big Integer Arithmetic
BigInt Multiplication
- Module:
jolt-inlines/bigint - Operations: 256-bit multiplication
- Speedup: ~5-10x vs. RISC-V
How Inlines Work
1. Custom Instruction Encoding
Inlines use RISC-V’s custom instruction extension space:2. Sequence Builder
Each inline defines a sequence builder that generates the constraint-native operation sequence:3. Tracer Integration
The tracer replaces custom instructions with the pre-computed sequence:4. Witness Generation
The inline sequence generates compact witness data:Performance Impact
SHA-256 Example
| Metric | RISC-V | Inline | Improvement |
|---|---|---|---|
| Instructions/block | ~1000 | ~80 | 12.5x |
| Witness rows | ~1000 | ~80 | 12.5x |
| Prover time | 100ms | ~7ms | 14x |
| Memory usage | High | Low | ~10x |
secp256k1 Example
| Metric | RISC-V | Inline | Improvement |
|---|---|---|---|
| Instructions/op | ~50,000 | ~500 | 100x |
| Witness rows | ~50,000 | ~500 | 100x |
| Prover time | 5s | ~50ms | 100x |
End-to-End Impact
For a program that performs:- 100 SHA-256 blocks
- 10 secp256k1 signatures
- SHA-256: 100,000 instructions
- secp256k1: 500,000 instructions
- Total: ~600,000 instructions
- Proving time: ~60s
- SHA-256: 8,000 instructions (inline sequences)
- secp256k1: 5,000 instructions (inline sequences)
- Other logic: ~10,000 instructions
- Total: ~23,000 instructions
- Proving time: ~12s
Creating Custom Inlines
To create a new inline for your application:1. Define the Inline Module
2. Implement Sequence Builder
3. Register the Inline
4. Provide Guest API
Best Practices
When to Use Inlines
✅ Good candidates:- Cryptographic primitives (hash, signatures, encryption)
- Fixed computation patterns (no data-dependent branching)
- High instruction count in RISC-V (>100 instructions)
- Performance-critical operations
- Simple operations (less than 10 instructions)
- Data-dependent control flow
- Operations that vary significantly based on input
Optimization Guidelines
- Minimize witness size: Each operation in the sequence adds to witness
- Use constraint-friendly operations: Prefer operations that map cleanly to R1CS constraints
- Avoid branches: Keep the sequence deterministic and fixed-length
- Test thoroughly: Verify correctness in both host and guest modes
Related Optimizations
- CompactPolynomial: Efficient witness storage
- Batched Sumcheck: Protocol-level batching
References
- Source:
jolt-inlines/directory in Jolt repository - RISC-V Custom Instruction Extension: RISC-V ISA Specification