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.

ComponentTechnologyPurpose
Layer 1 (Horizontal)AVX2 SIMDProcess 8 numbers at once per CPU core
Layer 2 (Vertical)Rayon ThreadsUse all CPU cores simultaneously
Combined EffectSVE~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

MetricValueImpact
Block Time1 secondAll TXs must verify within this window
TXs per Block (target)1000-5000Each needs signature check
Dilithium3 Verify (scalar, baseline)~0.5 ms1000 TXs = 500 ms crypto-only
Dilithium3 Verify (AVX2, measured)0.0822 ms1000 TXs = 82 ms crypto-only
Dilithium3 Verify (AVX2 + Rayon, measured)0.0108 ms1000 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.

InstructionPurposeMeasured Count
VMOVDQUAligned/unaligned 256-bit load/store58,211
VPXOR256-bit bitwise XOR22,266
VPADDQPacked 64-bit integer add20,868
VMOVDQAAligned 256-bit load/store20,073
VPMULUDQPacked unsigned multiply (32×32→64)10,326
VPAND256-bit bitwise AND7,655
VPSUBQPacked 64-bit integer subtract4,112
VPOR256-bit bitwise OR3,821
VPBROADCASTQ / D / BBroadcast scalar to vector~6,700
VPMULDQPacked signed multiply (32×32→64)966
VPMULLDPacked 32-bit multiply530
VPUNPCK*Unpack/Interleave data~2,500
VPALIGNRByte-level alignment457
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 GenerationExampleYearAVX2 SupportSVE Compatible
Intel Ivy BridgeCore i7-37702012No (AVX only)No
Intel HaswellCore i7-47702013YesYes
Intel SkylakeCore i7-67002015YesYes (Target)
Intel Core UltraCore Ultra 72024Yes + AVX512Yes
AMD Zen 1Ryzen 1800X2017YesYes
AMD Zen 4Ryzen 9 7950X2022Yes + AVX512Yes

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  → PROCESSED

Work 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.).

ScenarioWithout Work StealingWith Work Stealing (Rayon)
Thread 0 gets easy sigsWaits idleSteals work from busy thread
Thread 1 gets complex sigsBecomes bottleneckWork redistributed automatically
Total batch timeMax(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

AspectAVX2 RoleRayon RoleCombined Effect
GranularityInstruction-level (within 1 verify)Task-level (across verifies)Both levels optimized
Data ScopePolynomial coefficients (256 int32)Full signatures (2465 bytes each)Full stack coverage
SynchronizationNone needed (single thread)Join barrier at endMinimal overhead
Speedup TypeReduce work per verifyDivide work across coresMultiplicative 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 #FunctionTX TypeVolume %Signature Size
1verify_account_tx_signatures_batchAccount Transfer (CSM)~80%3309 bytes
2verify_did_create_signatureDID_CREATE~5%3309 bytes
3verify_did_update_signatureDID_UPDATE~5%3309 bytes
4verify_did_deactivate_signatureDID_DEACTIVATE~5%3309 bytes
5verify_account_tx_signaturesAccount 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.pubkey

7. Implementation Details

Technology Stack

ComponentChoiceVersionReason
LanguageRust1.78+ (Edition 2021)Memory safety, zero-cost abstractions, excellent LLVM codegen
SIMD Librarydilithium-rsv0.2.0 (upgrade to 0.3.0 recommended)Pure Rust Dilithium with optional AVX2
Parallel Libraryrayonv1.x (latest stable)Data parallelism, work stealing, ergonomic API
Thread Pool MgmtLazyLock (std::sync)Rust 1.70+ stableOne-time initialization, thread-safe
CPU Detectionnum_cpusv1.xPortable core count across OSes
Build Target.cargo/config.tomltarget-cpu=nativeEnables 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 wrapper

Build 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)

MetricMeasured ValueMeasurement Method
AVX2 Instruction Count~158,000objdump -d | grep -cE "vmovdqu|vpaddq|vpxor|..."
Build Time (clean)8m 22scargo clean && cargo build --release
Files Compiled35,935 filescargo clean output
Cache Cleaned16.6 GiBcargo clean output
Dilithium Tests9/9 passedcargo test --manifest-path crypto/dilithium/Cargo.toml

Measured Performance (17-thread CPU)

ConfigurationTime Per VerifyThroughput (per sec)Source
Reference implementation (scalar NTT)~0.5 ms~2,000Upstream dilithium reference
AVX2 NTT, single-thread0.0822 ms12,166cargo run --example bench_verify
AVX2 NTT + Rayon, 17 threads0.0108 ms92,886cargo 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.

StageObserved / Estimated Capacity
Signature verification (AVX2 + Rayon, 17T)~92,000/sec
DAG ordering (GHOSTDAG blue set)Tens of thousands/sec
RocksDB state writesTens of thousands/sec
P2P propagationNetwork-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.

OperationScalarAVX2 + RayonImprovement
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 COMPATIBLE

Fallback Status

Fallback TypeStatusNotes
Runtime CPU detectionNot implementedWould need cpufeatures crate
Scalar fallback pathNot implementeddilithium-rs may have internal fallback
Fat binary (multi-target)Not implementedWould double binary size
Separate build profileNot createdRecommended for compatibility

Recommended Deployment Targets

PlatformExample InstanceAVX2Recommended
AWSc5.xlarge, m5.largeYesDeploy
AzureD4s v3, F2s v2YesDeploy
GCPn2-standard-2, c2-instanceYesDeploy
AWS Gravitont4g, m7g (ARM)NoNeed ARM build
Desktop/LaptopIntel/AMD 2013+YesRun node

10. Security Considerations

Security Properties Matrix

Security PropertyStatusExplanation
Dilithium3 Mathematical SecurityUnchangedSame algorithm, same security proof
Post-Quantum ResistanceMaintainedLattice problems remain hard for quantum computers
Classical Security LevelMaintainedEquivalent to AES-192 classical strength
Constant-Time ExecutionPreserveddilithium-rs maintains constant-time guarantees
Timing Side ChannelsNo New RiskAVX2 doesn't introduce variable-time paths
Cache Side ChannelsTheoreticalRegister spill possible but mitigated by compiler
Verification CompletenessUnchangedAll checks performed, none skipped
Signature Forgery PreventionMaintainedSame 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

LimitationImpactMitigationPriority
CPU Architecture Lock-inOnly 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 FallbackBinary crashes with SIGILL on non-AVX2 CPU. No graceful error message.Add cpufeatures check at startup, dispatch to scalar path🟡 Medium
Small Batch OverheadFor 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 Saturation8 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 CoresCrypto workload is compute-bound, not memory-bound. Hyperthreading provides minimal gain (<15%).Cap thread pool at physical core count, not logical🟢 Low
Compile Time IncreaseAVX2 autovectorization passes increase compile time ~2x versus non-AVX2 build.Use sccache for incremental compilation caching🟡 Medium
dilithium-rs VersionCurrently 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

ParameterValueVerification Command
Operating SystemLinux (Ubuntu 22.04 LTS assumed)uname -a
CPU ModelIntel Core Ultra (Meteor Lake)cat /proc/cpuinfo | grep "model name"
Core Count8 physical (4P + 8E hybrid)nproc
Architecturex86_64uname -m
Rust Versionrustc 1.78.0 stable (or later)rustc --version
Cargo Versioncargo 1.78.0 (or later)cargo --version
Rust Edition2021In Cargo.toml
Target Triplex86_64-unknown-linux-gnurustup show

Dependency Versions (Cargo.lock)

PackageVersionSourceStatus
dilithium-rs0.3.0crates.ioZETAS bug fixed
rayon1.x (latest stable)crates.ioActive
num_cpus1.x (latest stable)crates.ioActive
sahyadri-dilithium1.1.0local (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 backend

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