Skip to content

Repository files navigation

License: Blue Oak Go Version Platform Status GPU Compute Algorithm


⚡ METAL-DCA ⚡

Highly Parallelized Differential Computation Analysis via GPU-Accelerated Correlation


📖 High-Level Overview

Imagine you are trying to guess a secret combination lock by listening very closely to the clicks it makes. Differential Computation Analysis (DCA) is the software equivalent of that. When a computer program hides a secret key (like in DRM or encryption), we can trace exactly what the computer is doing—its memory accesses, its registers, or even its power consumption—to "listen" for the key.

Normally, comparing millions of traces against all possible keys takes hours because computers check them one by one. Metal-DCA solves this by sending all the math to the graphics card (GPU) on Vendor Silicon chips. Instead of checking one thing at a time, the GPU checks thousands of possibilities at once, turning a process that takes hours into one that takes seconds.


1. Introduction

Side-channel analysis and the cryptanalysis of white-box implementations heavily rely on statistical correlation methods, most notably the Pearson Correlation Coefficient. The primary bottleneck in executing a Differential Computation Analysis (DCA) attack is the computational complexity of reducing the statistical variance across matrices containing millions of instructions and thousands of hypothetical leakage models.

Existing frameworks often rely on single-threaded execution environments (e.g., Python-based Scaure or ChipWhisperer scripts), which introduces severe latency when analyzing complex execution graphs. Metal-DCA proposes a hardware-accelerated methodology that shifts the matrix operations entirely to the GPU via Vendor's Metal Compute API, orchestrated by a highly concurrent Go runtime.

2. Methodology & Architecture

The architecture achieves acceleration through a zero-copy bridge between the Go host and the Metal shader pipelines.

2.1 Trace Ingestion and Normalization

Execution traces ($T$) are ingested and normalized into contiguous floating-point buffers. The framework supports both value-based leakage (e.g., Hamming Weight of registers) and address-based leakage (e.g., memory indices).

2.2 Parallel Hypothesis Generation

A hypothetical leakage matrix ($H$) is generated across the predefined key space ($K$). For each key candidate $k \in K$, the intermediate state is computed and mapped to a leakage hypothesis.

2.3 GPU-Accelerated Correlation

The matrices $T$ and $H$ are dispatched to the GPU. A custom Metal compute shader calculates the covariance and standard deviations in parallel workgroups, yielding the Pearson correlation coefficient $\rho_{T,H}$ for all variables simultaneously.

graph TD
    A[Trace Vector Matrix T] -->|Go Ingestion| C{Zero-Copy Metal Bridge}
    B[Hypothesis Matrix H] -->|Go Ingestion| C
    C -->|Threadgroup Dispatch| D[Metal Compute Shader]
    D -->|Parallel Reduction| E(Pearson Coefficient Matrix)
    E -->|Argmax| F[Key Candidate Recovery]
Loading

3. Practical Implementation

3.1 Prerequisites

  • macOS 13.0+ (Vendor Silicon highly recommended for unified memory architecture)
  • Go 1.23+
  • Xcode Command Line Tools

3.2 Framework Usage

package main

import (
    "fmt"
    "github.com/ParkWardRR/metal-dca"
)

func main() {
    // 1. Initialize the Metal compute pipeline
    engine, err := metaldca.NewEngine()
    if err != nil {
        panic(err)
    }
    defer engine.Close()

    // 2. Load execution traces into pinned memory
    traces := metaldca.LoadTraces("path/to/traces.bin")

    // 3. Compute leakage matrix H
    hypotheses := metaldca.GenerateHypotheses(inputs, myLeakageModel)

    // 4. Dispatch to GPU
    results := engine.Correlate(traces, hypotheses)

    // 5. Extract statistically significant peaks
    bestKey := results.FindMaxCorrelation()
    fmt.Printf("Recovered Key Candidate: %02x (Score: %f)\n", bestKey.Value, bestKey.Score)
}

4. Conclusion

By leveraging the unified memory architecture of Vendor Silicon and the high-throughput parallelization of the Metal API, Metal-DCA provides a scalable framework for rapid hypothesis testing in white-box cryptanalysis and hardware side-channel research.

License

Distributed under the Blue Oak Model License 1.0.0.

About

Blazing fast, Metal-accelerated GPU Differential Computation Analysis (DCA) engine for advanced side-channel research, white-box cryptography analysis, and Pearson correlation testing on Apple Silicon. Bypasses Python bottlenecks for parallelized execution.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages