A privacy-preserving payroll distribution system powered by Stellar, Soroban, and Zero-Knowledge Proofs (Groth16). This system allows employers to deposit bulk sums of USDC and distribute them to employees without revealing individual salaries or linking withdrawals to the source deposit.
In a traditional transparent blockchain, payroll distributions reveal sensitive employee salary data. This project solves that by using Circom circuits to generate ZK-SNARKs that prove:
- Summation Integrity: The sum of all private salaries equals the public bulk deposit.
- Commitment Authenticity: Each salary is correctly hashed and included in a Merkle Tree root.
- Double-Spend Protection: Each "note" can only be withdrawn once via a cryptographic Nullifier.
-
payroll.circom: The "Employer" circuit. It proves that a list of private salaries${s_1, s_2, ..., s_n}$ sums up to a public$Total$ and generates a Merkle root of commitments. -
withdraw.circom: The "Employee" circuit. It proves that the user knows the preimage of a commitment in the tree and generates a uniquenullifierto claim their USDC.
- BN254 Optimization: Leveraging Stellar Protocol 25's native
pairing_checkhost functions for gas-efficient proof verification. - Nullifier Set: An on-chain registry that prevents any note from being double-claimed.
- Stellar Asset Integration: Fully compatible with USDC and other SEP-24/SAC tokens.
- CSV Processing: Automatically parses employee records.
- Poseidon Hashing: Generates ZK-friendly commitments.
- Proof Generation: Uses
SnarkJSto generate Groth16 proofs for the Stellar network.
- Circom 2.0
- Stellar CLI
- Node.js & TypeScript
git clone <this-repo>
cd stellar-privacy-payroll
npm install# Compile the summation circuit
circom circuits/payroll.circom --wasm --r1cs -o ./build
# Run trusted setup (Powers of Tau) - simplification
snarkjs groth16 setup build/payroll.r1cs ptau/powersOfTau28_hez_final_15.ptau payroll_final.zkey- Fill
client/salaries.csvwith 100 employee salaries. - Run
npx ts-node client/proof_gen.tsto generate the bulk deposit proof. - Submit the proof and the root to the Soroban contract via
deposit. - Employees can then use their individual secrets to
withdrawprivately.
- Anonymity Set: Withdrawals are 1-of-100 anonymous within the Merkle root.
- Resistance: Proofs are bound to the
recipientaddress to prevent front-running/hijacking. - Integrity: Mathematical constraints ensure the employer cannot deposit less than the promised salaries.
MIT