Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xZKML/zk-mnist
Demo of ML for MNIST classification in a zero knowledge proof
https://github.com/0xZKML/zk-mnist
Last synced: 2 months ago
JSON representation
Demo of ML for MNIST classification in a zero knowledge proof
- Host: GitHub
- URL: https://github.com/0xZKML/zk-mnist
- Owner: 0xZKML
- Created: 2022-03-05T00:14:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T07:43:55.000Z (over 1 year ago)
- Last Synced: 2024-01-28T16:07:30.210Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 50.1 MB
- Stars: 105
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Lists
- awesome-zk - zk-MNIST: web frontend app + Jupyter notebook with ML model generation
- awesome-zkml - zk-mnist - [@hopanml](https://twitter.com/hopanml) [@sunfishstanford](https://twitter.com/fho888) [@henripal](https://twitter.com/henripal) (2022) (Codebases / Articles and podcasts)
- awesome-zkml - zk-mnist - [@hopanml](https://twitter.com/hopanml) [@sunfishstanford](https://twitter.com/fho888) [@henripal](https://twitter.com/henripal) (2022) (Codebases / Articles and podcasts)
- awesome-zero-knowledge-proofs - zk-MNIST: web frontend app + Jupyter notebook with ML model generation on Ethereum
README
# About
zk-MNIST: web frontend app + Jupyter notebook with ML model generation
Authors: @horacepan @sunfishstanford @henripalYou can play with the webapp demo at: https://zkmnist.netlify.app/
(Note: mobile browsers not supported; wallet connected to Goerli testnet required to demonstrate ZK verifier.)
Tutorial blog post: https://hackmd.io/Y7Y79_MtSoKdHNAEfZRXUgThis project is part of [0xPARC](https://0xparc.org/blog/program-for-applied-research)'s winter 2021 applied zk learning group, and draws heavily from 0xJOF's [zk learning in public](https://github.com/JofArnold/zkp-learning-in-public) repo and Wei Jie Koh's [zk nft mint repo](https://github.com/weijiekoh/zknftmint/blob/main/contracts/contracts/NftMint.sol)
## Current Functionality:
1) draw a digit or select an image of a hand-drawn digit
2) pass the digit through 2 conv layers and 2 FC layers in browser, generating a dim 84 embedding
3) generate a zkSNARK proof in browser that the embedding represents a given digit
4) verify proof on-chain using ethers + snarkjs## How to run it locally:
Prerequisites: global install of circom 2.0
1) `git clone` the repo
2) `cd` into the directory
3) `npm i` to install dependencies
4) generate powers of tau `yarn zk:ptau`
5) compile circuits: (_yarn zk:compile_ doesn't work)
5a) `cd zk`
5b) `zsh compile.sh`
5c) `cd ..` (back to main directory)
5d) copy over some of the wasm files
`mkdir public/static`
`mkdir public/static/js`
`cp node_modules/onnxruntime-web/dist/*.wasm public/static/js/`
6) compile the contracts `npx hardhat compile`
7) start a local ether node: `npx hardhat node`
8) switch to another terminal
9) deploy the smart contract ` npx hardhat run scripts/deploy.js --network localhost`
10) make a note of where the contract address has been deployed
11) edit `verifierAddress` in `./src/config.js`
12) start web app `npm start`## Development loop:
### ZK circuits
All zk circuits are in the `zk` directory.
1) generate basic powers of tau phase 1 with `yarn zk:ptau`
2) compile the circuits, generate the solidty validator with `yarn zk:compile` (but see 5a/5b above)