{"id":16194735,"url":"https://github.com/seiyakobayashi/zkml-optimization","last_synced_at":"2025-03-19T04:30:51.100Z","repository":{"id":65625170,"uuid":"561994652","full_name":"SeiyaKobayashi/zkml-optimization","owner":"SeiyaKobayashi","description":"Optimization for on-chain private machine learning.","archived":false,"fork":false,"pushed_at":"2023-10-26T05:05:51.000Z","size":2174,"stargazers_count":13,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-02-28T15:57:24.204Z","etag":null,"topics":["blockchain","ethereum","machine-learning","merkle-proof","merkle-tree","neural-network","optimization-algorithms","zk","zk-snarks","zkml","zkp"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeiyaKobayashi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-05T01:38:25.000Z","updated_at":"2024-02-07T21:13:28.000Z","dependencies_parsed_at":"2024-10-27T20:17:06.147Z","dependency_job_id":"a60b2973-e6ee-4db7-a31b-560572194ee7","html_url":"https://github.com/SeiyaKobayashi/zkml-optimization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeiyaKobayashi%2Fzkml-optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeiyaKobayashi%2Fzkml-optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeiyaKobayashi%2Fzkml-optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeiyaKobayashi%2Fzkml-optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeiyaKobayashi","download_url":"https://codeload.github.com/SeiyaKobayashi/zkml-optimization/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243971156,"owners_count":20376784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","machine-learning","merkle-proof","merkle-tree","neural-network","optimization-algorithms","zk","zk-snarks","zkml","zkp"],"created_at":"2024-10-10T08:24:44.662Z","updated_at":"2025-03-19T04:30:50.289Z","avatar_url":"https://github.com/SeiyaKobayashi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zkml-optimization\n\nOptimization of on-chain private machine learning (public model × private data).\n\n## Architecture Diagrams\n\n### Architecture Diagram of Verifier\n![Verifier](./docs/v1/arch-diagram-verifier.png \"verifier\")\n\n### Architecture Diagram of Prover\n![Prover](./docs/v1/arch-diagram-prover.png \"prover\")\n\n### Architecture Diagram of Model Developer\n![Model Developer](./docs/v1/arch-diagram-model-developer.png \"model developer\")\n\n## Prerequisites\n\nAll commands in this `README` (except this section) are assumed to be called from the root directory.\n\n```sh\n# cd into this repo\n$ cd zkml-optimization\n```\n\n## How to Use Demo CLI App\n\n### 0. Installation\n\nInstall all the dependencies using `yarn`.\n\n```sh\n$ yarn\n```\n\n### 1. Steps for Model Developers\n\n#### 1-A. Demo Model \u0026 Circuit\n\nWe have a demo ML model called `demo.h5` in `./models` directory. This is a classical classification model for MNIST dataset, and is a slightly modified version of [this model](https://github.com/socathie/keras2circom/blob/main/models/best_practice.h5). If needed, you can take a look at its implementation from `demo.ipynb` in `./models` directory.\n\nWe are using [keras2circom](https://github.com/socathie/keras2circom) as a way to convert model files (`.h5`) into circom-compatible circuits. Follow the steps in keras2circom's [README](https://github.com/socathie/keras2circom#keras2circom) to convert models into circuits. The demo circuit files auto-generated from the demo model are `demo-circuit.circom` and `demo-circuit-json` in `./circuits/` directory.\n\nWe need a ptau file for our trusted-setup. Clone `powersOfTau28_hez_final_17.ptau` from [this repo](https://github.com/iden3/snarkjs#7-prepare-phase-2), and place it in `./circuits` directory.\n\n#### 1-B. Circuit Compilation, ZKey Generation, IPFS, Model Registration\n\nGo to `./model-developers` directory, and follow the instructions in `README.md` for compiling demo circuit, generating zkeys from them, uploading files to IPFS, and registering the resulting hash to our custom verifier contract.\n\n### 2. Steps for Prover Clients\n\nGo to `./provers` directory, and follow the instructions in `README.md` for encoding testing results as a Merkle tree, generating Merkle proofs and ZKPs given the random challenge, and sending proofs to our custom verifier contract for revealing/verification.\n\n## Contributions\n\n### Adding Packages\n\nTo minimize side-effects of changes to packages, make sure to pin exact versions when adding packages.\n\n```sh\n# example: add package 'xxx' to root project as a dev dependency \n$ yarn add -W -D -E xxx\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseiyakobayashi%2Fzkml-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseiyakobayashi%2Fzkml-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseiyakobayashi%2Fzkml-optimization/lists"}