How minhvip08/zkshuffle works
Overall Structure and Main Components
• Project as a monorepo that leverages Yarn workspaces. Indicate that the repository is organized into distinct packages under “packages/”.
• Four main packages:
• @zk-shuffle/circuits – This contains the Circom circuits (e.g., babyjubjub, boolean, elgamal, matrix, permutation) along with unit tests. It is the foundation for generating zk proof artifacts (zkey, wasm, verifier contracts).
• @zk-shuffle/contracts – Contains Solidity smart contracts that incorporate the generated verifier contracts from the circuits package. It may also include additional functionalities and extensions as described in its documentation.
• @zk-shuffle/jssdk – A TypeScript SDK package that provides helper functions for generating zk proofs and cryptographic operations. This package is used by dApp developers to interact with the circuits and smart contracts.
• @zk-shuffle/proof – Provides utilities for generating zk proofs and is utilized by the contracts package for end-to-end testing.
Relationships and Interactions
• The contracts package depends on and imports the circuits artifacts (compiled circuits, verifiers).
• The jssdk and proof packages depend on the circuits package to perform proof generation and validation.
• The proof package also supports testing within the contracts package by offering proof generation utilities.
• Flow from circuit compilation: Circom circuits (from the circuits package) are compiled (outputting zkey/wasm/verifier contracts) and these outputs are integrated into the contracts package. Then the jssdk package provides a user-friendly interface to interact with these outputs in a dApp environment.
Architectural Patterns and Design Principles
• Modularity and clear separation of concerns. Each package encapsulates its functionality (circuits, contracts, SDK, proof utilities).
• That tests exist at various levels (unit tests in circuits, e2e tests in contracts, and specific tests for the proof package) to ensure quality and correct integration.
• Build and deployment scripts (e.g., Hardhat configurations in circuits and contracts, Yarn workspace commands) to indicate the CI/CD flows via GitHub workflows.
Relevant Technologies
• Circom for creating the ZKP circuits.
• Solidity and Hardhat for smart contract development and deployment.
• TypeScript for the jssdk and associated tooling in the proof package.
• Yarn v2 with workspaces for package management and project organization.
• Testing frameworks integrated into each package (unit testing, benchmark tests, etc.), as well as automated workflows defined in the .github/workflows directory.