How icme-lab/zkengine_dev works
Main Components
• Core Engine (zkEngine Library): Represents the central logic of the engine. The core includes modules such as:
• wasm_snark: This module is the heart of the proving process and proof verification. It provides functions like setup (producing public parameters), proving (executing the WASM code under a given step size), and verifying proofs.
• wasm_ctx & wasm_args: These components build and manage the execution context for a given WASM program. The WASMArgsBuilder is used to provide the file path, function name (e.g., "fib" or "kth_factor"), and function arguments.
• Aggregation and Sharding: These modules (located in src/aggregation and src/sharding) could address how the workload or data is partitioned and then combined – likely to support scalability or efficient memory consistency checks.
• Utils: Various helper modules like logging, tracing, and error handling that support the overall engine.
Third-Party Integration
• Wasmi: A Wasi or WASM interpreter engine integrated under the third-party directory. This is used to interpret or process WASM bytecode. It provides the underlying WASM execution environment which the zkEngine builds upon.
• External WASM Files: The WASM programs (e.g., in the wasm/ directory) are the inputs that the engine works on. They provide real-world examples (e.g., Fibonacci, kth_factor, etc.) and use cases.
Relationships and Data Flow
• Memory Consistency (MCC) and Switchboard: Within the wasm_snark module, break out internal components such as:
▪ Gadgets: Constraint systems and arithmetic operations (e.g., int, mcc).
▪ MCC (Memory Consistency Check) modules: Responsible for verifying large memory spaces and using memory_step_size.
▪ Switchboard: Handling ALU operations (with subcomponents for int32, int64, etc.).
As internal components that feed into the overall “WasmSNARK” proving flow.
Architectural Patterns or Design Principles
• Modular Design: The code is organized across different modules (aggregation, sharding, wasm_snark, utils) which promotes clear separation of concerns.
• Layering: The system layers the WASM input processing (WASMCtx), the proving engine (WasmSNARK with its gadgets and MCC), and the post-processing verification steps.
• Integration of Third-Party Libraries: The incorporation of wasmi shows how external dependencies are wrapped within the project to provide WASM module support.