security-gpu-attest

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

security-gpu-attest

Zero-CGo, zero-entitlement demo that executes an inline Metal compute kernel, attests real Apple Silicon GPU execution via x/engineattest, signs the attestation receipt with an ephemeral hardware Secure Enclave P-256 key via x/enclave, verifies the ASN.1 signature with Go's stdlib crypto/ecdsa, and proves a CPU-forged impostor is rejected.

What It Does

  1. Attested GPU compute (metal + x/engineattest): compiles an inline MSL affine_mix kernel and executes it through engineattest.Queue.GPU, verifying a nonzero hardware GPU scheduling window (GPUEndTime > GPUStartTime > 0) and hashing the GPU output buffer (SHA-256).
  2. Negative-control CPU impostor: runs a CPU loop computing the same transform without dispatching to Metal and asserts engineattest.Queue.GPU rejects it with engineattest.ErrDidNotRun.
  3. Hardware Secure Enclave receipt signing (x/enclave): generates an ephemeral P-256 key (IsHardwareBacked() == true on Apple Silicon; cleaned up via defer key.Close()), signs the canonical attestation receipt digest, and cross-verifies the DER signature + tampered-digest rejection using stdlib crypto/ecdsa.VerifyASN1.

Usage

CGO_ENABLED=0 go run ./examples/security/security-gpu-attest

Flags:

  • -n — float32 elements to process on GPU (default 1048576)
  • -require-hardware — fail closed if Secure Enclave is unavailable

Sample Output (Apple M4 Max)

=== GPU Execution Attestation (Apple M4 Max) ===
  GPU dispatch:    PASS (kernel=affine_mix, n=1048576, gpu=104µs)
  Output SHA-256:  c67fa3230fbc1154e29d05104ecf3df8522d3673cb29770b7232dbf7155258c2
  CPU impostor:    REJECTED (engineattest: no command buffer was created during the attested region: engine did not execute during the attested region)

=== Secure Enclave Receipt Signature ===
  Probe available: true
  Hardware-backed: true (ephemeral key cleaned up on exit)
  Public key:      044a46bf178d4657a98e2bf99b48f2d8... (65B X9.63)
  Receipt:         device=Apple M4 Max;kernel=affine_mix;n=1048576;gpu_us=104;out_sha256=c67fa3230fbc1154;attested=gpu;ts=2026-11-28T01:58:10Z
  ECDSA ASN.1 sig: 72 bytes
  stdlib verify:   PASS (crypto/ecdsa.VerifyASN1)
  Tamper check:    REJECTED=true

Documentation

Rendered for darwin/amd64

Overview

Command security-gpu-attest executes an inline Metal compute kernel, attests real Apple Silicon GPU execution via x/engineattest, signs the attestation receipt with a Secure Enclave P-256 key (x/enclave), verifies it with stdlib crypto/ecdsa, and proves that a CPU-forged impostor is rejected.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL