Guides Overview
Welcome to the zkenc guides! These step-by-step tutorials will help you integrate witness encryption into your projects.
What You'll Learn
These guides provide complete, practical examples of using zkenc in real-world applications:
📦 Node.js Integration
Learn how to build a complete Node.js application with witness encryption.
- Load and compile Circom circuits
- Encrypt and decrypt files
- Handle circuit inputs properly
- Error handling and best practices
⚛️ React Integration
Build an interactive React application with witness encryption.
- Set up Vite + React + TypeScript
- Handle circuit files in the browser
- Create encryption/decryption UI
- Optimize performance with Web Workers
🔄 Cross-Tool Workflows
Use zkenc-cli and zkenc-js together for maximum flexibility.
- Encrypt with CLI, decrypt with JavaScript
- Share ciphertexts across environments
- Combine tool strengths for your workflow
- Batch processing and automation
Prerequisites
Before starting these guides, you should:
-
Have basic knowledge of:
- JavaScript/TypeScript (for JS guides)
- Command line tools (for CLI guide)
- Circom circuits (basic understanding)
-
Install required tools:
# Node.js (18+)
node --version
# Circom
circom --version
# zkenc-cli (for cross-tool guide)
zkenc --help -
Have a circuit ready:
.circomsource file- Or pre-compiled
.r1csand.wasmfiles
Guide Structure
Each guide follows this structure:
- Setup - Project initialization and dependencies
- Circuit Preparation - Compile and load your circuit
- Implementation - Step-by-step code examples
- Testing - Verify everything works
- Optimization - Performance improvements
- Deployment - Production considerations
Example Circuits
The guides use these example circuits:
Simple Example Circuit
A basic circuit for learning:
pragma circom 2.0.0;
template Example() {
signal input publicValue;
signal input privateValue;
signal output result;
result <== publicValue + privateValue;
}
component main = Example();
Sudoku Circuit
A practical example used in the playground:
pragma circom 2.0.0;
template Sudoku() {
signal input puzzle[81]; // Public: the puzzle
signal input solution[81]; // Private: the solution
// Verify solution is valid
// ... constraints ...
}
component main = Sudoku();
Common Patterns
Encryption Pattern
// 1. Load circuit files
const circuitFiles = {
r1csBuffer: await loadFile('circuit.r1cs'),
wasmBuffer: await loadFile('circuit.wasm'),
};
// 2. Prepare public inputs
const publicInputs = { puzzle: [...] };
// 3. Encrypt
const { ciphertext } = await zkenc.encrypt(
circuitFiles,
publicInputs,
message
);
Decryption Pattern
// 1. Load ciphertext
const ciphertext = await loadFile('encrypted.bin');
// 2. Prepare full inputs (public + private)
const fullInputs = {
puzzle: [...],
solution: [...],
};
// 3. Decrypt
const decrypted = await zkenc.decrypt(
circuitFiles,
ciphertext,
fullInputs
);
Getting Help
If you get stuck:
-
Check the API Reference:
-
Try the Playground:
-
Review Example Code:
- Each guide includes complete, runnable examples
-
Open an Issue:
Choose Your Guide
For Node.js Developers
Perfect if you're building:
- CLI tools
- Backend services
- File encryption tools
- Batch processors
For React Developers
Perfect if you're building:
- Web applications
- Interactive UIs
- Browser-based tools
- Progressive Web Apps
For Automation
Perfect if you're:
- Using multiple tools
- Batch processing files
- Building pipelines
- Cross-platform workflows
What's Next
Ready to start? Pick a guide above, or:
- New to zkenc? Start with zkenc-js Getting Started
- Want to experiment? Try the Playground
- Need API details? Check the API Reference
Happy coding! 🚀