├── .gitignore ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── packages ├── app │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .prettierignore │ ├── .prettierrc.json │ ├── README.md │ ├── next.config.js │ ├── package.json │ ├── pages │ │ ├── _app.tsx │ │ ├── _document.tsx │ │ ├── api │ │ │ └── hello.ts │ │ └── index.tsx │ ├── public │ │ ├── favicon.ico │ │ ├── next.svg │ │ ├── snarkjs.min.js │ │ ├── sudoku.wasm │ │ ├── sudoku_1.zkey │ │ ├── sudoku_verify_key.json │ │ ├── thirteen.svg │ │ └── vercel.svg │ ├── src │ │ ├── Constants.tsx │ │ ├── components │ │ │ ├── KeyboardView.tsx │ │ │ ├── PlayPannel.tsx │ │ │ ├── ProofView.tsx │ │ │ ├── PuzzleView.tsx │ │ │ └── VerifyPannel.tsx │ │ ├── images │ │ │ └── sudoku.png │ │ ├── layout │ │ │ └── AppLayout.tsx │ │ └── utils │ │ │ └── GameUtils.ts │ ├── styles │ │ ├── Home.module.css │ │ └── globals.css │ └── tsconfig.json └── circuit │ ├── circuits │ ├── circomlib │ │ ├── aliascheck.circom │ │ ├── binsum.circom │ │ ├── bitify.circom │ │ ├── comparators.circom │ │ ├── compconstant.circom │ │ └── gates.circom │ ├── sudoku.circom │ └── utils.circom │ ├── index.js │ ├── package.json │ └── test │ ├── circuits │ ├── get_number_group_for_box.circom │ ├── get_number_group_for_column.circom │ ├── get_number_group_for_row.circom │ ├── is_number_in_range.circom │ ├── is_valid_puzzle.circom │ ├── is_valid_puzzle_number_group.circom │ ├── is_valid_solution.circom │ ├── is_valid_solution_number_group.circom │ └── is_valid_solution_of_puzzle.circom │ ├── sudoku_test.js │ ├── test_data.js │ └── utils_test.js ├── screen-capture.gif ├── screen-capture.mp4 ├── screen-capture.webm └── screenshot.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | **/node_modules 3 | 4 | # dependencies 5 | /node_modules 6 | 7 | # testing 8 | coverage 9 | 10 | # production 11 | build 12 | # yarn / eslint 13 | .yarn/cache 14 | .yarn/install-state.gz 15 | .yarn/build-state.yml 16 | .eslintcache 17 | # testing 18 | coverage 19 | 20 | # production 21 | build 22 | 23 | # misc 24 | .DS_Store 25 | .env* 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | 32 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![🏆](https://github.com/web3-master/zksnark-sudoku/blob/master/screen-capture.gif?raw=true) 2 | 3 | # 🏆🏆🏆 zkSNARK Sudoku 🏆🏆🏆 4 | 5 | Sudoku verifier using zkSNARK. 6 | 7 | ## 📺 LIVE ON 8 | 9 | https://zksnark-sudoku.surge.sh/ 10 | 11 | ## 📜 zksnark 12 | 13 | ### ⚔️ Used technologies 14 | 15 | > Groth16: zksnark implementation scheme. 16 | 17 | > Circom: zksnark circuit compilation toolkit. 18 | 19 | > snarkjs: zksnark library. 20 | 21 | ### 📝 Description 22 | 23 | ## 📺 Application 24 | 25 | ### ⚔️ Used technologies 26 | 27 | > antd: Excellent UI template library for react.js. 28 | 29 | > React.js: For our front end building. 30 | 31 | ### 📝 Description 32 | 33 | This is react.js based web application for sudoku game play and verify. 34 | Now it has the following features. 35 | 36 | 1. Game play. 37 | Application will generate puzzles for you and you can solve it. 38 | 2. Proof generation. 39 | If you solve a puzzle, you can generate its proof. 40 | 3. Verify. 41 | You can make sure others that you have solved a puzzle without sharing your solution. 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zksnark-sudoku", 3 | "version": "1.0.0", 4 | "description": "Sudoku verifier using zkSNARK.", 5 | "scripts": { 6 | "compile-circuit": "npm run compile --workspace circuit", 7 | "test-circuit": "npm run test --workspace circuit", 8 | "dev": "npm run dev --workspace app", 9 | "build": "npm run build --workspace app" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/web3-master/zksnark-sudoku.git" 14 | }, 15 | "keywords": [ 16 | "zksnark", 17 | "circom", 18 | "snarkjs", 19 | "sudoku" 20 | ], 21 | "author": "web3-master", 22 | "license": "BSL-1.0", 23 | "bugs": { 24 | "url": "https://github.com/web3-master/zksnark-sudoku/issues" 25 | }, 26 | "homepage": "https://github.com/web3-master/zksnark-sudoku#readme", 27 | "workspaces": [ 28 | "./packages/*" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /packages/app/.eslintignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | .next 3 | node_modules 4 | out 5 | pages 6 | public 7 | styles 8 | next.config.js -------------------------------------------------------------------------------- /packages/app/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:@typescript-eslint/recommended", 5 | "next/core-web-vitals", 6 | "prettier" 7 | ], 8 | "parser": "@typescript-eslint/parser", 9 | "plugins": ["@typescript-eslint"], 10 | "parserOptions": { 11 | "project": "./tsconfig.json" 12 | }, 13 | "root": true 14 | } 15 | -------------------------------------------------------------------------------- /packages/app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /packages/app/.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | .next 3 | node_modules 4 | out 5 | pages 6 | public 7 | styles -------------------------------------------------------------------------------- /packages/app/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "bracketSpacing": true, 4 | "bracketSameLine": false, 5 | "printWidth": 80 6 | } 7 | -------------------------------------------------------------------------------- /packages/app/README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | ``` 12 | 13 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 14 | 15 | You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. 16 | 17 | [API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. 18 | 19 | The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. 20 | 21 | ## Learn More 22 | 23 | To learn more about Next.js, take a look at the following resources: 24 | 25 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 26 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 27 | 28 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 29 | 30 | ## Deploy on Vercel 31 | 32 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 33 | 34 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 35 | -------------------------------------------------------------------------------- /packages/app/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | eslint: { 5 | // Warning: This allows production builds to successfully complete even if 6 | // your project has ESLint errors. 7 | ignoreDuringBuilds: true, 8 | }, 9 | typescript: { 10 | // !! WARN !! 11 | // Dangerously allow production builds to successfully complete even if 12 | // your project has type errors. 13 | // !! WARN !! 14 | ignoreBuildErrors: true, 15 | }, 16 | }; 17 | 18 | module.exports = nextConfig; 19 | -------------------------------------------------------------------------------- /packages/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build && next export", 8 | "start": "next start", 9 | "lint": "eslint .", 10 | "prettier": "prettier --write ." 11 | }, 12 | "dependencies": { 13 | "@ant-design/colors": "^6.0.0", 14 | "@next/font": "13.0.6", 15 | "@types/node": "18.11.15", 16 | "@types/react": "18.0.26", 17 | "@types/react-dom": "18.0.9", 18 | "antd": "^5.0.7", 19 | "eslint-config-next": "13.0.6", 20 | "next": "13.0.6", 21 | "react": "18.2.0", 22 | "react-dom": "18.2.0", 23 | "snarkjs": "^0.5.0", 24 | "sudoku": "^0.0.3" 25 | }, 26 | "devDependencies": { 27 | "@typescript-eslint/eslint-plugin": "^5.47.0", 28 | "@typescript-eslint/parser": "^5.47.0", 29 | "eslint": "^8.30.0", 30 | "eslint-config-prettier": "^8.5.0", 31 | "prettier": "2.8.1", 32 | "typescript": "^4.9.4" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/app/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import "../styles/globals.css"; 2 | import "antd/dist/reset.css"; 3 | import type { AppProps } from "next/app"; 4 | import { ConfigProvider, theme } from "antd"; 5 | import { purple } from "@ant-design/colors"; 6 | 7 | export default function App({ Component, pageProps }: AppProps) { 8 | return ( 9 | 17 | 18 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /packages/app/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/app/pages/api/hello.ts: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | import type { NextApiRequest, NextApiResponse } from 'next' 3 | 4 | type Data = { 5 | name: string 6 | } 7 | 8 | export default function handler( 9 | req: NextApiRequest, 10 | res: NextApiResponse 11 | ) { 12 | res.status(200).json({ name: 'John Doe' }) 13 | } 14 | -------------------------------------------------------------------------------- /packages/app/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { Inter } from "@next/font/google"; 2 | import { Col, Row } from "antd"; 3 | import Head from "next/head"; 4 | import Script from "next/script"; 5 | import PlayPannel from "../src/components/PlayPannel"; 6 | import VerifyPannel from "../src/components/VerifyPannel"; 7 | import { APP_DESCRIPTION, APP_NAME } from "../src/Constants"; 8 | import AppLayout from "../src/layout/AppLayout"; 9 | 10 | const inter = Inter({ subsets: ["latin"] }); 11 | 12 | export default function Home() { 13 | return ( 14 | <> 15 | 16 | {APP_NAME} 17 | 18 | 19 | 20 | 21 |