ZK circuit: Written inNoirpowered by Aztec)- Smart Contract: Written in Solidity (Framework: Foundry)
- Blockchain:
Sonic(Testnet)
-
This is the ZK Mortgage Agreement Manager, which is the Zero-Knowledge based mortgage loan agreement management system that consists of the ZK circuits and the smart contracts.
-
In the real estate space, when a borrower would borrow a mortgage loan to buy a house via a real estate agency, the following scenario will be proceeded:
- 1/ A borrower will submit some financial documents (i.e.
Employment verification letter) to a real estate agency for showing their finantial profile (i.eincome,tax returns, etc). - 2/ Also, the real estate company would ask a credit score provider (i.e.
FICO) the borrower'scredit scoreand retrieve it as the borrower's finantial profile. - 3/ The real estate company would send these finantial profile (i.e.
income,credit score) to a lender (i.e. Bank, Morgage Loan company, etc) as a morgage loan request. - 4/ Once the borrower's morgage loan request would be approved by the lender, the mortgage agreement would be created through the real estate agency (or the lender).
- 1/ A borrower will submit some financial documents (i.e.
-
The problem of the general mortgage loan process via a real estate agency above is that the real estate agency (and the lender) can see all of the borrower's informations, which includes the sensitive informations or/and unnecessity informations.
- This project (
ZK Mortgage Agreement Manager) can resolve these problem by the combination of the ZK circuits and the smart contracts as a privacy-preserving way. - By using this project (
ZK Mortgage Agreement Manager), a borrower can submit a mortgate loan request to a lender via a real estate agency without revealing their sensitive informations or/and unnecessity informations.
- This project (
Deployed-smart contracts on Sonic Testnet
| Contract Name | Descripttion | Deployed-contract addresses on Sonic Testnet |
|---|---|---|
| UltraVerifier (for the EmploymentVerificationLetterProof) | The UltraPlonk Verifer contract for the EmploymentVerificationLetterProof (./employer/contracts/circuit/plonk_vk.sol), which is generated based on ZK circuit in Noir (./circuits/src/main.nr). FYI: To generated this contract, the way of the Noir's Solidity Verifier generation was used. |
0x621dbc8010E0d5Aa2b11a5103c9833eC94a70E39 |
| EmploymentVerificationLetterProofVerifier | The smart contract that enable to validate whether or not a EmploymentVerificationLetterProof-submitted is valid. | 0xEd1324385Fe64c83687C3f9576F3210c6B8E309E |
| UltraVerifier (for the FICOCreditScoreProof) | The UltraPlonk Verifer contract for the EmploymentVerificationLetterProof (./FICO/contracts/circuit/plonk_vk.sol), which is generated based on ZK circuit in Noir (./circuits/src/main.nr). FYI: To generated this contract, the way of the Noir's Solidity Verifier generation was used. |
0xEa8EB5CFf49241B39950c31f788AEF8E0d4Df1c1 |
| FICOCreditScoreProofVerifier | The smart contract that enable to validate whether or not a EmploymentVerificationLetterProof-submitted is valid. | 0x20a414abEcFe31DD27Aa7FcCC353a505E976D277 |
| UltraVerifier (for the MortgageAffordabilityProof) | The UltraPlonk Verifer contract for the EmploymentVerificationLetterProof (./borrower/contracts/circuit/plonk_vk.sol), which is generated based on ZK circuit in Noir (./circuits/src/main.nr). FYI: To generated this contract, the way of the Noir's Solidity Verifier generation was used. |
0x2317106a73E00fc66AB25aD50979CFf140075b2b |
| MortgageAffordabilityProofVerifier | The smart contract that enable to validate whether or not a MortgageAffordabilityProof-submitted is valid. | 0x7a2E68d1d1bB79dBc945801A02Bd6e17d0842457 |
| MortgageAgreementManager | The smart contract that enable a borrower to create a request of the mortgage agreement /w three ZK proofs (EmploymentVerificationLetterProof, FICOCreditScoreProof, MortgageAffordabilityProof) and enable a lender to accept these request |
0x0A95E7Fc5c292eCe47893E63A1380f08a061814A |
- Install libraries (NOTE: Before this installation, all folders should be removed under the ./lib directory)
forge install OpenZeppelin/openzeppelin-contracts
forge install 0xnonso/foundry-noir-helperThere are three ZK circuits in total. For three ZK circuits in the three directory (./employer/circuits, ./FICO/circuits, ./borrower/circuits) respectively, the following installation should be done:
- 1/ Move to the
./circuitsdirectory:
cd circuits- 2/ Create the
Prover.tomlfile by coping the example file (Prover.example.toml) in the./circuitsdirectory.
cp Prover.example.toml Prover.toml-
3/ Write the
input datashould be written in theProver.toml. -
4/ Run the
build.shto run ZK circuit
sh build.sh- 5/ The UltraVerifier contract (
contract.sol) andproofandvkin Noir would be generated under the./circuits/target.- The UltraVerifier contract (
contract.sol) is automatically copied to the/contracts/circuitas theplonk_vk.sol
- The UltraVerifier contract (
- Run the
circuit_test.shto test the ZK circuit in the./employer/circuits.
cd employer/circuits
sh circuit_test.sh- Run the
circuit_test.shto test the ZK circuit in the./FICO/circuits.
cd FICO/circuits
sh circuit_test.sh- Run the
circuit_test.shto test the ZK circuit in the./borrower/circuits.
cd borrower/circuits
sh circuit_test.shThere are three components of the smart contracts in total. For three type of the smart contracts in the three directory (./employer/contracts, ./FICO/contracts, ./borrower/contracts) respectively, the following installation should be done:
- Compile the smart contracts
cd employer or FICO or borrower
sh ./buildContract.shThere are three components of the smart contract tests in total. For three components of the smart contracts in the three directory (./employer/test, ./FICO/test, ./borrower/test) respectively, the following installation should be done:
- Run the test of the
EmploymentVerificationLetterProofVerifier.t.sol, which is the test file of theEmploymentVerificationLetterProofVerifier.solon Local Network.
cd employer
sh ./test/runningTest_EmploymentVerificationLetterProofVerifier.sh- Run the test of the
EmploymentVerificationLetterProofVerifierOnSonicTestnet.t.sol, which is the test file of theEmploymentVerificationLetterProofVerifier.solon Sonic Testnet.
cd employer
sh ./test/sonic-testnet/runningTest_EmploymentVerificationLetterProofVerifierOnSonicTestnet.sh- Run the test of the
FICOCreditScoreProofVerifier.t.sol, which is the test file of theEFICOCreditScoreProofVerifier.solon Local Network.
cd FICO
sh ./test/runningTest_FICOCreditScoreProofVerifier.sh- Run the test of the
FICOCreditScoreProofVerifierOnSonicTestnet.t.sol, which is the test file of theFICOCreditScoreProofVerifier.solon Sonic Testnet.
cd FICO
sh ./test/sonic-testnet/runningTest_EmploymentVerificationLetterProofVerifierOnSonicTestnet.sh- Run the test of the
MortgageAffordabilityProofVerifier.t.sol, which is the test file of theMortgageAffordabilityProofVerifier.solon Local Network.
cd borrower
sh ./test/runningTest_MortgageAffordabilityProofVerifier.sh- Run the test of the
MortgageAffordabilityProofVerifierOnSonicTestnet.t.sol, which is the test file of theMortgageAffordabilityProofVerifier.solon Sonic Testnet.
cd borrower
sh ./test/sonic-testnet/runningTest_MortgageAffordabilityProofVerifierOnSonicTestnet.sh- Run the test of the
MortgageAgreementManagerOnSonicTestnet.t.sol, which is the test file of theMortgageAgreementManager.solon Sonic Testnet.
(NOTE: This test is still in progress)
cd borrower
sh ./test/sonic-testnet/runningTest_MortgageAgreementManagerOnSonicTestnet.sh- Run the script of the
EmploymentVerificationLetterProofVerifier.s.sol, which is the test file of theEmploymentVerificationLetterProofVerifier.solon Sonic Testnet.
cd employer
sh ./script/sonic-testnet/runningScript_EmploymentVerificationLetterProofVerifier.sh- Run the script of the
FICOCreditScoreProofVerifier.s.sol, which is the test file of theUltraVerifier.solon Sonic Testnet.
cd FICO
sh ./script/sonic-testnet/runningScript_FICOCreditScoreProofVerifier.sh- Run the script of the
MortgageAffordabilityProofVerifier.s.sol, which is the test file of theUltraVerifier.solon Sonic Testnet.
cd borrower
sh ./script/sonic-testnet/runningScript_MortgageAffordabilityProofVerifier.sh-
NOTE: Each Smart Contract has been deployed on
Sonic Testnet. See the"Deployed-smart contracts onSonic Testnet"paragraph above in this README. -
1/ Create the
.envfile by coping the example file (.env.example) in the root directory.- Then, you should add a private key of your deployer address to the
SONIC_BLAZE_TESTNET_PRIVATE_KEY/or theELECTRONEUM_TESTNET_PRIVATE_KEY.
- Then, you should add a private key of your deployer address to the
cd employer or FICO or borrower
cp .env.example .env- 2/ Deploy all contracts on Sonic Testnet by running the
script/DeploymentAllContracts.s.sol
cd employer
sh ./script/sonic-testnet/deployment/deployment-on-sonic-testnet.sh
cd FICO
sh ./script/sonic-testnet/deployment/deployment-on-sonic-testnet.sh
cd borrower
sh ./script/sonic-testnet/deployment/deploymentScript_MortgageAffordabilityProofVerifier.sh
sh ./script/sonic-testnet/deployment/deploymentScript_MortgageAgreementManager.sh-
Noir:
- Doc: https://noir-lang.org/docs/getting_started/quick_start
noir-starter(for Foundry): https://github.com/AztecProtocol/noir-starter/tree/main/with-foundry
-
Sonic:
- Block Explorer (on Sonic Testnet): https://testnet.sonicscan.org/
- Doc (icl. RPC, etc): https://docs.soniclabs.com/sonic/build-on-sonic/getting-started
- Fancet: https://testnet.soniclabs.com/account