
Hardware-bound & Cloud-gated binary execution, cryptographic provenance, and anti-tamper envelope sealing for Crystal.
Hardware-Bound & Cloud-Gated Binary Execution and Anti-Tamper Envelope Sealing for Crystal.
Pyrite ensures that your compiled Crystal binary only executes on your authorized infrastructure. If an adversary extracts, leaks, steals, or modifies the binary, execution halts immediately before any application logic or secrets are exposed.
systemd-creds) or Google Cloud Run IAM / Cloud KMS./proc/self/exe and compares it against the authorized hash decrypted from the envelope. Any 1-byte alteration halts the process instantly.strip -s) contains zero symbol tables, reflection metadata, or plaintext configuration. Decompilation yields only a dead decryption wrapper.shard.ymldependencies:
pyrite:
github: renich/pyrite
version: ~> 0.2.0
require "pyrite"
require "kemal"
# Define strongly-typed application configuration
struct AppConfig
include JSON::Serializable
getter database_url : String
getter session_secret : String
getter api_token : String
end
# 1-line verification & bootstrap:
config = Pyrite.bootstrap!(AppConfig)
puts "Pyrite verified binary integrity. Starting application..."
get "/" do
"Secure service running on authorized hardware."
end
Kemal.run
Pyrite enforces an absolute zero-trust, fail-closed policy:
Pyrite::HardwareAuthError and exits with code 1.bin/pyrite)When installed, Pyrite provides a compiled CLI tool to automate LLVM compilation, ELF symbol stripping, SHA-256 digest hashing, and envelope sealing.
# Build & Seal for Google Cloud Run (KMS):
bin/pyrite build \
--input=src/main.cr \
--output=bin/app \
--target=gcp \
--kms-key="projects/my-p/locations/global/keyRings/my-r/cryptoKeys/app-key" \
--config=config/production.json
# Build & Seal for Bare-Metal Fedora (TPM 2.0 / systemd-creds):
bin/pyrite build \
--input=src/main.cr \
--output=bin/app \
--target=baremetal \
--pcr=0,7 \
--config=config/production.json
# Build & Seal for AWS (ECS / Lambda / KMS):
bin/pyrite build \
--input=src/main.cr \
--output=bin/app \
--target=aws \
--kms-key="arn:aws:kms:us-east-1:123456789012:key/..." \
--config=config/production.json
| Environment | Provider | Root of Trust | Protection |
|---|---|---|---|
| Google Cloud Run | Pyrite::Providers::GCPKMS | Google Cloud IAM + Cloud KMS | BinAuthz + Instance Metadata OIDC |
| Fedora / Bare-Metal | Pyrite::Providers::SystemdCreds | Host TPM 2.0 (PCR 0,7) | systemd-creds + Linux Kernel IMA |
| Bare-Metal Direct | Pyrite::Providers::TPM2Direct | /dev/tpmrm0 chip | Direct TPM2 PCR unseal (tpm2-tools) |
| AWS (ECS / Lambda) | Pyrite::Providers::AWSKMS | IMDSv2 + AWS KMS | AWS IAM Task Role Decrypt |
Exhaustive technical documentation, specifications, and architecture decision records are maintained in reStructuredText under docs/: