Sahyadri Vector Engine (SVE)
AVX2 + Rayon Cryptographic Acceleration
A high-performance dual-layer optimization system combining Intel AVX2 SIMD vectorization with Rust Rayon multi-core parallelism for accelerating Dilithium3 post-quantum signature verification in the Sahyadri L1 blockchain.
1. What is Sahyadri Vector Engine?
Sahyadri Vector Engine (SVE) is a cryptographic acceleration layer built into the core of Sahyadri L1 blockchain's consensus engine. It is not a separate program or external library, but rather an integrated optimization strategy that leverages two powerful technologies working together: Intel's AVX2 instruction set for single-core parallelism, and Rust's Rayon library for multi-core distributed processing.
| Component | Technology | Purpose |
|---|---|---|
| Layer 1 (Horizontal) | AVX2 SIMD | Process 8 numbers at once per CPU core |
| Layer 2 (Vertical) | Rayon Threads | Use all CPU cores simultaneously |
| Combined Effect | SVE | ~46x faster than scalar baseline (measured on 17-thread CPU) |
The engine targets specifically the Dilithium3 (CRYSTALS-Dilithium) signature verification algorithm, which is NIST's post-quantum cryptography standard selected to replace RSA and ECDSA against quantum computer attacks. Each Dilithium3 verification involves complex mathematical operations on polynomials (algebraic expressions with 256 terms), and SVE accelerates these operations dramatically.
Why "Vector Engine"?
The name comes from "vectorization" - the technique of performing one operation on multiple data points simultaneously. AVX2 uses 256-bit "vector registers" that hold 8 integers at once. When we add two vectors of 8 integers each, all 8 additions happen in a single clock cycle. This is like having 8 math workers inside one CPU core, plus Rayon adds 8 actual CPU cores, giving us 64 virtual workers total.
2. Why Sahyadri Uses It
To understand why SVE exists, we must first understand the problem it solves: Dilithium3 verification is computationally expensive, and Sahyadri processes thousands of these verifications every second.
The Workload Problem
| Metric | Value | Impact |
|---|---|---|
| Block Time | 1 second | All TXs must verify within this window |
| TXs per Block (target) | 1000-5000 | Each needs signature check |
| Dilithium3 Verify (scalar, baseline) | ~0.5 ms | 1000 TXs = 500 ms crypto-only |
| Dilithium3 Verify (AVX2, measured) | 0.0822 ms | 1000 TXs = 82 ms crypto-only |
| Dilithium3 Verify (AVX2 + Rayon, measured) | 0.0108 ms | 1000 TXs = 11 ms crypto-only |
Bottleneck Analysis Before SVE
BLOCK PROCESSING TIME BREAKDOWN (Before Optimization) Network Receive ████████████████████ 200ms (P2P propagation) DAG Sorting ██████████ 50ms (GhostDAG ordering) Disk Write ████ 20ms (RocksDB storage) State Update ██ 10ms (UTXO/DID changes) ──────────────────────────────────────────────────────────────── SIGNATURE VERIFY █████████████████ 500ms ← BOTTLENECK (50%!) ──────────────────────────────────────────────────────────────── TOTAL ~780ms (leaves only 220ms margin)
Without optimization, signature verification alone consumes over half the block time budget. This limits maximum TPS and creates risk of missed blocks under load. SVE reduces the crypto portion from 500ms to approximately 45ms, making network latency the new bottleneck instead.
Why Parallel Verification Works Here
Signature verification has a special property called "embarrassing parallelism" - verifying transaction A's signature has zero dependency on verifying transaction B's signature. They share no data, no ordering requirement, and no synchronization needed until all results are collected. This makes it perfect for both AVX2 (within one verification) and Rayon (across multiple verifications).
3. AVX2 Acceleration
AVX2 stands for "Advanced Vector Extensions 2" - Intel's 256-bit SIMD instruction set introduced in 2013 with Haswell processors. It is the key technology that enables SVE's single-core speedup.
How AVX2 Works (Visual Explanation)
NORMAL SCALAR OPERATION (1 number at a time): ┌─────┐ ┌─────┐ ┌─────┐ │ 5 │ + │ 3 │ = │ 8 │ ← 1 addition, 1 clock cycle └─────┘ └─────┘ └─────┘ AVX2 VECTOR OPERATION (8 numbers at once): ┌───────────────────────────────────────┐ │ 5 │ 12 │ 7 │ 23 │ 1 │ 9 │ 4 │ 15 │ ┐ └───────────────────────────────────────┘ │ VPADDQ instruction ┌───────────────────────────────────────┐ │ (256-bit add) │ 3 │ 4 │ 2 │ 10 │ 0 │ 5 │ 2 │ 8 │ ├→ 1 operation, 1 clock cycle └───────────────────────────────────────┘ │ ┌───────────────────────────────────────┐ ▼ │ 8 │ 16 │ 9 │ 33 │ 1 │ 14 │ 6 │ 23 │ └───────────────────────────────────────┘ RESULT: 8 additions in the time of 1! (8x speedup for this operation)
AVX2 Instructions in the Release Binary
Measured from target/release/sahyadrid using objdump -d | grep. The instruction mix is dominated by operations used in Dilithium's NTT, SHA3/Keccak permutation, and BLAKE3 hashing — all of which are AVX2-vectorized in the release build.
| Instruction | Purpose | Measured Count |
|---|---|---|
| VMOVDQU | Aligned/unaligned 256-bit load/store | 58,211 |
| VPXOR | 256-bit bitwise XOR | 22,266 |
| VPADDQ | Packed 64-bit integer add | 20,868 |
| VMOVDQA | Aligned 256-bit load/store | 20,073 |
| VPMULUDQ | Packed unsigned multiply (32×32→64) | 10,326 |
| VPAND | 256-bit bitwise AND | 7,655 |
| VPSUBQ | Packed 64-bit integer subtract | 4,112 |
| VPOR | 256-bit bitwise OR | 3,821 |
| VPBROADCASTQ / D / B | Broadcast scalar to vector | ~6,700 |
| VPMULDQ | Packed signed multiply (32×32→64) | 966 |
| VPMULLD | Packed 32-bit multiply | 530 |
| VPUNPCK* | Unpack/Interleave data | ~2,500 |
| VPALIGNR | Byte-level alignment | 457 |
| Total AVX2-family instructions | ~158,000 | |
The signed and unsigned packed-multiply instructions (VPMULDQ + VPMULUDQ + VPMULLD ≈ 11,822 total) are concentrated in the Dilithium NTT and polynomial multiplication paths. Before the AVX2 path was wired into the poly-level dispatcher, these were absent from the binary (VPMULDQ = 0); after the fix, they account for the core of the verification speedup.
CPU Compatibility Matrix
| CPU Generation | Example | Year | AVX2 Support | SVE Compatible |
|---|---|---|---|---|
| Intel Ivy Bridge | Core i7-3770 | 2012 | No (AVX only) | No |
| Intel Haswell | Core i7-4770 | 2013 | Yes | Yes |
| Intel Skylake | Core i7-6700 | 2015 | Yes | Yes (Target) |
| Intel Core Ultra | Core Ultra 7 | 2024 | Yes + AVX512 | Yes |
| AMD Zen 1 | Ryzen 1800X | 2017 | Yes | Yes |
| AMD Zen 4 | Ryzen 9 7950X | 2022 | Yes + AVX512 | Yes |
4. Rayon Parallel Verification
If AVX2 is like having 8 workers inside one office (CPU core), then Rayon is like opening 8 offices and giving each its own work. Rayon is Rust's data-parallelism library that automatically distributes work across available CPU cores using a work-stealing scheduler.
Rayon Architecture Diagram
RAYON THREAD POOL ARCHITECTURE
┌─────────────────────────────────────────────────────────────┐
│ VERIFY_POOL (LazyLock static) │
│ Thread Count: 7 threads │
│ Formula: (num_cpus - 1).max(1) │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Thread 0 │ │ Thread 1 │ │ ... Thread 6 │
│ (Worker #1) │ │ (Worker #2) │ │ (Worker #7) │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Signature #1 │ │ Signature #8 │ │ Signature #57 │
│ Signature #2 │ │ Signature #9 │ │ Signature #58 │
│ ... │ │ ... │ │ ... │
│ Signature #7 │ │ Signature #15 │ │ Signature #63 │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ dilithium-rs │ │ dilithium-rs │ │ dilithium-rs │
│ + AVX2 math │ │ + AVX2 math │ │ + AVX2 math │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
└────────────────────┼────────────────────┘
▼
┌────────────────────┐
│ Results Collected │
│ [true, true, │
│ false, true, ...]│
└─────────┬──────────┘
▼
Invalid TXs → REJECTED
Valid TXs → PROCESSEDWork Stealing Explained
Rayon uses "work stealing" - if Thread 0 finishes its 7 signatures but Thread 1 still has 3 left, Thread 0 can "steal" work from Thread 1's queue. This ensures balanced load even when some verifications take longer than others (due to cache misses, branch prediction failures, etc.).
| Scenario | Without Work Stealing | With Work Stealing (Rayon) |
|---|---|---|
| Thread 0 gets easy sigs | Waits idle | Steals work from busy thread |
| Thread 1 gets complex sigs | Becomes bottleneck | Work redistributed automatically |
| Total batch time | Max(any thread) | Near average(all threads) |
5. AVX2 + Rayon Combined Architecture
This is where the magic happens. AVX2 and Rayon operate at different levels of the computation stack, creating a multiplicative speedup effect.
Two-Dimensional Parallelism Diagram
TWO-DIMENSIONAL PARALLELISM MODEL
════════════════════════════════
VERTICAL (Rayon)
↑ Multi-Core
│
┌───────┼───────┬─────────┐
│ │ │ │ HORIZONTAL (AVX2)
Core 0 Core 1 Core 2 Core N Single-Core SIMD
│ │ │ │ ↓
┌───┴───┐ ┌─┴────┐ ┌─┴────┐ ┌─┴───┐ ┌─────────────────┐
│AVX2 x8│ │AVX2x8│ │AVX2x8 │ │AVX2x8│ │ 32-bit Integer │
│workers│ │workers││workers│ │workers│ │ Coefficients │
└───┬───┘ └──┬───┘ └──┬────┘ └──┬───┘ │ c0,c1,...c255] │
│ │ │ │ └─────────────────┘
└───────┴───────┴───────┘
│
TOTAL PARALLELISM
= 8 cores × 8 AVX2 lanes
= 64 simultaneous operations
SPEEDUP = 1.35 (AVX2) × 8 (Rayon)
≈ 10.8x theoretical (pre-AVX2-wiring)
≈ 46x measured (17-thread, target-cpu=native)Complete Execution Flow
STEP-BY-STEP: How SVE Processes A Block With 1000 Transactions
┌─────────────────────────────────────────────────────────────────────┐
│ STEP 1: BLOCK ARRIVAL │
│ Block received from P2P network containing 1000 transactions │
└─────────────────────────────────────────────────────────────────────┘ │
▼
┌─────────────────────────────────────────────────────────────────────┐
│ STEP 2: EXTRACTION │
│ Processor extracts 1000 (signature, pubkey) pairs into Vec buffer │
│ Memory used: ~1000 × (3309 + 1952) bytes ≈ 5.1 MB │
└─────────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────┐
│ STEP 3: RAYON DISPATCH │
│ VERIFY_POOL.install(|| { │
│ batch.par_iter().map(|(sig, pubkey)| { │
│ DilithiumKeyPair::verify(sig, pubkey) │
│ }).collect::<Vec<bool>>() │
│ }) │
│ │
│ → 1000 signatures ÷ 7 threads ≈ 143 signatures per thread │
└────────────────────────────────────────────────────────────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ THREAD 0 │ │ THREAD 1 │ │ THREAD 6 │
│ Sigs 0-142 │ │ Sigs 143-285 │ │ Sigs 857-999 │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ STEP 4: AVX2 │ │ STEP 4: AVX2 │ │ STEP 4: AVX2 │
│ PER-SIGNATURE │ │ PER-SIGNATURE │ │ PER-SIGNATURE │
│ │ │ │ │ │
│ 4a. Hash msg │ │ 4a. Hash msg │ │ 4a. Hash msg │
│ 4b. NTT(forward) AVX2 │ 4b. NTT(forward) AVX2 │ 4b. NTT(forward) AVX2│
│ 4c. Poly mult AVX2 │ 4c. Poly mult AVX2 │ 4c. Poly mult AVX2│
│ 4d. NTT(inverse)AVX2 │ 4d. NTT(inverse)AVX2 │ 4d. NTT(inverse)AVX2│
│ 4e. Compare │ │ 4e. Compare │ │ 4e. Compare │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
└───────────────────────┼───────────────────────┘
▼
┌────────────────────────────────────────────────────────────────────┐
│ STEP 5: RESULT AGGREGATION │
│ results = [true, true, false, true, true, ..., true] │
│ (997 valid, 3 invalid signatures detected) │
└────────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────┐
│ STEP 6: TRANSACTION FILTERING │
│ Valid TXs (997) → Continue to UTXO/DID processing │
│ Invalid TXs (3) → Rejected with "signature verification failed" │
└────────────────────────────────────────────────────────────────────┘
TOTAL WALL-CLOCK TIME: ~25ms (vs ~500ms sequential without SVE)Interaction Between Layers
| Aspect | AVX2 Role | Rayon Role | Combined Effect |
|---|---|---|---|
| Granularity | Instruction-level (within 1 verify) | Task-level (across verifies) | Both levels optimized |
| Data Scope | Polynomial coefficients (256 int32) | Full signatures (2465 bytes each) | Full stack coverage |
| Synchronization | None needed (single thread) | Join barrier at end | Minimal overhead |
| Speedup Type | Reduce work per verify | Divide work across cores | Multiplicative benefit |
6. Where It Is Used (Verification Call Sites)
SVE is integrated at 5 specific locations in the Sahyadri codebase where Dilithium3 signature verification occurs. Every location follows the same pattern but handles different transaction types.
Call Site Map
SAHYADRI CODEBASE - VERIFICATION LOCATIONS
═════════════════════════════════════════
consensus/src/
│
├── processes/transaction_validator/
│ └── tx_validation_in_isolation.rs
│ │
│ └── fn verify_account_tx_signatures_batch()
│ Account Transaction Verification
│ Handles CSM transfers between accounts
│ Highest volume site (~80% of all verifications)
│
└── pipeline/virtual_processor/
└── processor.rs
│
├── fn verify_did_create_signature()
│ New DID registration signatures
│
├── fn verify_did_update_signature()
│ Updating DID document attributes
│
├── fn verify_did_deactivate_signature()
│ Permanent DID deactivation
│
└── fn verify_account_tx_signatures()
Account TX (processor-level secondary path)Verification Sites Detail Table
| Site # | Function | TX Type | Volume % | Signature Size |
|---|---|---|---|---|
| 1 | verify_account_tx_signatures_batch | Account Transfer (CSM) | ~80% | 3309 bytes |
| 2 | verify_did_create_signature | DID_CREATE | ~5% | 3309 bytes |
| 3 | verify_did_update_signature | DID_UPDATE | ~5% | 3309 bytes |
| 4 | verify_did_deactivate_signature | DID_DEACTIVATE | ~5% | 3309 bytes |
| 5 | verify_account_tx_signatures | Account TX (alt path) | ~5% | 3309 bytes |
Code Pattern Used At Each Site
// This exact pattern appears at all 5 sites:
let is_valid = VERIFY_POOL.install(|| {
DilithiumKeyPair::verify(&signature_bytes, &public_key_bytes)
});
if !is_valid {
return Err(TransactionError::SignatureVerificationFailed);
}
// Variables differ per site:
// - Site 1: tx.sig, tx.pubkey (from UTXO input)
// - Site 2: did_create_tx.signature, did_create_tx.public_key
// - Site 3: did_update_tx.signature, controller_pubkey
// - Site 4: did_deactivate_tx.signature, current_did.pubkey
// - Site 5: account_tx.signature, account_tx.pubkey7. Implementation Details
Technology Stack
| Component | Choice | Version | Reason |
|---|---|---|---|
| Language | Rust | 1.78+ (Edition 2021) | Memory safety, zero-cost abstractions, excellent LLVM codegen |
| SIMD Library | dilithium-rs | v0.2.0 (upgrade to 0.3.0 recommended) | Pure Rust Dilithium with optional AVX2 |
| Parallel Library | rayon | v1.x (latest stable) | Data parallelism, work stealing, ergonomic API |
| Thread Pool Mgmt | LazyLock (std::sync) | Rust 1.70+ stable | One-time initialization, thread-safe |
| CPU Detection | num_cpus | v1.x | Portable core count across OSes |
| Build Target | .cargo/config.toml | target-cpu=native | Enables AVX2 code generation globally |
File Structure
sahyadri-final/sahyadri/
│
├── .cargo/
│ └── config.toml ← AVX2 ENABLEMENT (rustflags)
│
├── Cargo.toml ← Workspace root (profile.release settings)
│
├── consensus/
│ ├── Cargo.toml ← num_cpus dependency added
│ └── src/
│ ├── lib.rs / main.rs
│ │
│ ├── processes/transaction_validator/
│ │ └── tx_validation_in_isolation.rs
│ │ ├── Lines 10-19: use rayon, LazyLock, VERIFY_POOL definition
│ │ └── Lines 220-232: verify_account_tx_signatures_batch()
│ │
│ └── pipeline/virtual_processor/
│ └── processor.rs
│ ├── Lines 58-62: Imports + VERIFY_POOL definition
│ ├── Line 742: DID_CREATE verification (SVE active)
│ ├── Line 810: DID_UPDATE verification (SVE active)
│ ├── Line 853: DID_DEACTIVATE verification (SVE active)
│ └── Line 907: Account TX verification (SVE active)
│
└── crypto/dilithium/
├── Cargo.toml ← dilithium-rs dependency
└── src/lib.rs ← sahyadri-dilithium wrapperBuild Configuration
The current build uses target-cpu=native, which allows LLVM to emit the widest instruction set the build CPU supports (AVX2, plus AVX-512 where available). Deployments compiling for a specific baseline should set target-cpu explicitly.
# .cargo/config.toml (current) [build] rustflags = ["-C", "target-cpu=native"] # What target-cpu=native does: # 1. Detects host CPU features at compile time # 2. Emits widest supported SIMD (AVX2 minimum, AVX-512 where available) # 3. Results in ~158,000 AVX2-family instructions in the release binary # 4. Binary is NOT portable — must be rebuilt per CPU family # For distribution / portability, use an explicit baseline: # rustflags = ["-C", "target-cpu=native"] ← AVX2 baseline (Haswell 2013+) # rustflags = ["-C", "target-cpu=haswell"] ← Strict AVX2 floor # For maximum compatibility (no AVX2): # rustflags = ["-C", "target-cpu=x86-64-v2"] ← SSE4.2 baseline
8. Performance and Benchmarks
Verified Metrics (From Actual Build)
| Metric | Measured Value | Measurement Method |
|---|---|---|
| AVX2 Instruction Count | ~158,000 | objdump -d | grep -cE "vmovdqu|vpaddq|vpxor|..." |
| Build Time (clean) | 8m 22s | cargo clean && cargo build --release |
| Files Compiled | 35,935 files | cargo clean output |
| Cache Cleaned | 16.6 GiB | cargo clean output |
| Dilithium Tests | 9/9 passed | cargo test --manifest-path crypto/dilithium/Cargo.toml |
Measured Performance (17-thread CPU)
| Configuration | Time Per Verify | Throughput (per sec) | Source |
|---|---|---|---|
| Reference implementation (scalar NTT) | ~0.5 ms | ~2,000 | Upstream dilithium reference |
| AVX2 NTT, single-thread | 0.0822 ms | 12,166 | cargo run --example bench_verify |
| AVX2 NTT + Rayon, 17 threads | 0.0108 ms | 92,886 | cargo run --example bench_multithread |
Speedup vs reference: ~46x on 17-thread AVX2 hardware. Scaling from 1 to 17 threads is approximately 7.6x — close to linear, limited primarily by memory bandwidth at high concurrency.
Absolute numbers vary by CPU generation. Newer CPUs with wider AVX-512 support will be faster; older AVX2 CPUs (Haswell 2013+) will be slower but still usable.
Where Crypto Sits in the Bottleneck Stack
Signature verification is no longer the limiting factor. On 17-thread AVX2 hardware, the crypto layer alone can process ~92,000 verifications per second — well above what other pipeline stages (network, disk, state) can deliver.
| Stage | Observed / Estimated Capacity |
|---|---|
| Signature verification (AVX2 + Rayon, 17T) | ~92,000/sec |
| DAG ordering (GHOSTDAG blue set) | Tens of thousands/sec |
| RocksDB state writes | Tens of thousands/sec |
| P2P propagation | Network-bound; typical limits 5,000-20,000 TPS |
With AVX2 + Rayon active, the crypto stage has headroom above every other pipeline stage. Practical throughput is now determined by network propagation and block scheduling, not cryptographic verification.
Latency Contribution Per Block
Measurements from the single-block verification path. Ranges reflect hardware variance between generations.
| Operation | Scalar | AVX2 + Rayon | Improvement |
|---|---|---|---|
| Verify 1,000 signatures | ~500 ms | ~11 ms | ~46x |
| Verify 1,000 signatures (older AVX2 CPU) | ~500 ms | ~30-50 ms | ~10-15x |
| Crypto as % of 1-second block budget | ~50% | ~1% | Crypto no longer limits |
9. CPU Compatibility and Fallback
Compatibility Decision Tree
DOES YOUR CPU SUPPORT AVX2?
│
┌───────────────┴───────────────┐
│ │
YES NO
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ BINARY RUNS │ │ CRASH WITH │
│ SUCCESSFULLY │ │ SIGILL ERROR │
│ │ │ (Illegal │
│ Full SVE │ │ Instruction) │
│ Performance │ │ │
└────────┬────────┘ └────────┬────────┘
│ │
▼ ▼
Intel Haswell+ (2013+) Intel pre-Haswell
AMD Zen 1+ (2017+) AMD Bulldozer/PileDriver
Most modern servers Some Atom/Celeron chips
Apple Rosetta 2 (emulated) Embedded/IoT devices
COMPATIBLE NOT COMPATIBLEFallback Status
| Fallback Type | Status | Notes |
|---|---|---|
| Runtime CPU detection | Not implemented | Would need cpufeatures crate |
| Scalar fallback path | Not implemented | dilithium-rs may have internal fallback |
| Fat binary (multi-target) | Not implemented | Would double binary size |
| Separate build profile | Not created | Recommended for compatibility |
Recommended Deployment Targets
| Platform | Example Instance | AVX2 | Recommended |
|---|---|---|---|
| AWS | c5.xlarge, m5.large | Yes | Deploy |
| Azure | D4s v3, F2s v2 | Yes | Deploy |
| GCP | n2-standard-2, c2-instance | Yes | Deploy |
| AWS Graviton | t4g, m7g (ARM) | No | Need ARM build |
| Desktop/Laptop | Intel/AMD 2013+ | Yes | Run node |
10. Security Considerations
Security Properties Matrix
| Security Property | Status | Explanation |
|---|---|---|
| Dilithium3 Mathematical Security | Unchanged | Same algorithm, same security proof |
| Post-Quantum Resistance | Maintained | Lattice problems remain hard for quantum computers |
| Classical Security Level | Maintained | Equivalent to AES-192 classical strength |
| Constant-Time Execution | Preserved | dilithium-rs maintains constant-time guarantees |
| Timing Side Channels | No New Risk | AVX2 doesn't introduce variable-time paths |
| Cache Side Channels | Theoretical | Register spill possible but mitigated by compiler |
| Verification Completeness | Unchanged | All checks performed, none skipped |
| Signature Forgery Prevention | Maintained | Same rejection criteria as reference implementation |
What Optimization Does NOT Affect
CRYPTOGRAPHIC BOUNDARY OF OPTIMIZATION
══════════════════════════════════════
┌─────────────────────────────────────────────────────────────┐
│ OPTIMIZATION ZONE │
│ (AVX2 + Rayon operate here - ONLY performance changes) │
│ │
│ • How fast polynomial multiply completes │
│ • How many signatures verified per second │
│ • Which CPU cores do the work │
│ • How data is arranged in registers │
└─────────────────────────────────────────────────────────────┘
↑↓ NO CROSSING
┌─────────────────────────────────────────────────────────────┐
│ CRYPTOGRAPHIC ZONE │
│ (Untouched by optimization - security properties fixed) │
│ │
│ • Which mathematical operations are performed │
│ • What counts as valid vs invalid signature │
│ • Security reduction to Module-LWE/SIS problems │
│ • Resistance to forgery, replay, quantum attacks │
└─────────────────────────────────────────────────────────────┘11. Limitations
Current Limitations Detail
| Limitation | Impact | Mitigation | Priority |
|---|---|---|---|
| CPU Architecture Lock-in | Only runs on x86_64 with AVX2. ARM (Graviton, Apple Silicon), older CPUs cannot execute binary. | Create separate build profile with target-cpu generic for ARM/legacy | 🔴 High |
| No Runtime Fallback | Binary crashes with SIGILL on non-AVX2 CPU. No graceful error message. | Add cpufeatures check at startup, dispatch to scalar path | 🟡 Medium |
| Small Batch Overhead | For batches smaller than ~16 signatures, Rayon thread pool overhead (~2μs) exceeds parallelism benefit. | Add sequential fast-path for small batches (if batch.len() < 16) | 🟢 Low |
| Memory Bandwidth Saturation | 8 threads × 8-12KB per verify = 64-96KB concurrent read pressure. May exceed L1 cache on some CPUs. | Pre-fetch next batch while processing current; align data to cache lines | 🟢 Low |
| Diminishing Returns Past 8 Cores | Crypto workload is compute-bound, not memory-bound. Hyperthreading provides minimal gain (<15%). | Cap thread pool at physical core count, not logical | 🟢 Low |
| Compile Time Increase | AVX2 autovectorization passes increase compile time ~2x versus non-AVX2 build. | Use sccache for incremental compilation caching | 🟡 Medium |
| dilithium-rs Version | Currently on v0.2.0 which may have ZETAS bug in edge cases. v0.3.0 fixes this. | Upgrade dependency to 0.3.0+ before production | 🔴 High |
12. Reproducibility
This section provides complete information needed to independently reproduce the benchmarks and build results presented in this document.
Environment Specification
| Parameter | Value | Verification Command |
|---|---|---|
| Operating System | Linux (Ubuntu 22.04 LTS assumed) | uname -a |
| CPU Model | Intel Core Ultra (Meteor Lake) | cat /proc/cpuinfo | grep "model name" |
| Core Count | 8 physical (4P + 8E hybrid) | nproc |
| Architecture | x86_64 | uname -m |
| Rust Version | rustc 1.78.0 stable (or later) | rustc --version |
| Cargo Version | cargo 1.78.0 (or later) | cargo --version |
| Rust Edition | 2021 | In Cargo.toml |
| Target Triple | x86_64-unknown-linux-gnu | rustup show |
Dependency Versions (Cargo.lock)
| Package | Version | Source | Status |
|---|---|---|---|
| dilithium-rs | 0.3.0 | crates.io | ZETAS bug fixed |
| rayon | 1.x (latest stable) | crates.io | Active |
| num_cpus | 1.x (latest stable) | crates.io | Active |
| sahyadri-dilithium | 1.1.0 | local (crypto/dilithium/) | Active |
Build Configuration Files
# File: .cargo/config.toml [build] rustflags = ["-C", "target-cpu=native"] # File: Cargo.toml (workspace root) [profile.release] opt-level = 3 lto = "thin" codegen-units = 1 overflow-checks = false strip = true
12. Code Reference
The vector engine is implemented across two files. Each defines the same VERIFY_POOL pattern; the pool is instantiated once per module and reused.
Pool Definition
// File: consensus/src/processes/transaction_validator/
// tx_validation_in_isolation.rs
use std::sync::LazyLock;
use rayon::ThreadPoolBuilder;
use num_cpus;
pub(crate) static VERIFY_POOL: LazyLock<rayon::ThreadPool> =
LazyLock::new(|| {
ThreadPoolBuilder::new()
.num_threads((num_cpus::get() - 1).max(1))
.thread_name(|i| format!("sahyadri-verify-{i}"))
.build()
.expect("verify pool")
});Signature Verification Pattern
// Every call site uses the same four-line pattern:
let is_valid = VERIFY_POOL.install(|| {
DilithiumKeyPair::verify(&signature_bytes, &public_key_bytes)
});
if !is_valid {
return Err(TransactionError::SignatureVerificationFailed);
}Batch Verification
// File: consensus/src/processes/transaction_validator/
// tx_validation_in_isolation.rs
pub fn verify_account_tx_signatures_batch(
txs: &[FlashTransaction],
) -> Result<(), TransactionError> {
VERIFY_POOL.install(|| {
txs.par_iter()
.try_for_each(|tx| {
let sighash = tx.sighash();
let is_valid = DilithiumKeyPair::verify(
&tx.signature,
&tx.pubkey,
);
if !is_valid {
return Err(TransactionError::SignatureVerificationFailed);
}
Ok(())
})
})
}File Structure
sahyadri-final/sahyadri/
.cargo/
config.toml <- target-cpu=native enables AVX2
consensus/
Cargo.toml <- num_cpus dependency
src/
processes/transaction_validator/
tx_validation_in_isolation.rs
- LazyLock VERIFY_POOL
- verify_account_tx_signatures_batch
pipeline/virtual_processor/
processor.rs
- VERIFY_POOL (second instance)
- DID_CREATE/UPDATE/DEACTIVATE verification
- account TX verification (alt path)
crypto/dilithium/
src/lib.rs <- sahyadri-dilithium wrapper
re-exports dilithium-rs AVX2 backendVerification Commands
# Confirm the pool exists in the codebase grep -rn "VERIFY_POOL" consensus/src/ | grep -v target # Confirm AVX2 dispatch is wired grep -rn "DilithiumKeyPair::verify" consensus/src/ | grep -v target # Measure AVX2 instruction count in the binary objdump -d target/release/sahyadrid | grep -cE "vmovdqu|vpaddq|vpxor|vpmul" # Measure per-verification throughput cargo run --release --example bench_verify # Measure parallel throughput cargo run --release --example bench_multithread
The three commands at the bottom of the block are what a reviewer would run to independently reproduce the throughput numbers in Section 3. The numbers are not asserted by the documentation — they are measured from the binary that the reviewer builds on their own hardware.
Summary
Sahyadri Vector Engine is the AVX2 + Rayon acceleration layer that turns Dilithium3 verification from a bottleneck into a negligible cost. On 17-thread AVX2 hardware, single-thread verification runs at 0.0822 ms (12,166/sec); 17-thread throughput reaches 92,886/sec (0.0108 ms per verification). This is roughly 46x faster than the scalar reference implementation and well ahead of what other pipeline stages (network, disk, state) can sustain.
The compiled binary contains approximately 158,000 AVX2-family instructions, with 11,822 concentrated in signed/unsigned packed multiplies that drive the Dilithium NTT — the core of the algorithm. The AVX2 NTT path is wired through the poly-level dispatcher, so all callers (transaction validation, DID operations, batch verification) automatically use it.
Builds use target-cpu=native by default; production deployments that require portability should set an explicit baseline (Haswell / Skylake) at build time. Future work includes runtime CPU detection for broader compatibility and AVX-512 exploitation on newer hardware.