Audit Proof Circuit
A zero-knowledge proof circuit for generating tamper-proof audit logs without exposing sensitive data. This circuit implements patent claims 6 and 9, providing cryptographic integrity verification for audit trails while maintaining complete privacy.
β οΈ Important: SDK Required with API Key
This circuit requires the AffixIO SDK from NPM to function. The SDK is NOT included in this repository.
For production use, you MUST have an API key from AffixIO. Get your API key at: https://dashboard.affix-io.com
Model Details
- Circuit Type: Zero-Knowledge Proof (Noir)
- Proof System: Noir (Barretenberg backend)
- Version: 0.1.0
- Use Case: Audit logging, compliance verification, tamper-proof records
- License: MIT
- Developed by: AffixIO
Model Description
The Audit Proof circuit generates zero-knowledge proofs for audit logs, allowing verification of audit integrity without revealing:
- Decision values
- Timestamps
- Pseudonymised identifiers
- Rule hashes
This enables privacy-preserving compliance logging and audit trail verification across industries including finance, healthcare, government, and enterprise sectors.
Inputs
The circuit accepts four private inputs (all Field type):
| Input | Type | Description |
|---|---|---|
decision_value |
Field | The decision value being audited |
timestamp |
Field | Timestamp of the audit event |
pseudonymised_id |
Field | Pseudonymised identifier for privacy |
rules_hash |
Field | Cryptographic hash of the rules applied |
Outputs
The circuit returns a single public output:
| Output | Type | Description |
|---|---|---|
integrity_verified |
Field | Integrity verification result (1 = verified, 0 = failed) |
Installation
Step 1: Install the AffixIO SDK
This is required to use this circuit. The SDK is not included in this repository.
npm install @affixio/sdk
Step 2: Get Your API Key
- Sign up at https://dashboard.affix-io.com
- Navigate to API Keys section
- Create a new API key
- Copy your API key (starts with
affix_)
Step 3: Install Noir (Optional - for circuit development only)
If you want to compile or modify the circuit locally:
# Using noirup (Recommended)
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
noirup
# Or using npm
npm install -g @noir-lang/noir_wasm
# Or using cargo
cargo install nargo
Usage
Production Usage with API Key (Required)
You must use an API key for production deployments. Sandbox mode is only for testing.
import { AffixIO } from '@affixio/sdk';
// Initialize SDK with your API key
const sdk = new AffixIO({
apiKey: process.env.AFFIXIO_API_KEY || 'affix_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
baseURL: 'https://api.affix-io.com'
});
// Generate audit proof
const result = await sdk.circuits.auditProof({
decisionValue: 1, // 1 = approved, 0 = denied
pseudonymisedId: '0x1234567890abcdef1234567890abcdef',
rulesHash: '0xabcdef1234567890abcdef1234567890',
timestamp: new Date().toISOString()
});
console.log('Decision:', result.decision ? 'Approved' : 'Denied');
console.log('Verified:', result.verified);
console.log('Proof ID:', result.proofId);
console.log('Proof:', result.proof);
Environment Variables
For security, store your API key in environment variables:
# .env file
AFFIXIO_API_KEY=affix_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
import { AffixIO } from '@affixio/sdk';
const sdk = new AffixIO({
apiKey: process.env.AFFIXIO_API_KEY, // Load from environment
baseURL: 'https://api.affix-io.com'
});
Sandbox Mode (Testing Only)
Note: Sandbox mode is for testing only. Production requires an API key.
import { AffixIO } from '@affixio/sdk';
// Initialize SDK in sandbox mode (no API key needed for testing)
const sdk = new AffixIO({
sandbox: true
});
// Generate audit proof
const result = await sdk.circuits.auditProof({
decisionValue: 1,
pseudonymisedId: '0x1234567890abcdef',
rulesHash: '0xabcdef1234567890',
timestamp: new Date().toISOString()
}, true); // Use sandbox mode
console.log('Decision:', result.decision);
console.log('Verified:', result.verified);
console.log('Proof:', result.proof);
Direct Circuit Compilation (Advanced)
If you want to compile and use the circuit directly with Noir (not recommended for production):
# Compile the circuit
nargo compile
# This generates circuit artifacts in target/
Then use with Noir SDK:
import { Noir } from '@noir-lang/noir_js';
import { BarretenbergBackend } from '@noir-lang/backend_barretenberg';
import circuit from './target/audit_proof.json';
// Initialize backend and circuit
const backend = new BarretenbergBackend(circuit);
const noir = new Noir(circuit);
// Prepare inputs
const inputs = {
decision_value: "1",
timestamp: "1704067200",
pseudonymised_id: "0x1234567890abcdef",
rules_hash: "0xabcdef1234567890"
};
// Generate proof
const proof = await noir.generateProof(inputs);
// Verify proof
const verification = await noir.verifyProof(proof);
console.log('Verification result:', verification);
Examples
See the examples/ directory for complete usage examples:
basic-usage.ts- Basic SDK usage with sandbox modeauthenticated-usage.ts- Production API usage with API keybatch-audit.ts- Batch audit proof generation
Use Cases
Compliance & Regulatory
- GDPR/CCPA Compliance: Generate audit proofs without storing personal data
- Financial Audits: Tamper-proof transaction logs
- Healthcare: HIPAA-compliant audit trails
- Government: Secure compliance verification
Enterprise Applications
- Access Control: Audit access decisions without exposing user data
- Decision Logging: Privacy-preserving decision audit trails
- Compliance Reporting: Generate verifiable compliance reports
- Risk Management: Audit risk assessment decisions
Circuit Structure
.
βββ src/
β βββ main.nr # Main circuit implementation
βββ Nargo.toml # Noir project configuration
βββ Prover.toml.example # Example prover configuration
βββ README.md # This file
βββ examples/ # Usage examples
β βββ basic-usage.ts
β βββ authenticated-usage.ts
β βββ batch-audit.ts
βββ metadata.yaml # Circuit metadata
βββ LICENSE # MIT License
βββ CITATION.cff # Citation information
Input Format
All inputs are Noir Field types, which are integers modulo the field modulus. When using the SDK, you can pass:
- Numbers: String representations (e.g.,
"1","1704067200") - Hex Strings: Hexadecimal strings prefixed with
0x(e.g.,"0x1234") - BigInt: BigInt values for large numbers
- ISO Timestamps: For timestamp fields, the SDK accepts ISO 8601 strings which are converted to Unix timestamps
Output Format
The circuit returns a Field value:
1if integrity verification passes0if integrity verification fails
Security Notes
β οΈ Important Security Considerations:
- API Key Security: Never commit API keys to version control. Always use environment variables
- This circuit uses a simplified integrity check. In production, consider implementing proper cryptographic hash verification
- Always verify proofs on-chain or in a trusted verification environment
- Keep private inputs secure and never expose them in logs or error messages
- Use the AffixIO SDK for production deployments as it includes additional security features
- Store proofs securely and maintain proof verification records
Performance
- Proof Generation: < 500ms average (online), < 200ms (offline with SDK)
- Verification: < 100ms average
- Circuit Size: Optimized for production use
Limitations
- Simplified integrity check (for production, use full cryptographic hashing)
- Requires AffixIO SDK with API key for production use
- Field size limitations apply (Noir field modulus)
- SDK must be installed separately (not included in repository)
API Key Management
Getting an API Key
- Visit https://dashboard.affix-io.com
- Sign up or log in
- Navigate to "API Keys" section
- Create a new API key
- Copy and store securely
Using API Keys Securely
// β
Good: Use environment variables
const sdk = new AffixIO({
apiKey: process.env.AFFIXIO_API_KEY
});
// β Bad: Hardcode API keys
const sdk = new AffixIO({
apiKey: 'affix_my_secret_key_here' // Never do this!
});
API Key Format
API keys start with affix_ followed by a long alphanumeric string:
affix_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Citation
If you use this circuit in your research or production system, please cite:
@software{affixio_audit_proof,
title = {Audit Proof Circuit - Zero-Knowledge Proof for Tamper-Proof Audit Logs},
author = {AffixIO},
year = {2024},
url = {https://huggingface.co/affixio/audit-proof-circuit}
}
License
MIT License - See LICENSE file for details
Contributing
Contributions to improve the circuit or documentation are welcome. Please ensure:
- All changes maintain backward compatibility
- Security best practices are followed
- Tests are included for new features
Support
For issues related to:
- This Circuit: Open an issue on the Hugging Face model page
- AffixIO SDK: Visit https://www.affix-io.com/docs or email support@affix-io.com
- API Keys: Visit https://dashboard.affix-io.com
- Noir SDK: Visit Noir documentation or Noir GitHub
References
- AffixIO Documentation
- AffixIO SDK
- AffixIO Dashboard
- Noir Documentation
- Noir GitHub Repository
- Zero-Knowledge Proofs Explained
Related Models
Check out other AffixIO circuits on Hugging Face:
Built with β€οΈ by AffixIO
β οΈ Remember: This circuit requires the AffixIO SDK with an API key for production use. Get your API key at https://dashboard.affix-io.com