From 97ba35d77f6155bc6db5a5170487f4b40200efc3 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:23:14 +0900 Subject: [PATCH 01/13] fix typos README.md "applilcations" -> "applications" "developping" -> "developing" "sophisicated" -> "sophisticated" "fo" -> "of" "languague" -> "language" "disign" -> "design" --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0903e2d..70715eb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repo contains documentation about the ZKWASM and can be seen live at: [See the book live](https://zkwasmdoc.gitbook.io/delphinus-zkwasm/). -The mission of DelphiusLab is to provide Web2 developers with a concise toolset to leverage the power of Web3 in their applications. The ZKWASM (ZKSNARK virtual machine that supports Web Assembly) serves as a trustless layer between rich applilcations running on WASM runtime and smart contracts on chain. +The mission of DelphiusLab is to provide Web2 developers with a concise toolset to leverage the power of Web3 in their applications. The ZKWASM (ZKSNARK virtual machine that supports Web Assembly) serves as a trustless layer between rich applications running on WASM runtime and smart contracts on chain. WASM (or WebAssembly) is an open standard binary code format similar to assembly. Its initial objective was to provide an alternative to java-script with improved performance for the current web ecosystem. Benefiting from its platform independence, front-end flexibility (can be compiled from the majority of languages including C, C++, assembly script, rust, etc.), good isolated runtime and speed comes closer to the speed of a native binary, its usage is arising in distributed cloud and edge computing. Recently it has become a popular binary format for users to run customized functions on AWS Lambda, Open Yurt, AZURE, etc. @@ -10,12 +10,12 @@ The idea of ZKWASM is derived from ZKSNARK (Zero-Knowledge Succinct Non-Interact Docs include tutorials for the following audiences -1. beginners to get familiar with developping WASM based applications that runs in ZKWASM virtual machine and specifications for zkWASM host circuits. -2. sophisicated rollup application builders that would like to leverage the ability fo ZKWASM for their own application rollup. -3. circuit integrators that would like to use WASM as a glue languague to connect different ZKP circuits for more customizable scenarios (eg. ML, ORACL, VRF, etc) +1. beginners to get familiar with developing WASM based applications that runs in ZKWASM virtual machine and specifications for zkWASM host circuits. +2. sophisticated rollup application builders that would like to leverage the ability of ZKWASM for their own application rollup. +3. circuit integrators that would like to use WASM as a glue language to connect different ZKP circuits for more customizable scenarios (eg. ML, ORACL, VRF, etc) 4. ZKVM builders that would like to use a core minimal set of WASM bytecode to build their own ZK virtual machine. -This document also provides the information regarding the ZKP circuit disign, proof batching and aggregation, proof structure of continuation execution, WASM host circuit integration and WASI support. +This document also provides the information regarding the ZKP circuit design, proof batching and aggregation, proof structure of continuation execution, WASM host circuit integration and WASI support. **This book is a WIP and being constantly updated.** From e1c443be461a46a2c0d820011a638e9abc3a80d6 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:26:22 +0900 Subject: [PATCH 02/13] fix typo README.md "should should" -> "should" ("should" used twice) --- c4_cloud/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c4_cloud/README.md b/c4_cloud/README.md index a918824..ff85190 100644 --- a/c4_cloud/README.md +++ b/c4_cloud/README.md @@ -177,7 +177,7 @@ With the verification contract deployed we can verify the proof on chain with th

-Hit the Verify on Chain button, sign the transaction, in some time the transaction receipt should should produce a successful on chain verification.
+Hit the Verify on Chain button, sign the transaction, in some time the transaction receipt should produce a successful on chain verification.

From 77477e9ef048c9f2f4dbc9d00b9e23fc06a2454a Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:30:59 +0900 Subject: [PATCH 03/13] fix typos README.md "bytecods" -> "bytecodes" "native supported runtime" -> "natively supported runtime" "Serveless" -> "Serverless" "selveless" -> "serverless" "applification" -> "application" "verfy" -> "very" "buildin" -> "builtin" "differen" -> "different" "easiler" -> "easier" "adopts itself quick" -> "adopts itself quickly" "morden" -> "modern" "compatiability" -> "compatibility" "Further more" -> "Furthermore" "an glue" -> "a glue" "board" -> "broad" --- c5_miscqa/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/c5_miscqa/README.md b/c5_miscqa/README.md index 0f68f43..491f7c6 100644 --- a/c5_miscqa/README.md +++ b/c5_miscqa/README.md @@ -1,15 +1,15 @@ # MISC Q&A -## Why pick WASM as the native bytecods our ZKVM +## Why pick WASM as the native bytecodes our ZKVM -1. Wasm run time is native supported runtime in Browser and Serveless application. Given the support of WASM in zkWASM, web2 application runs in browser and selveless server can quickly establish a trustless rollup via Delphinus ZKWasm applification specific rollup as a service. +1. Wasm run time is natively supported runtime in Browser and Serverless application. Given the support of WASM in zkWASM, web2 application runs in browser and serverless server can quickly establish a trustless rollup via Delphinus ZKWasm application specific rollup as a service. 2. Wasm is the major alternative to ethereum bytecode. Wasmi for substrate, Wasmtimer for Cosmos. Give a zkWASM virtual machine, we can potentially turn a substrate blockchain into a etheurem rollup. This give existing ecosystem (substrate) a way to be adopted into another ecosystem (Etheurem) -3. Wasm has a verfy concise but flexible specification. The buildin host function give a way for application and rollup service a native way to extend the runtime. Delphinuslab application rollup service can provide specific wasm runtime (with differen host functions) to provide applicification service. -4. Wasm support a broad range of generic languages including C, C++, rust, assembly script, typescript, etc. Thus libraries written in different languages can be linked together via wasm module system which means it is more easiler to build an ecosystem than single backend language. -5. Wasm is a bytecode that has regular evolution managed by World Wide Web Consortium (W3C). It means that wasm adopts itself quick than stable bytecodes like evm to fits the need of morden web2 applications. +3. Wasm has a very concise but flexible specification. The builtin host function give a way for application and rollup service a native way to extend the runtime. Delphinuslab application rollup service can provide specific wasm runtime (with different host functions) to provide applicification service. +4. Wasm support a broad range of generic languages including C, C++, rust, assembly script, typescript, etc. Thus libraries written in different languages can be linked together via wasm module system which means it is more easier to build an ecosystem than single backend language. +5. Wasm is a bytecode that has regular evolution managed by World Wide Web Consortium (W3C). It means that wasm adopts itself quickly than stable bytecodes like evm to fits the need of modern web2 applications. ## Why support unmodified WASM specification is important. -Delphinus-ZKWASM follows and supports the unmodified standard WASM bytecode specification https://www.w3.org/TR/wasm-core-1/ which are supported as a standard backend target by most of the generic programming languages (C, C++, Rust, Go, Assembly Script, etc). By providing full compatiability, wasm generated from the existing compilers can be executed in zkWASM emulator without further adjustment. Further more, zkWASM also follows the definition of WASM host functions, which are functions expressed outside WebAssembly but passed to a module as an import. +Delphinus-ZKWASM follows and supports the unmodified standard WASM bytecode specification https://www.w3.org/TR/wasm-core-1/ which are supported as a standard backend target by most of the generic programming languages (C, C++, Rust, Go, Assembly Script, etc). By providing full compatibility, wasm generated from the existing compilers can be executed in zkWASM emulator without further adjustment. Furthermore, zkWASM also follows the definition of WASM host functions, which are functions expressed outside WebAssembly but passed to a module as an import. Supporting the unmodified WebAssembly (WASM) bytecode specification has several advantages, particularly in terms of compatibility, security, performance, and cross-platform functionality. Here's a closer look at why it's beneficial to adhere to the standard, unmodified WASM specification: @@ -21,7 +21,7 @@ Supporting the unmodified WebAssembly (WASM) bytecode specification has several 4. Future-Proofing: The WASM specification is continuously evolving with contributions from a wide range of industry experts. By following the unmodified specification, developers can more easily adapt to future changes and enhancements in the WASM ecosystem. -5. Interoperability: WASM is designed to have native host api support, meaning it can support customization which allowing developers to seamlessly integrate code(or zk circuit) from external ecosystem. Delphinus-ZKWASM fully support WASM's native host api extension features thus can be used as an glue language for a board range of application specific circuits. +5. Interoperability: WASM is designed to have native host api support, meaning it can support customization which allowing developers to seamlessly integrate code(or zk circuit) from external ecosystem. Delphinus-ZKWASM fully support WASM's native host api extension features thus can be used as a glue language for a broad range of application specific circuits. ## Why not just use LLVM bitcode as a binary format? The LLVM compiler infrastructure has a lot of attractive qualities: it has an existing intermediate representation (LLVM IR) and binary encoding format (bitcode). It has code generation backends targeting many architectures and is actively developed and maintained by a large community. In fact PNaCl already uses LLVM as a basis for its binary format. However, the goals and requirements that LLVM was designed to meet are subtly mismatched with those of WebAssembly. From 9fc8db7fc486338db24c7aaf79a2cb7863c4707f Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:31:58 +0900 Subject: [PATCH 04/13] Update README.md "suppose" -> "supposed" --- c2_advance/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c2_advance/README.md b/c2_advance/README.md index e715472..3b20f8c 100644 --- a/c2_advance/README.md +++ b/c2_advance/README.md @@ -1,9 +1,9 @@ # Build a Rollup Application -This document is suppose to be a complete reference for ZKWASM users that would like to make their own rollup application. Following topics will be covered: +This document is supposed to be a complete reference for ZKWASM users that would like to make their own rollup application. Following topics will be covered: 1. The architecture of a reference implementation of ZKWASM rollup application. 2. The proof generation architecture. 3. Customize and define your ZKWASM by extending host APIs. 4. Customize your proof generation via proof batching scripts. -3. Define settlement protocol and deploy your rollup verifier. +5. Define settlement protocol and deploy your rollup verifier. From 4648c5bc4bab9edb9e5cead652ea9047074f448b Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:34:45 +0900 Subject: [PATCH 05/13] fix typos README.md "initialobjective" -> "initial objective" "webecosystems" -> "web ecosystems" "fromthe" -> "from the" "runtimeand" -> "runtime and" "edgecomputing" -> "edge computing" "functionson" -> "functions on" "connecta" -> "connect a" "building block andingredients" -> "building blocks and ingredients" "validunder" -> "valid under" "suchthat" -> "such that" "inpractical" -> "in practical" "a internal" -> "an internal" --- c3_circuits/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/c3_circuits/README.md b/c3_circuits/README.md index 27c7a1a..f12d878 100644 --- a/c3_circuits/README.md +++ b/c3_circuits/README.md @@ -1,12 +1,12 @@ # Circuit Design ## 1 INTRODUCTION -WASM (or WebAssembly) is an open standard binary code format close to assembly. Its initialobjective is to provide an alternative to java-script with better performance in the current webecosystems. Benefiting from its platform independence, front-end flexibility (can be compiled fromthe majority of languages including C, C++, assembly script, rust, etc.), good isolated runtimeand speed that is close to native binary, its usage starts to arise in the distributed cloud and edgecomputing. Recently it has become a popular binary format for users to run customized functionson AWS Lambda, Open Yurt, AZURE, etc. +WASM (or WebAssembly) is an open standard binary code format close to assembly. Its initial objective is to provide an alternative to java-script with better performance in the current web ecosystems. Benefiting from its platform independence, front-end flexibility (can be compiled from the majority of languages including C, C++, assembly script, rust, etc.), good isolated runtime and speed that is close to native binary, its usage starts to arise in the distributed cloud and edge computing. Recently it has become a popular binary format for users to run customized functions on AWS Lambda, Open Yurt, AZURE, etc. **The Problem.** To implement a ZKSNARK-backed WASM virtual machine, we need to connect the implementation of WASM runtime with the proof system of ZKSNARK. In general, a ZKSNARK system is represented in arithmetic circuits with polynomial constraints. Therefore we need to abstract the full imperative logic of a WASM virtual machine systematically and rewrite it into arithmetic circuits with constraints. Given two outputs, one is generated by emulating the WASM bytecode in WASM runtime that enforces the semantics of WASM specification, and the other satisfies the constraints imposed on the arithmetic circuits. If the circuits we write preserve the semantics, these two outputs must be the same. Hence the proof of the ZKSNARK derived from the circuits also shows that the output is valid as a result of emulating the bytecode in WASM runtime. -**Organization of the document.** After a brief introduction to the basic ideas about how to connecta stateful virtual machine with ZKSNARK in Section 2, we describe the basic building block andingredients used to construct ZKWASM circuits in Section 3 and then present the circuits architecture in Section 4. After the architecture is settled, we discuss the circuits of every category of WASM instructions in Section 5. In addition, in Section 5.4 we discuss foreign instruction expansion which provides a way to extend the virtual machine for better performance and integration. In Section 6, we present the partition and proof batching technique to solve the long execution trace problem. +**Organization of the document.** After a brief introduction to the basic ideas about how to connect a stateful virtual machine with ZKSNARK in Section 2, we describe the basic building block and ingredients used to construct ZKWASM circuits in Section 3 and then present the circuits architecture in Section 4. After the architecture is settled, we discuss the circuits of every category of WASM instructions in Section 5. In addition, in Section 5.4 we discuss foreign instruction expansion which provides a way to extend the virtual machine for better performance and integration. In Section 6, we present the partition and proof batching technique to solve the long execution trace problem. Throughout the document, we use the notation $$a:A$$ to specify a variable of type $$A$$, $$F$$ to specify the number field, and $$F_n$$ to specify a multi-dimensional vector with dimension $$n$$. We denote by $$A \rightarrow B$$ the function type from $$A$$ to $$B$$ and use $$\circ$$ for function composition. Moreover, we use $$G[i][j]$$ to specify the value of the cell of matrix $$G$$ at the $$i$$ th row and $$j$$ th column. @@ -17,17 +17,17 @@ Internally the WASM run-time maintains a state $$S$$ denoted by a tuple ($$iaddr For simplicity, we will use the notation of record field to specify a field in state $$s:S$$. For example, $$s.iaddr$$ denotes the current instruction address of state $$s$$, $$s.IO.stdin$$ denotes the input of state $$s$$, etc. We also use $$s.iaddr.op$$ to denote the opcode (operation code that specifies the operation to be performed) at address $$s.iaddr$$ in the code section $$C$$ of image $$I$$. -Based on the above definition, we define the criteria for a list of state transitions to be validunder $$(I(C, H), E, IO)$$, as follows. +Based on the above definition, we define the criteria for a list of state transitions to be valid under $$(I(C, H), E, IO)$$, as follows. --- **Definition 2.1** (Valid Execution Trace). Given a WASM machine with input $$(I(C, H), E, IO)$$, and $$s_0$$ is the initial state with $$s_0.iaddr = E$$. A valid execution trace is a list of transition functions $$t_i$$ suchthat the following holds: +-- **Definition 2.1** (Valid Execution Trace). Given a WASM machine with input $$(I(C, H), E, IO)$$, and $$s_0$$ is the initial state with $$s_0.iaddr = E$$. A valid execution trace is a list of transition functions $$t_i$$ such that the following holds: (1) For all $$k$$, $$s_k = t_{k-1} \circ \cdots \circ t_1 \circ t_0 (s_0)$$, $$t_k$$ enforces the semantics of $$s_k.iaddr.op$$. (2) If $s_e$ is the last state, then the depth of the calling frame is zero: $se.F.depth = 0$. ## 3 IO of ZKWASM -The outermost function of ZKWASM is of type `zkmain(void): (void)`. To access the external IO, we use two builtin host functions: *zkwasm_input* and *zkwasm_output*. Suppose that we have an array of instances [$$I_i$$] and a internal cursor $$k$$, *zkwasm_input(1)* binds the $$k$$th instance to the top of the stack and similarly *zkwasm_output()* binds the current top of the stack with $$I_k$$. Both *zkwasm_input* and *zkwasm_output* increase the cursor $$k$$. We can also access external witness by *zkwasm_input(0)*, when doing so we just fill the top of the stack with a witness which does not bind with any public instances. +The outermost function of ZKWASM is of type `zkmain(void): (void)`. To access the external IO, we use two builtin host functions: *zkwasm_input* and *zkwasm_output*. Suppose that we have an array of instances [$$I_i$$] and an internal cursor $$k$$, *zkwasm_input(1)* binds the $$k$$th instance to the top of the stack and similarly *zkwasm_output()* binds the current top of the stack with $$I_k$$. Both *zkwasm_input* and *zkwasm_output* increase the cursor $$k$$. We can also access external witness by *zkwasm_input(0)*, when doing so we just fill the top of the stack with a witness which does not bind with any public instances. ## 4 Succinct Proof of the circuits -Compared with a standard WASM run-time, ZKWASM aims to provide a proof to prove that the output is valid so that it can be used in scenarios which require trustless and privacy computation. Moreover, the verifying algorithm needs to be simple in the sense of complexity to be useful inpractical. In zkWasm we have three different categories of circuits. +Compared with a standard WASM run-time, ZKWASM aims to provide a proof to prove that the output is valid so that it can be used in scenarios which require trustless and privacy computation. Moreover, the verifying algorithm needs to be simple in the sense of complexity to be useful in practical. In zkWasm we have three different categories of circuits. 1. Guest circuits: enforces the semantics of slices of execution traces. 2. Host circuits: enforces the semantics of host API calls From 56b3ca7b8169274382c84f7dc3527234336c8f2a Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:36:43 +0900 Subject: [PATCH 06/13] fix typos c1_typescript.md "typscript" -> "typescript" "APIS" -> "APIs" "informations" -> "information" "A example" -> "An example" --- c4_cloud/c1_typescript.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/c4_cloud/c1_typescript.md b/c4_cloud/c1_typescript.md index fea107f..1051122 100644 --- a/c4_cloud/c1_typescript.md +++ b/c4_cloud/c1_typescript.md @@ -1,11 +1,11 @@ # Typescript SDK for connecting with ZKWASM cloud. ## Introduction -zkWasm-service-helper(https://github.com/DelphinusLab/zkWasm-service-helper) is a typscript library to help communicate with zkwasm cloud service. It provides common APIS for ZKWASM application developers to use the cloud proving service to generate ZKWASM proofs. +zkWasm-service-helper(https://github.com/DelphinusLab/zkWasm-service-helper) is a typescript library to help communicate with zkwasm cloud service. It provides common APIs for ZKWASM application developers to use the cloud proving service to generate ZKWASM proofs. ## How to use it -The default RPC point for ZKWASM cloud is "https://rpc.zkwasmhub.com:8090". This lib main provide a ZkWasmServiceHelper class to help user to communicate to this RPC endpoint. It mainly provides the following APIs to perform proving tasks and query informations about submitted tasks. +The default RPC point for ZKWASM cloud is "https://rpc.zkwasmhub.com:8090". This lib main provide a ZkWasmServiceHelper class to help user to communicate to this RPC endpoint. It mainly provides the following APIs to perform proving tasks and query information about submitted tasks. Example APIs: * async queryImage(md5: string); @@ -13,7 +13,7 @@ Example APIs: * async addNewWasmImage(task: WithSignature); * async addProvingTask(task: WithSignature); -### A example to add new wasm image +### An example to add new wasm image This example typescript code will add the wasm image to the zkwasm service. ``` import { @@ -52,7 +52,7 @@ let response = await helper.addNewWasmImage(task); ``` -### A example to add proving tasks +### An example to add proving tasks This example typescript code will add proving tasks to the zkwasm service. ``` import { @@ -96,7 +96,7 @@ let task: WithSignature = { let response = await helper.addProvingTask(task); ``` -### A example to query task details +### An example to query task details This example typescript code will query task details: ``` import { From d47857d9eddee1f777e3c0843c51f617d0f36317 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:39:03 +0900 Subject: [PATCH 07/13] fix typos io.md "circuits distinguish" -> "circuit distinguishes" "two different way" -> "two different ways" "an public instance" -> "a public instance" "initialzed" -> "initialized" --- c1_beginner/c2_builtin/io.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c1_beginner/c2_builtin/io.md b/c1_beginner/c2_builtin/io.md index 881aa12..6fbd0a7 100644 --- a/c1_beginner/c2_builtin/io.md +++ b/c1_beginner/c2_builtin/io.md @@ -1,7 +1,7 @@ # IO Functions ## Fetch External Inputs -Since a ZKP circuits distinguish between public inputs(instances) and private inputs(witness), ZKWASM supports two different way to fetch inputs from the user, **zkwasm_input(1)** reads an public instance from the user and **zkwasm_input(0)** reads a private input(witness). +Since a ZKP circuit distinguishes between public inputs(instances) and private inputs(witness), ZKWASM supports two different ways to fetch inputs from the user, **zkwasm_input(1)** reads a public instance from the user and **zkwasm_input(0)** reads a private input(witness). ``` extern "C" { @@ -22,7 +22,7 @@ fn get_inputs() -> [u64; 3] { ``` ## Witness Queue. -The ZKWASM run time supports multiple queue. When the ZKWASM runs an image, the input witness queues is initialzed by a sequence of u64 specified by the ZKWASM running API (See command line args --private). Once this queue is specified, we can not change it and all the witness can be fetched from the beginning (start from index 0) by **zkwasm_input(0)** one by one. +The ZKWASM run time supports multiple queue. When the ZKWASM runs an image, the input witness queues is initialized by a sequence of u64 specified by the ZKWASM running API (See command line args --private). Once this queue is specified, we can not change it and all the witness can be fetched from the beginning (start from index 0) by **zkwasm_input(0)** one by one. Suppose that a list of witness inputs are specified via --private input1:i64 input2:i64 input3:i64 ..., then the following code should return an array of [input1, input2, input3] From b42112e0b2e772f9a92b63326139038b2354a1ff Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:43:49 +0900 Subject: [PATCH 08/13] fix typos README.md "can be describe" -> "can be described" "cloumn" -> "column" "instanation" -> "instantiation" "Futhermore" -> "Furthermore" "type of columns" -> "types of columns" "steup" -> "setup" "compute the the values" -> "compute the values" "in to" -> "into" "commintment" -> "commitment" --- c2_advance/c1_circuit/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/c2_advance/c1_circuit/README.md b/c2_advance/c1_circuit/README.md index d02b6fb..d8ab6cf 100644 --- a/c2_advance/c1_circuit/README.md +++ b/c2_advance/c1_circuit/README.md @@ -1,15 +1,15 @@ # ZKWASM Circuits -A ZK Circuit in abstract is a matrix that each column represents a function $$f_i(w_j)$$ where $$j=1,2,3 \cdots$$ and a set of constraints $$C$$. A constraint in $$C$$ can be describe as a function equation $$H(f_i(w * g^j) = 0$$. Given an arbitrary instance of matrix, if all cloumn of the matrix satisfies the constraints $$C$$ then it is a valid instanation of the given circuit. +A ZK Circuit in abstract is a matrix that each column represents a function $$f_i(w_j)$$ where $$j=1,2,3 \cdots$$ and a set of constraints $$C$$. A constraint in $$C$$ can be described as a function equation $$H(f_i(w * g^j) = 0$$. Given an arbitrary instance of matrix, if all column of the matrix satisfies the constraints $$C$$ then it is a valid instantiation of the given circuit. -Futhermore, given a matrix, we have 3 different type of columns. +Furthermore, given a matrix, we have 3 different types of columns. 1. Advice columns. Value of advice columns can vary among different valid instantiations. -2. Fix columns. Value of fix columns must keep the same between different valid instantiations and the value of each fixed columns are provided at steup stage of the circuit. +2. Fix columns. Value of fix columns must keep the same between different valid instantiations and the value of each fixed columns are provided at setup stage of the circuit. 3. Instance columns. Value of instance columns usually decides the other value of the matrix and is used as the input of the verifier. We call the process of deducing other values in the matrix via the instance column to be the synthesize process. ## Circuit Setup -Circuit Setup contains two phases. One is to compute the the values of all fixed columns and the other is to compute the values of all implicit columns derived from lookups and permutations. Once the circuit was setup, the commitment of each pre-calculated columns are stored into a vkey file and the other information of the circuit is stored in to a circuit data file which uniquely defines the circuit. +Circuit Setup contains two phases. One is to compute the values of all fixed columns and the other is to compute the values of all implicit columns derived from lookups and permutations. Once the circuit was setup, the commitment of each pre-calculated columns are stored into a vkey file and the other information of the circuit is stored into a circuit data file which uniquely defines the circuit. ## Circuit Synthesize The synthesize process calculates all the witness of the circuit matrix based on the provided value of instance columns. Once a circuit instance has been synthesized, we can start proof generation of this instantiation. @@ -18,7 +18,7 @@ The synthesize process calculates all the witness of the circuit matrix based on Proof is generated after the syntehsize stage via PCS(polynomial commitment scheme). In short, the proof contains the commit of constraint polynomials $$C(x)$$, the commitment of the vanish polynomial V(x) and the quotient polynomial $$h(x)$$. All these info are stored in a file called `proof transcript` (usually has file name `XXX.transcript.data`). ## Verify proof -The proof verification algorithm is simply open all the commintment of PCS to check that the polynomial constraints holds. +The proof verification algorithm is simply open all the commitment of PCS to check that the polynomial constraints holds. ## Circuits involved in ZKWASM In ZKWASM, there are three different categories of circuits. From 240a23da1861f926a969bcf35d1cdd881575424e Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:44:44 +0900 Subject: [PATCH 09/13] fix typos README.md "solphiscated" -> "sophisticated" "devides" -> "divides" "categores" -> "categories" "functiosn" -> "functions" --- c1_beginner/c2_builtin/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c1_beginner/c2_builtin/README.md b/c1_beginner/c2_builtin/README.md index 03ae3c3..db1ddcb 100644 --- a/c1_beginner/c2_builtin/README.md +++ b/c1_beginner/c2_builtin/README.md @@ -14,8 +14,8 @@ Here are some key points about WASM host functions: In summary, WASM host functions are a crucial part of the WebAssembly ecosystem, enabling WASM modules to interact with their environment in a controlled and secure manner, thus extending the capabilities of WebAssembly beyond its sandboxed context. -In the ZKWASM, we provide a wide range of pre-defined host functions to ease the burden of building solphiscated applications. We devides them into three major categores +In the ZKWASM, we provide a wide range of pre-defined host functions to ease the burden of building sophisticated applications. We divides them into three major categories 1. IO related host functions 2. Constraint related host functions. -3. Predefined host functiosn with external circuits support. +3. Predefined host functions with external circuits support. From 9d38793d20cda2801918c7f5d5742303eca0519c Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:47:19 +0900 Subject: [PATCH 10/13] fix typos README.md "Architectrue" -> "Architecture" "serveral" -> "several" "applicatin" -> "application" "Further more" -> "Furthermore" "differerent" -> "different" "a application" -> "an application" --- c2_advance/c3_proofgen/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c2_advance/c3_proofgen/README.md b/c2_advance/c3_proofgen/README.md index 9bddb87..702f26d 100644 --- a/c2_advance/c3_proofgen/README.md +++ b/c2_advance/c3_proofgen/README.md @@ -1,13 +1,13 @@ -# Proof Generation Architectrue -When executing a WASM image, its generated trace can be very long (serveral billion instructions) while the ZKWASM guest circuits has a limit on how many instructions it can proof in a single execution segment. Thus we need a scheme to split the huge execution into small pieces and generate the proof of them separately. After that we need to add extra connecting proofs to connect those separated proofs and then batch them together to generate a single proof for the whole execution. +# Proof Generation Architecture +When executing a WASM image, its generated trace can be very long (several billion instructions) while the ZKWASM guest circuits has a limit on how many instructions it can proof in a single execution segment. Thus we need a scheme to split the huge execution into small pieces and generate the proof of them separately. After that we need to add extra connecting proofs to connect those separated proofs and then batch them together to generate a single proof for the whole execution. -In ZKWASM we assume an applicatin is just like a standard desktop application that have a lifecycle of open, run and close. We say a single lifecycle from open to close is a bundle of execution while within that bundle there is a huge execution trace that contains billions of instructions. Further more, we split the execution of a bundle into many small execution segments. +In ZKWASM we assume an application is just like a standard desktop application that have a lifecycle of open, run and close. We say a single lifecycle from open to close is a bundle of execution while within that bundle there is a huge execution trace that contains billions of instructions. Furthermore, we split the execution of a bundle into many small execution segments. The overall proof generation architecture is divided into three stages depends on the application executing style. 1. Segment proof: guest and host circuit proof of a single execution segment. 2. Continuation proof: connecting the segment proof and batch them into a single bundle execution proof. -3. Bundle proof batching: combine the continuation proof of each bundle and generate a single proofs (This is usually for a application rollup which needs to submit the state differerent to a Blockchain with a execution proofs). +3. Bundle proof batching: combine the continuation proof of each bundle and generate a single proofs (This is usually for an application rollup which needs to submit the state different to a Blockchain with a execution proofs).

From b24c77e2218317499b071eae2dc10aa4d49a2c48 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:49:26 +0900 Subject: [PATCH 11/13] fix typos c3_setup.md "beinging" -> "being" "excution" -> "execution" --- c1_beginner/c1_quickstart/c3_setup.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c1_beginner/c1_quickstart/c3_setup.md b/c1_beginner/c1_quickstart/c3_setup.md index dca6bd0..cb166dc 100644 --- a/c1_beginner/c1_quickstart/c3_setup.md +++ b/c1_beginner/c1_quickstart/c3_setup.md @@ -1,6 +1,6 @@ # Setup ZKWASM circuit -With the wasm bytecode beinging generated, we can start setup the circuit of the VM. In the Setup Phase an application as a wasm image is used as input to zkWasm to generate a zkSNARK circuit for the application. The setup phase generates the output vkey.data for the image which is a circuit that commits its constant column. +With the wasm bytecode being generated, we can start setup the circuit of the VM. In the Setup Phase an application as a wasm image is used as input to zkWasm to generate a zkSNARK circuit for the application. The setup phase generates the output vkey.data for the image which is a circuit that commits its constant column. There are two modes to setup ZKWASM, the uniform-circuit mode and the image specific mode. @@ -49,7 +49,7 @@ This produces the output files in `./params/` As the default mode is more friendly for beginers that might only focus on a particular application, the following content will assume the default mode is enabled. (However all examples should also works in uniform-mode). ## The continuation mode -When you are running a wasm image with unbounded execution trace, you need to use the continuation mode of zkWasm which will splits the excution trace into slices and generate proofs for each slice. +When you are running a wasm image with unbounded execution trace, you need to use the continuation mode of zkWasm which will splits the execution trace into slices and generate proofs for each slice. ``` cargo run --release --features continuation --params ./params testwasm setup ``` From b3499bf21f9fd543b6ea126b32e3eda6676acac9 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:50:57 +0900 Subject: [PATCH 12/13] fix typos c4_prove.md "signle" -> "single" "commnad" -> "command" "arguement" -> "argument" "execuated" -> "executed" --- c1_beginner/c1_quickstart/c4_prove.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c1_beginner/c1_quickstart/c4_prove.md b/c1_beginner/c1_quickstart/c4_prove.md index e6ef9b9..6bb45cf 100644 --- a/c1_beginner/c1_quickstart/c4_prove.md +++ b/c1_beginner/c1_quickstart/c4_prove.md @@ -1,6 +1,6 @@ # Prove WASM execution -## Proof Generation of a signle execution +## Proof Generation of a single execution In the Proof Phase the web assembly interpreter (wasmi) outputs two traces; the web assembly bytecode as the execution trace & the host API call trace. These record the order of the host API calls and their output. The combination of the two traces ensures the host call trace is in the same order as the execution trace (including the same input arguments).
@@ -12,7 +12,7 @@ $ZKWASMBIN/zkwasm-cli --params ./params testwasm prove --output ./output --wasm In the above command `--host` specifies the host api set we would like to use. Since our application does not relies on any special WASI functions, and `--params` tells the prover refer to `/params` folder for all circuit specific data. The `--output` argument specify the output folder for proof results (together with some intermediate files). -After executing the commnad, it should produce the following files in the output directory `--output ./output`. +After executing the command, it should produce the following files in the output directory `--output ./output`. ``` . @@ -59,7 +59,7 @@ The process of proof generation requires reading the vkey which is implied by th ## Proof Verification: -The verification of a proof generated by zkWasm is done using the `verify` command line arguement. In the below bash script which is execuated from within `output_simple_program` a single verification run can be done by: +The verification of a proof generated by zkWasm is done using the `verify` command line argument. In the below bash script which is executed from within `output_simple_program` a single verification run can be done by: ``` $ZKWASMBIN/zkwasm-cli --params ./params testwasm verify --output ./output From c217bda15c1f2683d8d014f00526f81e00aa07f6 Mon Sep 17 00:00:00 2001 From: osrm <90407222+osrm@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:51:42 +0900 Subject: [PATCH 13/13] fix typo c2_prepare.md "Simlarly" -> "Similarly" --- c1_beginner/c1_quickstart/c2_prepare.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c1_beginner/c1_quickstart/c2_prepare.md b/c1_beginner/c1_quickstart/c2_prepare.md index 23aa220..6962563 100644 --- a/c1_beginner/c1_quickstart/c2_prepare.md +++ b/c1_beginner/c1_quickstart/c2_prepare.md @@ -106,7 +106,7 @@ pub fn zkmain() -> { } ``` -Simlarly the Makefile used to generate WASM from RUST is the following: +Similarly the Makefile used to generate WASM from RUST is the following: ``` build: wasm-pack build --release --out-name rust-sdk-test.wasm --out-dir pkg --features wasmbind