A zero-knowledge file viewer with cryptographic redaction proofs
- Zero-Knowledge Proofs: Generate cryptographic proofs of file redaction without revealing original content
- Selective Redaction: Redact specific lines by index while preserving the rest
- Verification: Independently verify redaction proofs without access to the original file
- Multiple Output Formats: Support for both human-readable and JSON output
- Performance Metrics: Optional timing and statistics reporting
- File Export: Save redacted content to output files
- Trustless: No need to trust the redactor - cryptographic proofs ensure integrity
- Rust toolchain (1.70 or later)
- RISC Zero zkVM dependencies (automatically handled by cargo)
cargo install --git https://github.com/tanctl/zkcatgit clone https://github.com/tanctl/zkcat.git
cd zkcat
cargo build --releaseThe binary will be available at target/release/zkcat or you can install it with:
cargo install --path host# View file with redaction
zkcat <file> --redact <line_indices>
# Generate proof and save to file
zkcat document.txt --redact 1,3,5 --output redacted.txt
# Verify an existing proof
zkcat document.txt.zkproof --verify
# JSON output for programmatic use
zkcat document.txt --redact 2,4 --json
# Show performance statistics
zkcat document.txt --redact 1 --stats| Option | Short | Description |
|---|---|---|
--redact |
-r |
Comma-separated line indices to redact (0-indexed) |
--verify |
-v |
Verify an existing proof file |
--output |
-o |
Save redacted content to file |
--json |
Output results in JSON format | |
--stats |
Show performance statistics | |
--help |
-h |
Show help information |
--version |
Show version information |
Note: Line indices are 0-indexed, meaning the first line is line 0, second line is line 1, etc.
# Redact lines 1, 3, and 6 from document.txt
zkcat document.txt --redact 1,3,6Output:
Hello, this is a public note.
***REDACTED***
Nothing to redact in this line, all clear.
***REDACTED***
This file contains sensitive information.
Just a random comment about cats and pizza.
***REDACTED***
✓ Proof generated and verified!
- Full file SHA-256 hash: a1b2c3d4e5f6...
- Redacted file SHA-256 hash: f6e5d4c3b2a1...
- Redacted line indices: [1, 3, 6]
Proof saved to: document.txt.zkproof
zkcat document.txt --redact 1,3 --json --statsOutput:
{
"success": true,
"full_file_hash": "a1b2c3d4e5f6789abcdef123456789abcdef123456789abcdef123456789abcd",
"redacted_file_hash": "f6e5d4c3b2a1987654321fedcba987654321fedcba987654321fedcba987654",
"redacted_line_indices": [1, 3],
"proof_file": "document.txt.zkproof",
"output_file": null,
"statistics": {
"total_time_ms": 2543,
"proof_generation_time_ms": 2234,
"verification_time_ms": 12,
"file_size_bytes": 287,
"lines_total": 10,
"lines_redacted": 2
}
}zkcat document.txt.zkproof --verifyOutput:
✓ Proof verified successfully!
- Full file SHA-256 hash: a1b2c3d4e5f6789abcdef123456789abcdef123456789abcdef123456789abcd
- Redacted file SHA-256 hash: f6e5d4c3b2a1987654321fedcba987654321fedcba987654321fedcba987654
- Redacted line indices: [1, 3]
- Verification time: 0.012s
zkcat uses a host-guest architecture powered by the RISC Zero zkVM:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Host │ │ RISC Zero │ │ Guest │
│ (main app) │───▶│ zkVM │───▶│ (computation) │
│ │ │ │ │ │
│ • File I/O │ │ • Proof Gen │ │ • Hash original │
│ • CLI interface │ │ • Verification │ │ • Apply redact │
│ • Proof storage │ │ • Isolation │ │ • Hash redacted │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Host Binary (
host/src/main.rs): Command-line interface, file I/O, proof verification - Guest Program (
methods/guest/src/main.rs): Zero-knowledge computation in isolated environment - Methods (
methods/): Build configuration and method exports for zkVM integration - Workspace Configuration: Optimized build settings for zkVM performance
- Input: Original file content + redaction indices
- Guest Execution:
- Computes SHA-256 hash of original content
- Applies redaction to specified lines (replaces with "REDACTED")
- Computes SHA-256 hash of redacted content
- Commits hashes and indices to journal
- Proof Generation: zkVM creates cryptographic proof of correct execution
- Verification: Anyone can verify the proof without seeing original content
Proof files (.zkproof) contain:
- Receipt: Cryptographic proof of computation
- Journal Data: Original file hash, redacted file hash, redaction indices
- Method ID: Identifier for the guest program that generated the proof The proof files are serialized using bincode for efficient storage and transmission.
- Privacy: Original content never leaves the host system
- Integrity: Proof guarantees redaction was performed correctly
- Verifiability: Third parties can verify redaction without seeing original content
- Non-repudiation: Cryptographic proof prevents denial of redaction
cat > sensitive_doc.txt << EOF
Public information line 1
SECRET: API key yogurt
Public information line 3
CONFIDENTIAL: Password oiia
Public information line 5
EOFzkcat sensitive_doc.txt --redact 1,3 --output clean_doc.txt --stats# Share these files publicly:
# - clean_doc.txt (redacted content)
# - sensitive_doc.txt.zkproof (verification proof)
# Recipients can verify without seeing original:
zkcat sensitive_doc.txt.zkproof --verify# Use JSON output for automation
zkcat sensitive_doc.txt --redact 1,3 --json > redaction_result.json- Green text: Non-redacted lines
- Red text: Redacted lines shown as
***REDACTED*** - Checkmarks: Success indicators
- Hashes: SHA-256 hashes in hexadecimal
- Performance: Timing information when
--statsis used
{
"success": boolean,
"full_file_hash": "hex_string",
"redacted_file_hash": "hex_string",
"redacted_line_indices": [number],
"proof_file": "string",
"output_file": "string|null",
"statistics": {
"total_time_ms": number,
"proof_generation_time_ms": number,
"verification_time_ms": number,
"file_size_bytes": number,
"lines_total": number,
"lines_redacted": number
}
}# Process multiple files
for file in *.txt; do
zkcat "$file" --redact 0,2,4 --output "clean_$file" --json
done#!/bin/bash
# Automated redaction pipeline
RESULT=$(zkcat document.txt --redact 1,3,5 --json)
SUCCESS=$(echo "$RESULT" | jq -r '.success')
if [ "$SUCCESS" = "true" ]; then
echo "Redaction completed successfully"
PROOF_FILE=$(echo "$RESULT" | jq -r '.proof_file')
echo "Proof saved to: $PROOF_FILE"
else
echo "Redaction failed"
exit 1
fi# For large files, monitor performance
zkcat large_file.txt --redact 10,20,30 --stats --json | jq '.statistics'zkcat/
├── host/ # Main application
│ ├── src/main.rs # CLI interface and proof handling
│ └── Cargo.toml # Host dependencies
├── methods/ # zkVM integration
│ ├── guest/ # Guest program (runs in zkVM)
│ │ ├── src/main.rs # Zero-knowledge computation
│ │ └── Cargo.toml # Guest dependencies
│ ├── src/lib.rs # Method exports
│ ├── build.rs # Build configuration
│ └── Cargo.toml # Methods dependencies
└── Cargo.toml # Workspace configuration
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Built with RISC Zero zkVM
This project uses the RISC Zero zkVM, which is licensed under the Apache License 2.0.
zkcat - Trustless file redaction with zero-knowledge proofs