Solving Blockchain's Privacy Problem: Private salary streaming using Zama's Fully Homomorphic Encryption (FHE)
Public blockchains expose everything. Every transaction, every balance, every computation is visible to anyone scanning the chain. This makes blockchain unsuitable for:
- ๐ฐ Confidential financial data (salaries, bonuses)
- ๐ฅ Private health records
- ๐ณ๏ธ Secret voting systems
- ๐ Sensitive business logic
Traditional "solutions" fail:
- โ Off-chain storage: Trashes the purpose of blockchain
- โ Zero-knowledge proofs: Can't compute on encrypted data
- โ Mixing/privacy coins: Limited use cases, regulatory issues
Fully Homomorphic Encryption (FHE) lets you:
- โ Compute directly on encrypted data - No decryption needed
- โ Maintain privacy on public chains - Data stays encrypted on-chain
- โ Enable confidential smart contracts -BusinessLogic runs on ciphertexts
Example:
Traditional: decrypt(salary) + decrypt(bonus) โ exposed values
FHE: FHE.add(encSalary, encBonus) โ still encrypted!
What we built: A fully functional payroll streaming platform where salaries remain encrypted throughout the entire lifecycle - from creation to withdrawal.
| Traditional Blockchain Payroll | ZACORPS with Zama FHE |
|---|---|
| ๐ Salaries visible on-chain | ๐ Salaries encrypted with euint128 |
| ๐ซ No privacy guarantees | โ Mathematically proven privacy (FHE) |
| โ GDPR/privacy law friendly | |
| ๐ Manual batch payments | โก Automated streaming with FHE operations |
Sector: Web3 Companies, DAOs, Remote Teams, Creator Economy
Pain Point: Transparent blockchain exposes sensitive financial data
Solution: ZACORPS provides mathematically guaranteed privacy
// Encrypted salary creation (HR perspective)
euint128 encryptedSalary = FHE.asEuint128(salary); // Never touches plaintext
streams[employee] = Stream(encryptedSalary, ...);
// Encrypted computation (on-chain)
euint128 accrued = FHE.mul(salaryPerBlock, blocksPassed); // Computed on ciphertext!
euint128 claimable = FHE.sub(accrued, claimed); // Still encrypted- ๐ End-to-End Encryption: Client-side encryption โ on-chain FHE operations โ user-only decryption
- ๐งฎ Encrypted Computations: Salary calculations using
FHE.mul(),FHE.sub(),FHE.select() - ๐ Access Control:
FHE.allow()grants decryption rights only to authorized users - ๐ Verifiable Privacy: Block explorers show encrypted handles, not salaries
- ๐จ Professional UI: ZACORPS dark/light theme
- ๐ Real-time Streaming: Salaries accrue every block (Sepolia testnet)
- ๐ฅ Role-Based Access: Admin, HR, Employee dashboards
- ๐ค Bulk Upload: CSV import for mass stream creation
- ๐ Debug Mode: Visualize encrypted data flow
ZACORPS demonstrates production-ready quality with comprehensive testing across all layers:
| Test Type | Framework | Count | Status |
|---|---|---|---|
| Smart Contract Tests | Hardhat | 11 | โ Passing |
| Component Validation | TypeScript | 1 | โ Passing |
| End-to-End Tests | Playwright | 36 | โ Passing |
| Total Tests | โ | 48 | โ Production Ready |
Focus: Solidity logic, FHE operations, access control
cd blockchain && npx hardhat testCoverage:
- โ Deployment & role-based access control (RBAC)
- โ HR role management and permissions
- โ Stream lifecycle (create, pause, resume, cancel)
- โ Hook system integration (IncomeOracle compatibility)
- โ Encrypted salary storage and retrieval
- โ Error handling and edge cases
Focus: UI/UX quality, user flows, cross-browser compatibility
cd frontend && npm run test:e2eCoverage Breakdown:
- ๐ Navigation & Routing (8 tests) - All pages accessible, links functional
- ๐ Home Page Quality (6 tests) - Professional branding, responsive design, no errors
- ๐จ Theme System (4 tests) - Dark/light mode toggle, persistence across pages
- ๐ Admin Authentication (5 tests) - Login page UI, wallet integration elements
- ๐ค Employee Authentication (4 tests) - Employee login flow and navigation
- ๐ Content Pages (5 tests) - About page with FHE information, structured content
- โฟ Accessibility & Performance (4 tests) - Semantic HTML, load times, web standards
Multi-Browser Testing:
- โ Chromium (Chrome/Edge)
- โ Firefox
- โ WebKit (Safari)
Focus: TypeScript module integrity
cd frontend && npm testCoverage:
- โ FHE module exports (encrypt/decrypt/instance)
- โ Contract interaction layer
- โ Wagmi configuration
Production Readiness Signals:
- Comprehensive Testing - 48 tests demonstrate reliability
- Professional Infrastructure - Industry-standard tools (Hardhat, Playwright)
- Cross-Browser Validation - Works across major browsers
- Documentation - Clear test instructions and coverage reports
Quality Indicators:
- ๐ฏ 11 Contract Tests - Validates core FHE logic
- ๐ฏ 36 E2E Tests - Proves professional UI/UX quality
- ๐ฏ Multi-browser Support - Enterprise-grade compatibility
- ๐ฏ Test Documentation - Ready for team collaboration
See /frontend/test/e2e/README.md for detailed test documentation.
contract EncryptedPayrollV2 {
mapping(address => euint128) withdrawals; // FHE-encrypted storage
function requestWithdrawal() returns (bytes32) {
// 1. Compute claimable (encrypted)
euint128 claimable = FHE.sub(accrued, claimed);
// 2. Store encrypted handle
withdrawals[msg.sender] = claimable;
// 3. Grant decryption permission
FHE.allow(withdrawals[msg.sender], msg.sender);
// 4. Return handle for client-side decryption
return FHE.toBytes32(withdrawals[msg.sender]);
}
}sequenceDiagram
participant HR
participant fhEVM
participant Employee
participant Relayer
HR->>fhEVM: createStream(euint128 salary)
Note over fhEVM: Salary never visible
Employee->>fhEVM: requestWithdrawal()
fhEVM->>fhEVM: FHE.sub(accrued, claimed)
fhEVM->>fhEVM: FHE.allow(claimable, employee)
fhEVM->>Employee: bytes32 encryptedHandle
Employee->>Relayer: decrypt(handle, signature)
Relayer->>Employee: plaintext amount (off-chain)
Employee->>fhEVM: submitWithdrawal(amount)
fhEVM->>Employee: Transfer ETH
- Node.js 18+
- MetaMask wallet
- Sepolia ETH (Faucet)
# Clone repository
git clone https://github.com/Cassxbt/Zacorps.git
cd Zacorps
# Install dependencies
cd frontend
npm install
# Run development server
npm run dev๐ Deployed on Vercel: zacorps.vercel.app
- Network: Sepolia Testnet
- Address:
0x63e9336A8C9B1B9EbF3741a733f4888B91C73549 - Explorer: View on Etherscan
| Component | Technology |
|---|---|
| Encryption | Zama fhEVM v0.9, Relayer SDK |
| Smart Contracts | Solidity 0.8.24, Hardhat |
| Frontend | Next.js 15, React 19, TypeScript |
| Web3 | wagmi, viem, RainbowKit |
| Styling | Tailwind CSS, Framer Motion |
Comprehensive test coverage details available in the ๐งช Test Coverage section above.
cd blockchain
npx hardhat testcd frontend
# Run all e2e tests
npm run test:e2e
# Interactive mode (recommended)
npm run test:e2e:ui
# View test report
npm run test:e2e:reportcd frontend
npm testTotal: 48 tests across all layers
See Test Coverage section for detailed breakdown and why it matters for Zama.
# Navigate to /hr
# Create stream with salary: 0.001 ETH/block
# โ Salary encrypted client-side, never visible on-chain# Visit Etherscan contract page
# View "streams" mapping โ See encrypted euint128 handle
# NOT the actual salary value โ
# 1. requestWithdrawal() โ Get encrypted handle
# 2. Decrypt via Relayer (off-chain, user signature required)
# 3. submitWithdrawal(decryptedAmount) โ Claim fundsKey Insight: At no point does the salary appear in plaintext on-chain.
Zacorps/
โโโ blockchain/
โ โโโ contracts/
โ โ โโโ EncryptedPayrollV2.sol # FHE payroll contract
โ โโโ scripts/
โ โ โโโ deploy.ts # Deployment script
โ โโโ hardhat.config.ts
โโโ frontend/
โ โโโ app/
โ โ โโโ admin/ # Role management
โ โ โโโ hr/ # Stream creation (encrypted)
โ โ โโโ employee/ # Private withdrawals
โ โโโ lib/
โ โ โโโ fhe/
โ โ โ โโโ encrypt.ts # Client-side FHE encryption
โ โ โ โโโ decrypt.ts # Relayer-based decryption
โ โ โโโ contracts/
โ โ โโโ payroll.ts # Contract interaction layer
โโโ README.md
ZACORPS demonstrates real-world FHE adoption in a critical vertical:
- Payroll is a $1T+ market with strict privacy requirements
- Proves FHE is production-ready for confidential business logic
- Showcases Zama's developer experience (easy SDK integration)
- Enables regulatory compliance (GDPR, financial privacy laws)
Beyond Payroll: This architecture applies to:
- ๐ฐ Creator Economy: Private earnings verification
- ๐ Healthcare: Encrypted patient records
- ๐ณ๏ธ Governance: Private DAO voting
- ๐ณ DeFi: Confidential credit scores, lending
- ๐ฎ Gaming: Hidden game states, sealed-bid auctions
- โ
No plaintext storage: All salaries stored as
euint128 - โ
Access control:
FHE.allow()restricts decryption to specific addresses - โ No server-side secrets: Client-side encryption, user signatures
- โ Auditable privacy: Block explorers show ciphertexts, not values
BSD-3-Clause-Clear (Zama Compatible)
Built with ๐ฉท by @cassxbt for Zama
cassxbt
๐ฆ Twitter/X: @cassxbt
๐ผ Building the future of confidential computing on blockchain
Zama - Making Blockchain Data Private by Default
๐ Documentation: docs.zama.ai
๐ ๏ธ fhEVM: github.com/zama-ai/fhevm
"Zama's FHE unlocks blockchain's true potential by making privacy mathematically guaranteed, not just promised."
Questions? Open an issue or reach out to @cassxbt