🎉ETHGlobal SF Hackathon 3X prize winner 🎉
https://github.com/dappbeast/daoism
With on-chain ZK-SNARK verifiers, it's possible to make provable claims about employee salaries without revealing their salaries to the public. This has a couple very interesting usecases:
- Negotiations and competitiveness: provably share the average salary per contributor role without sharing individual salaries
- Equity: share salary ranges based on demographics and roles, thus proving equal pay without revealing sensitive details
- Undercollateralized loans: submit salary proofs to decentralized lending protocols like Aave to get more attractive loans due to better credit worthiness
- Sybil resistance: use these contracts to prove humanity
- allows creation / cancellation of employment contracts on-chain
- the salary information is hashed with sha256(secret, salary)
- a
submitAverageSalaryProof()
routes to theZKAverage
andZKHash
on-chain verifiers which verify that a certain role does in fact match the claimed average
- Generated via Circom 2.1.1 and snarkjs.
Flow:
- Employer generates a ZKAverage witness off-chain via dApp using (a) unhashed salaries (b) claimed averages per role
- Employer generates aa ZKHash witness off-chain via dApp using (a) unhashed salaries (b) hashed salaries (c) secret
- The public inputs (unhashed salaries, claimed averages) + proofs are submitted to
WorkAgreement.submitAverageSalaryProof()
- Within the function,
WorkAgremeent.sol
first routes toZKAverage.sol
to verify the average calculation - Then,
WorkAgreement.sol
takes in all the hashed salaries from the contract state and routes those toZKHash.sol
to ensure that the supplied salaries match the ones on-chain
forge test
- deploy WorkAgreement.sol:
source.env; forge script Deploy --rpc-url $OP_GOERLI_RPC_URL --broadcast --verify
- seed WorkAgreement.sol:
forge script Seed --rpc-url $OP_GOERLI_RPC_URL --broadcast
- deploy ZK verifiers:
forge DeployZKVerifier --rpc-url $OP_GOERLI_RPC_URL --broadcast --verify
- submit proof:
forge Prove --rpc-url $OP_GOERLI_RPC_URL --broadcast
- Ideally, the ZKHash and ZKAverage circuits would live in a single circuit, thus ensuring that the salaries of current employees (no more and no less) were used in the average calculation. Unfortunately, due to the gigantic size of the circuit, it was infeasible to generate a single proof during the timespan of the hackathon (single laptop)
- Circomlib's SHA256 has very sparse documentation and we had significant issues making solidity's sha256() match the inputs and outputs of Circoms template