docs: add ZK Loan DApp tutorial (Parts 1-3)#756
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary
Errors per inputErrors in docs/tutorials/zk-loan/attestation-api.mdx
Errors in docs/tutorials/zk-loan/cli.mdx
Errors in docs/tutorials/zk-loan/smart-contract.mdx
|
Add the first part of the ZK Loan DApp tutorial covering the smart contract, Schnorr signature module, witness implementation, and compilation steps. Update the advanced placeholder to link to the new tutorial location.
3a231fe to
e876738
Compare
Add the second part of the ZK Loan DApp tutorial covering the attestation API, Schnorr signing implementation, REST server, attestation flow walkthrough, and Docker proof server setup.
Add the final part of the ZK Loan DApp tutorial covering the CLI implementation, wallet management, smart contract deployment, and end-to-end testing walkthrough with Midnight Local Dev.
Link Part 1/2/3 references to their respective pages and replace the external installation docs link with an internal one.
Link to concepts (zero-knowledge proofs, ledgers, data protection, explicit disclosure), Compact language reference, Standard Library, proof server guide, Midnight Local Dev guide, and release notes.
🚀 Preview Deployment✅ Deployment Ready 🔗 Preview URL: https://pr-756-midnight-docs.vercel.app 📝 Latest commit: This preview updates automatically when you push new commits to this PR. |
|
@gyrationtechs - Please review. LMK if I need to take a look. |
gyrationtechs
left a comment
There was a problem hiding this comment.
Hi @Olanetsoft, very detailed and 'long' tutorial. I have a couple of comments and suggestions for improvement.
Please take a look and let me know if you have any questions or concerns🙂
- Use active voice for headings (Write/Create/Compile instead of Writing/Creating/Compiling) - Change Compact code blocks from typescript to compact syntax highlighting - Replace bold with italics for emphasis throughout - Convert sequential ordered lists to unordered lists, remove blank lines between items - Move explanations after code snippets for better readability - Wrap evaluateApplicant note in :::important admonition - Update compactc references to Compact toolchain / compact compile - Update proof server image to midnightntwrk/proof-server:8.0.0 and remove --network testnet flag - Add explanatory comments for JUBJUB_ORDER and TWO_248 constants - Split large cli.ts code block into smaller annotated sections - Rename final heading to "Next steps" for consistency - Rewrite passive intro paragraphs to active voice
- Remove "What you built in Part 2" summary section (redundant with intro) - Rename "Coming up in Part 3" to "Next steps" with rewritten intro - Convert prerequisites to heading with bullet list - Rename "Building the CLI" to "Build the CLI" - Replace compactc reference with "Compact compiler" - Use tNIGHT/tDUST for testnet token names - Add context paragraphs before code sections that lacked them
|
|
||
| 2. **Proof server**: A Docker container running Midnight's proof generation service locally. Every transaction that touches the smart contract requires a zero-knowledge proof, and this service produces them. | ||
|
|
||
| You also walk through the **attestation flow** end-to-end — how credit data moves from the attestation API into the zero-knowledge proof without ever appearing on-chain. |
There was a problem hiding this comment.
Suggestion for improvement:
This section walks through the attestation flow end-to-end, showing how credit data flows from the attestation API to the zero-knowledge proof without ever appearing on-chain.
gyrationtechs
left a comment
There was a problem hiding this comment.
Hey @Olanetsoft, thanks for making the changes. Looking good. Minor edits then g2g.
| 3. *CLI*: A command-line tool to deploy the smart contract, register the attestation provider, request loans, and interact with the system — all pointing at Midnight's local network. | ||
|
|
||
| ## Project setup | ||
|
|
There was a problem hiding this comment.
We should avoid stacking headings together. A brief context paragraph would be handy!
|
|
||
| The next part builds the off-chain infrastructure that makes the smart contract functional: | ||
|
|
||
| * *[Attestation API](./attestation-api)*: A REST server that signs credit data with Schnorr signatures, acting as the trusted data provider that the smart contract verifies against. |
There was a problem hiding this comment.
I think this is supposed to be bolded. Single asterisk (*) applies italics. A few sections are impacted by this. Review and update each to use bolded text.
There was a problem hiding this comment.
Actually, I wouldn't format the link text at all. The non-link text before the colon certainly should be bold.
|
|
||
| [Midnight Network](/concepts/network-architecture/onchain-logic) makes this practical. It is a blockchain purpose-built for [data protection](/concepts/how-midnight-works/keeping-data-private), where smart contracts can process private inputs and commit only the results on-chain. The sensitive data never leaves the user's machine. | ||
|
|
||
| In this tutorial, you build a zero-knowledge loan application from scratch on Midnight Network. The app privately evaluates a user's credit data (credit score, income, and employment tenure) using zero-knowledge proofs and records only the loan outcome on-chain. The sensitive financial data never leaves your machine. |
There was a problem hiding this comment.
Let's rewrite this section to use an active voice. Here is a suggestion. Feel free to reword and use as you see fit.
This tutorial builds a ...
|
|
||
| In this tutorial, you build a zero-knowledge loan application from scratch on Midnight Network. The app privately evaluates a user's credit data (credit score, income, and employment tenure) using zero-knowledge proofs and records only the loan outcome on-chain. The sensitive financial data never leaves your machine. | ||
|
|
||
| You build three things: |
There was a problem hiding this comment.
Maybe it's just me. But this reads somehow. Here's another version:
The tutorial is split into three parts:
|
@DianaHackmamba, please review when you have a moment. |
|
|
||
| But right now, that smart contract has no way to receive signed credit data or generate zero-knowledge proofs. This part builds the two pieces of off-chain infrastructure that make the smart contract functional: | ||
|
|
||
| 1. **Attestation API**: A REST server that signs credit data with Schnorr signatures on the Jubjub curve. It acts as the trusted data provider (a stand-in for a bank or credit bureau) whose signatures the smart contract verifies inside the zero-knowledge circuit. |
There was a problem hiding this comment.
Why is this list numbered?
|
|
||
| 2. **Proof server**: A Docker container running Midnight's proof generation service locally. Every transaction that touches the smart contract requires a zero-knowledge proof, and this service produces them. | ||
|
|
||
| You also walk through the **attestation flow** end-to-end — how credit data moves from the attestation API into the zero-knowledge proof without ever appearing on-chain. |
|
|
||
| #### How the signing works | ||
|
|
||
| The signing uses the **Jubjub elliptic curve** (Midnight's native internal curve). Here is the Schnorr signing flow, step by step: |
There was a problem hiding this comment.
Why is this text bold? I do not see a reason it should be.
|
|
||
| The signing uses the **Jubjub elliptic curve** (Midnight's native internal curve). Here is the Schnorr signing flow, step by step: | ||
|
|
||
| 1. Generate a random nonce `k` |
There was a problem hiding this comment.
This list is sentences. Add periods.
| | Rejected | < 580 | any | any | $0 | | ||
|
|
||
| `createLoan` handles the status logic. Three outcomes are possible: | ||
| - *Approved*: The user asked for less than or equal to their max eligible amount. They get exactly what they asked for. |
There was a problem hiding this comment.
The text before the colon should be bold, not italic.
|
|
||
| `changePin` is the most complex circuit. When a user changes their PIN, they get a new on-chain identity. But their existing loans are tied to the old identity. All loans need to migrate from the old public key to the new one. | ||
|
|
||
| The catch: *zero-knowledge circuits cannot loop over variable-length data*. If a user has 12 loans, you cannot write `for i in 0..loans.size()`. The loop bound must be known at compile time. The solution is *batched migration*: |
There was a problem hiding this comment.
Beware of overusing italics. If you use it too much, then it becomes meaningless.
|
|
||
| | **Data** | **Visibility** | **Why** | | ||
| | --- | --- | --- | | ||
| | Credit score, income, and tenure | *Private* (witness only) | Never leaves the user's machine | |
There was a problem hiding this comment.
Remove italics in this table. Overused.
|
|
||
| This part covered the foundation of the zero-knowledge loan application: | ||
|
|
||
| * *Schnorr signature module*: A Compact module that verifies cryptographic signatures inside a zero-knowledge circuit, ensuring credit data comes from a trusted source. |
There was a problem hiding this comment.
Text before colon should be bold, not italic.
|
|
||
| The next part builds the off-chain infrastructure that makes the smart contract functional: | ||
|
|
||
| * *[Attestation API](./attestation-api)*: A REST server that signs credit data with Schnorr signatures, acting as the trusted data provider that the smart contract verifies against. |
There was a problem hiding this comment.
Actually, I wouldn't format the link text at all. The non-link text before the colon certainly should be bold.
Co-authored-by: David Ozokoye <david.ozokoye@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: David Ozokoye <david.ozokoye@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: David Ozokoye <david.ozokoye@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: DianaHackmamba <diana@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: DianaHackmamba <diana@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: DianaHackmamba <diana@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: DianaHackmamba <diana@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Co-authored-by: DianaHackmamba <diana@hackmamba.io> Signed-off-by: Idris Olubisi <heedris2olubisi@gmail.com>
Summary
docs/tutorials/zk-loan/zk-loan/tutorial folder with_category_.yamlfollowing the existing counter/bboard pattern_advanced/zk-loan-dapp.mdxplaceholder to link to the new tutorialTest plan