Skip to main content
Erst can generate signed audit logs that provide cryptographic proof of simulation results. This is essential for compliance, forensics, and maintaining tamper-evident records of transaction analysis.

Overview

Audit log signing creates a cryptographically signed record containing:
  • Transaction hash
  • Simulation results (events, logs, traces)
  • Timestamp
  • Digital signature
  • Public key for verification
  • Optional hardware attestation
Audit logs provide:
  • Tamper evidence: Any modification invalidates the signature
  • Non-repudiation: Proof that a specific key signed the data
  • Compliance: Auditable trail for regulatory requirements
  • Hardware attestation: Proof that signing keys are HSM-protected

Signing methods

Erst supports two signing methods:

Software signing

Uses Ed25519 private keys stored in PEM format
  • Fast and convenient
  • Suitable for development
  • Keys can be backed up

HSM signing

Uses hardware security modules via PKCS#11
  • Production-grade security
  • Keys never leave hardware
  • Compliance-ready

Software signing

Sign audit logs using an Ed25519 private key.

Generate a signing key

Create an Ed25519 key pair:
Protect your private key file with restricted permissions:

Sign with environment variable

Provide the private key via environment variable:

Sign with CLI flag

Provide the private key directly:
The audit:sign command is part of the TypeScript bindings. For Go CLI integration, see the implementation in internal/cmd/audit.go.

HSM signing (PKCS#11)

Sign audit logs using a hardware security module.

Prerequisites

Install PKCS#11 provider:

Configure environment

Set required environment variables:

Sign with HSM

Generate a signed audit log:
The command outputs signed JSON to stdout:

Hardware attestation

HSM signing can include hardware attestation proving the signing key is hardware-protected.

Attestation data

When signing with an HSM, the audit log includes:
  • Certificates: X.509 certificate chain (leaf to root)
  • Token info: HSM device information
  • Key non-exportable: Confirmation that the key cannot be extracted
  • Retrieved timestamp: When attestation was captured

Verification

The attestation is included in the signature hash, so:
  • Removing attestation invalidates the signature
  • Modifying attestation invalidates the signature
  • Attestation proves the key is HSM-protected
Hardware attestation is optional but recommended for high-security environments where you need cryptographic proof that keys are hardware-protected.

Audit log structure

Version 1.1.0 schema

Hash computation

The trace_hash is computed as:
The signature is:

Verification

Verify an audit log’s integrity and signature:

Programmatic verification

Manual verification

Verification results

  • Valid: Hash matches and signature verifies
  • Invalid: Payload was modified, signature is wrong, or key is incorrect
  • Attestation removed: Hash won’t match if attestation was stripped

YubiKey PIV integration

Use YubiKey devices for HSM signing.

PIV slots

YubiKey PIV supports multiple key slots: Recommended for audit logs: Slot 9c (Digital Signature)

Generate key on YubiKey

Configure for Erst

See docs/pkcs11-yubikey.md for detailed YubiKey setup.

Common workflows

Generate audit log after debugging

Batch audit log generation

Generate audit logs for multiple transactions:

Verify archived audit logs

Check integrity of stored logs:

Security best practices

For software keys:
  • Store with restricted permissions: chmod 600 key.pem
  • Never commit to version control
  • Use environment variables, not hardcoded paths
  • Rotate keys periodically
  • Back up securely (encrypted storage)
For HSM keys:
  • Never export private keys
  • Use strong PINs (not default PINs)
  • Enable PIN retry limits
  • Physical security for HSM devices
  • Audit HSM access logs
Software keys are convenient for development, but production audit logs should use HSM:
  • Keys cannot be extracted
  • Tamper-evident hardware
  • Compliance-ready (FIPS 140-2)
  • Hardware attestation available
  • Centralized key management
When using HSM, always include attestation:
  • Proves keys are hardware-protected
  • Cannot be forged
  • Required for high-assurance compliance
  • Covered by signature (tamper-evident)
  • Store in append-only storage
  • Use write-once media for immutability
  • Encrypt at rest
  • Replicate to multiple locations
  • Test restoration procedures
  • Document retention policies

Troubleshooting

Invalid signature

Solutions:
  • Verify you’re using the correct public key
  • Check audit log wasn’t modified
  • Ensure payload format matches schema version
  • Re-generate audit log if corrupted

HSM not detected

Solutions:
  • Check PKCS#11 module path: ls $ERST_PKCS11_MODULE
  • Install HSM drivers/software
  • Verify HSM is connected: yubico-piv-tool -a status
  • Check permissions: sudo usermod -a -G plugdev $USER

PIN incorrect

Solutions:
  • Verify PIN is correct
  • Check PIN hasn’t been locked (retry limit)
  • Reset PIN if needed (requires PUK)
  • Use correct PIN for the token

Key not found in HSM

Solutions:
  • List available keys: yubico-piv-tool -a list
  • Verify key label or ID is correct
  • Check you’re using the right slot
  • Generate key if it doesn’t exist

Implementation details

Source files

Audit log signing is implemented in:
  • internal/cmd/audit.go - Go implementation
  • internal/signer/ - Signer interface
  • internal/signer/memory.go - Software signer
  • internal/signer/pkcs11.go - HSM signer

Key functions

Audit log generation:
  • Generate() - Legacy function (software key)
  • GenerateWithSigner() - Generic signer interface
  • VerifyAuditLog() - Verify signature and hash
Location: internal/cmd/audit.go:73, internal/cmd/audit.go:84, internal/cmd/audit.go:143

Signer interface

Implementations:
  • InMemorySigner - Ed25519 software signing
  • Pkcs11Signer - PKCS#11 HSM signing

Next steps

HSM integration guide

Detailed HSM setup and configuration

Working with sessions

Save debugging context for audit log generation

Debugging failed transactions

Generate simulation results for signing