diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..c1d2ba2
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,48 @@
+# Define standard eol format
+
+# Web Files
+*.html text eol=lf
+*.md text eol=lf
+*.css text eol=lf
+*.js text eol=lf
+
+# Jekyll related files
+*.yml text eol=lf
+
+# Git related files
+.gittattributes text eol=lf
+.gitignore text eol=lf
+.gitkeep text eol=lf
+
+# Ruby files
+*.rb text eol=lf
+Gemfile text eol=lf
+Gemfile.lock text eol=lf
+
+# Github specific fies
+LICENCE text eol=lf
+
+# Docker specific files
+Dockerfile text eol=lf
+
+# VSCode files
+*.json text eol=lf
+
+# General multimedia files
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.png binary
+*.t3x binary
+*.t3d binary
+*.exe binary
+*.data binary
+*.ttf binary
+*.eof binary
+*.eot binary
+*.swf binary
+*.mov binary
+*.mp4 binary
+*.mp3 binary
+*.ogg binary
+*.flv binary
diff --git a/.gitignore b/.gitignore
index 645ce6c..7d47e95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,16 @@
-book
-temp
\ No newline at end of file
+temp
+
+# project
+_site
+.sass-cache
+.vagrant
+
+# general
+.DS_Store
+Thumbs.db
+ehthumbs.db
+
+Gemfile.lock
+
+beautiful-jekyll-theme-*.gem
+>>>>>>> 118400f (trying out theme)
diff --git a/README.md b/README.md
index 62151f4..c70bc30 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,9 @@
# Delphinus-Lab-Book
-This repo contains a `mdBook` for documentation about the zkWASM, tutorials for zkWasm service and specifications for zkWASM host circuits.
+This repo contains documentation about the zkWASM `./docs` directory or can be seen live at: [See the book live](https://delphinuslab.github.io/Delphinus-Lab-Book/).
-This book is a WIP and being constantly updated.
+Docs include tutorials for zkWasm service and specifications for zkWASM host circuits.
+**This book is a WIP and being constantly updated.**
-## Building:
-This book is built with mdbook.
-
-For installation instructions consult:
-[mdBook Documentation](https://rust-lang.github.io/mdBook/guide/installation.html)
-
-Alternatively you can use Cargo to install:
-```console
-cargo install mdbook
-```
-
-Build the book with:
-
-```console
-mdbook build
-```
-
-## Serving the Book:
-
-To build & serve:
-
-```
-mdbook serve --open
-```
-
-To build & serve at host address on specific port:
-```
-mdbook serve -p 3000 -n 0.0.0.0
-```
\ No newline at end of file
diff --git a/book.toml b/book.toml
deleted file mode 100644
index 4109364..0000000
--- a/book.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[book]
-authors = ["Antony"]
-language = "en"
-multilingual = false
-src = "doc"
-title = "Delphinus Labs Documentation"
-
-[preprocessor.katex]
-
-[output.html]
diff --git a/docs/.rubocop.yml b/docs/.rubocop.yml
new file mode 100644
index 0000000..15c823d
--- /dev/null
+++ b/docs/.rubocop.yml
@@ -0,0 +1,11 @@
+inherit_gem:
+ rubocop-github:
+ - config/default.yml
+
+AllCops:
+ Exclude:
+ - _site/**/*
+ - vendor/**/*
+
+Layout/LineLength:
+ Enabled: false
diff --git a/docs/.travis.yml b/docs/.travis.yml
new file mode 100644
index 0000000..a871f2a
--- /dev/null
+++ b/docs/.travis.yml
@@ -0,0 +1,6 @@
+language: ruby
+cache: bundler
+rvm: 2.6
+
+install: script/bootstrap
+script: script/cibuild
diff --git a/docs/Gemfile b/docs/Gemfile
new file mode 100644
index 0000000..be173b2
--- /dev/null
+++ b/docs/Gemfile
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+source "https://rubygems.org"
+
+gemspec
diff --git a/docs/LICENSE b/docs/LICENSE
new file mode 100644
index 0000000..670154e
--- /dev/null
+++ b/docs/LICENSE
@@ -0,0 +1,116 @@
+CC0 1.0 Universal
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator and
+subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for the
+purpose of contributing to a commons of creative, cultural and scientific
+works ("Commons") that the public can reliably and without fear of later
+claims of infringement build upon, modify, incorporate in other works, reuse
+and redistribute as freely as possible in any form whatsoever and for any
+purposes, including without limitation commercial purposes. These owners may
+contribute to the Commons to promote the ideal of a free culture and the
+further production of creative, cultural and scientific works, or to gain
+reputation or greater distribution for their Work in part through the use and
+efforts of others.
+
+For these and/or other purposes and motivations, and without any expectation
+of additional consideration or compensation, the person associating CC0 with a
+Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
+and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
+and publicly distribute the Work under its terms, with knowledge of his or her
+Copyright and Related Rights in the Work and the meaning and intended legal
+effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not limited
+to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
+ and translate a Work;
+
+ ii. moral rights retained by the original author(s) and/or performer(s);
+
+ iii. publicity and privacy rights pertaining to a person's image or likeness
+ depicted in a Work;
+
+ iv. rights protecting against unfair competition in regards to a Work,
+ subject to the limitations in paragraph 4(a), below;
+
+ v. rights protecting the extraction, dissemination, use and reuse of data in
+ a Work;
+
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+ European Parliament and of the Council of 11 March 1996 on the legal
+ protection of databases, and under any national implementation thereof,
+ including any amended or successor version of such directive); and
+
+ vii. other similar, equivalent or corresponding rights throughout the world
+ based on applicable law or treaty, and any national implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention of,
+applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
+unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
+and Related Rights and associated claims and causes of action, whether now
+known or unknown (including existing as well as future claims and causes of
+action), in the Work (i) in all territories worldwide, (ii) for the maximum
+duration provided by applicable law or treaty (including future time
+extensions), (iii) in any current or future medium and for any number of
+copies, and (iv) for any purpose whatsoever, including without limitation
+commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
+the Waiver for the benefit of each member of the public at large and to the
+detriment of Affirmer's heirs and successors, fully intending that such Waiver
+shall not be subject to revocation, rescission, cancellation, termination, or
+any other legal or equitable action to disrupt the quiet enjoyment of the Work
+by the public as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason be
+judged legally invalid or ineffective under applicable law, then the Waiver
+shall be preserved to the maximum extent permitted taking into account
+Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
+is so judged Affirmer hereby grants to each affected person a royalty-free,
+non transferable, non sublicensable, non exclusive, irrevocable and
+unconditional license to exercise Affirmer's Copyright and Related Rights in
+the Work (i) in all territories worldwide, (ii) for the maximum duration
+provided by applicable law or treaty (including future time extensions), (iii)
+in any current or future medium and for any number of copies, and (iv) for any
+purpose whatsoever, including without limitation commercial, advertising or
+promotional purposes (the "License"). The License shall be deemed effective as
+of the date CC0 was applied by Affirmer to the Work. Should any part of the
+License for any reason be judged legally invalid or ineffective under
+applicable law, such partial invalidity or ineffectiveness shall not
+invalidate the remainder of the License, and in such case Affirmer hereby
+affirms that he or she will not (i) exercise any of his or her remaining
+Copyright and Related Rights in the Work or (ii) assert any associated claims
+and causes of action with respect to the Work, in either case contrary to
+Affirmer's express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+ surrendered, licensed or otherwise affected by this document.
+
+ b. Affirmer offers the Work as-is and makes no representations or warranties
+ of any kind concerning the Work, express, implied, statutory or otherwise,
+ including without limitation warranties of title, merchantability, fitness
+ for a particular purpose, non infringement, or the absence of latent or
+ other defects, accuracy, or the present or absence of errors, whether or not
+ discoverable, all to the greatest extent permissible under applicable law.
+
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+ that may apply to the Work or any use thereof, including without limitation
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
+ disclaims responsibility for obtaining any necessary consents, permissions
+ or other rights required for any use of the Work.
+
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+ party to this document and has no duty or obligation with respect to this
+ CC0 or use of the Work.
+
+For more information, please see
+
-- [zkWASM Playground](./zkWASM_Playground/README.md)
+This book is written to not only describe the architecture of the zkWASM but also to educate users about the process of generating a WASM application and proof generation.
-- [zkWASM](./zkWASM/README.md)
- - [Environment & Building](./zkWASM/Environment.md)
- - [Generating a Proof](./zkWASM/Setup_and_Proof.md)
+[See the book live](https://delphinuslab.github.io/Delphinus-Lab-Book/)
-- [zkWASM Host Circuits](./zkWASM_Host_Circuits/README.md)
- - [Circuits](./zkWASM_Host_Circuits/Circuits.md)
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000..5f83d89
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1,5 @@
+title: Delphinus Lab Book
+description: Documentation for the zkWasm.
+show_downloads: false
+google_analytics:
+theme: jekyll-theme-hacker
\ No newline at end of file
diff --git a/docs/_includes/head-custom-google-analytics.html b/docs/_includes/head-custom-google-analytics.html
new file mode 100644
index 0000000..8a3ae5c
--- /dev/null
+++ b/docs/_includes/head-custom-google-analytics.html
@@ -0,0 +1,10 @@
+{% if site.google_analytics %}
+
+{% endif %}
diff --git a/docs/_includes/head-custom-theme-colors.html b/docs/_includes/head-custom-theme-colors.html
new file mode 100644
index 0000000..a30e708
--- /dev/null
+++ b/docs/_includes/head-custom-theme-colors.html
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/docs/_includes/head-custom.html b/docs/_includes/head-custom.html
new file mode 100644
index 0000000..44cdb83
--- /dev/null
+++ b/docs/_includes/head-custom.html
@@ -0,0 +1,12 @@
+
+
+
+{% include head-custom-theme-colors.html %}
+
+
+{% include head-custom-google-analytics.html %}
+
+
+
+
+
diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html
new file mode 100644
index 0000000..1c8c883
--- /dev/null
+++ b/docs/_layouts/default.html
@@ -0,0 +1,38 @@
+
+
+
by {{ page.author | default: site.author }}
+ +{{content}} + +{% if page.tags %} + tags: {{ page.tags | join: " - " }} +{% endif %} diff --git a/docs/_sass/_default_colors.scss b/docs/_sass/_default_colors.scss new file mode 100644 index 0000000..52922ec --- /dev/null +++ b/docs/_sass/_default_colors.scss @@ -0,0 +1,15 @@ +$apple-blossom: #ac4142; +$alto: #d0d0d0; +$bouquet: #aa759f; +$chelsea-cucumber: #da7eec; +$cod-grey: #838282; +$conifer: #93b8e9; +$dove-grey: #666; +$gallery: #eaeaea; +$grey: #888; +$gulf-stream: #75b5aa; +$hippie-blue: #a7d0e2; +$potters-clay: #8f5536; +$rajah: #f4bf75; +$raw-sienna: #d28445; +$silver-chalice: #aaa; diff --git a/docs/_sass/hacker.scss b/docs/_sass/hacker.scss new file mode 100644 index 0000000..b535d24 --- /dev/null +++ b/docs/_sass/hacker.scss @@ -0,0 +1,4 @@ +// Placeholder file. If your site uses +// @import "{{ site.theme }}"; +// Then using this theme with jekyll-remote-theme will work fine. +@import "jekyll-theme-hacker"; diff --git a/docs/_sass/jekyll-theme-hacker.scss b/docs/_sass/jekyll-theme-hacker.scss new file mode 100644 index 0000000..99ed962 --- /dev/null +++ b/docs/_sass/jekyll-theme-hacker.scss @@ -0,0 +1,268 @@ +@import "rouge-base16-dark"; +@import "default_colors"; + +$body-background: $cod-grey !default; +$body-foreground: $gallery !default; +$header: $conifer !default; +$blockquote-color: $silver-chalice !default; +$blockquote-border: $dove-grey !default; +$container-max-width: 1000px; + +@mixin media-max-width($max-width) { + @media (max-width: $max-width) { + @content; + } +} + +body { + margin: 0; + padding: 0; + background: $body-background url("../images/bkg.png") 0 0; + color: $body-foreground; + font-size: 16px; + line-height: 1.5; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; +} + +/* General & 'Reset' Stuff */ + +.container { + width: 90%; + max-width: $container-max-width; + margin: 0 auto; +} + +section { + display: block; + margin: 0 0 20px 0; +} + +h1, h2, h3, h4, h5, h6 { + margin: 0 0 20px; +} + +li { + line-height: 1.4 ; +} + +/* Header,+ +
+ +Within the directory `./zkWasm/` with the program build using [environment setup](./Environment.md), run the setup stage of zkWasm with the input .wasm image (`ouput.wasm`) from above. + + +``` +mkdir output_simple_program +cargo run --release -- --function zkmain --output ./output_simple_program --wasm $HOME/zkWasm-C/tests/simple_program/output.wasm setup +``` + +This produces the output files in `./output_simple_program/` +``` +. +├── K18.params +├── K21.params +└── zkwasm.0.vkey.data +``` + + + +## Proof Phase: + +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).+ +
+ + +To generate a single proof using zkWasm using the wasm image from above `/simple_program/output.wasm` but this time we add a public input to the application `--public 112:i64`. + +Within zkWasm generate a single proof: + +```console +cargo run --release -- --function zkmain --output ./output_simple_program --wasm $HOME/zkWasm-C/tests/simple_program/output.wasm single-prove --public 112:i64 +``` + +This produces the following output in the output directory `--output ./output_simple_program`: + +``` +. +├── etable.json +├── external_host_table.json +├── imtable.json +├── itable.json +├── jtable.json +├── K18.params +├── K21.params +├── mtable.json +├── zkwasm.0.instance.data +├── zkwasm.0.transcript.data +└── zkwasm.0.vkey.data +``` + +The process of proof generation requires reading the `vkey.data` and `K.params` files generated in the previous Setup Phase, which is used as input to zkWasm which creates a proof outputting guest `transcript.data` (the proof) and `instance.data` (the public input). For the Gust virtual machine. Along side the Host virtual machine creates its own proof using the `host.vkey` and Host call trace, outputting host `transcript.data`.+ +
+ + + + + +## Poseidon Example: + +In the following we use the poseidon example from Delphinus Lab's zkWasm-C [repo](https://github.com/DelphinusLab/zkWasm-C) + +Using the make file generate `output.wasm` from within + +[back](./../../) \ No newline at end of file diff --git a/docs/docs_pages/zkWASM/assets/images/Deploy_Phase_wbg.png b/docs/docs_pages/zkWASM/assets/images/Deploy_Phase_wbg.png new file mode 100644 index 0000000..0c408ce Binary files /dev/null and b/docs/docs_pages/zkWASM/assets/images/Deploy_Phase_wbg.png differ diff --git a/docs/docs_pages/zkWASM/assets/images/Proof_Phase_wbg.png b/docs/docs_pages/zkWASM/assets/images/Proof_Phase_wbg.png new file mode 100644 index 0000000..1eabbbd Binary files /dev/null and b/docs/docs_pages/zkWASM/assets/images/Proof_Phase_wbg.png differ diff --git a/docs/docs_pages/zkWASM/assets/images/Setup_Phase_wbg.png b/docs/docs_pages/zkWASM/assets/images/Setup_Phase_wbg.png new file mode 100644 index 0000000..647e3b0 Binary files /dev/null and b/docs/docs_pages/zkWASM/assets/images/Setup_Phase_wbg.png differ diff --git a/docs/docs_pages/zkWASM_Host_Circuits/Circuits.md b/docs/docs_pages/zkWASM_Host_Circuits/Circuits.md new file mode 100644 index 0000000..306c914 --- /dev/null +++ b/docs/docs_pages/zkWASM_Host_Circuits/Circuits.md @@ -0,0 +1 @@ +# Circuits diff --git a/docs/docs_pages/zkWASM_Host_Circuits/Host_Circuits.md b/docs/docs_pages/zkWASM_Host_Circuits/Host_Circuits.md new file mode 100644 index 0000000..69c914d --- /dev/null +++ b/docs/docs_pages/zkWASM_Host_Circuits/Host_Circuits.md @@ -0,0 +1,180 @@ +--- +layout: default +--- + + +# zkWASM Host Circuits + + +## 1. Motivation +Customizable host circuits and host API is a key feature of DelphinusLab zkWASM which provides a way to support the WASM host API specification. + +In WASM, the user can provide runtime host functions and call those functions in WASM bytecode through function calls (see the following example). + +### Example of code calls host API: + +``` +extern void host_api_1(int x, int y, int z); +extern int host_api_2(int b); +int main(int a) { + if (a > 1) { + host_api_1(a,1,2); + } else { + int b = host_api_2(a); + host_api_1(b,2,1); + } + return; +} +``` +After compilation of the above code written in $C$ to WASM (or WAT) as follows. +``` + (import "env" "host_api_1" (func $host_api_1 (param i32 i32 i32))) + (import "env" "host_api_2" (func $host_api_2 (param i32) (result i32))) + (func $zkmain (; 2 ;) (param $0 i32) (result i32) + (block label + (br_if label (i32.lt_s (get_local $0) (i32.const 2))) + (call $host_api_1 (get_local $0) (i32.const 1) (i32.const 2)) + (return) + ) + (call $host_api_1 + (call $host_api_2 + (get_local $0) + ) + (i32.const 2) + (i32.const 1) + ) + return + ) +) +``` + +We notice that the host APIs (host_api_1 & host_api_2) are not implemented by wasm but provided by the host env. Delphinus ZKWasm supports the host environment by providing host functions to the WASM Emulator if the host environment can provide two things: +1. The witness of host API outputs. +2. The circuit that can prove the host API outputs and inputs enforces the semantics. + +The witness generated for host API outputs is used for the WASM Emulator so that the WASM Emulator can continue to generate execution traces for the ZKWasm guest prover. However since the ZKWasm guest prover can only prove the bytecode of WASM, it can not prove that the witness (outputs and inputs of host API calls) are valid. To solve this problem, We introduce a host VM that can leverage the host API circuit to prove that the witness of host API calls are valid. In the end, the Delphinus ZKWasm proof batcher combines the proof of both the guest and host to generate a final proof (see the proof generation architecture below).+ +
+ +When the proof batching circuit combines the proofs from the guest circuit and host circuit, it checks two things: +1. Each proof checks. +2. The host API call traces are the same both in the guest circuit and in the host circuit. + + +## 2. Restriction of customizable circuits for host API. +Some customizable circuits might have dynamic input sizes. For example, one might want to provide a host circuit of multi-scalar multiplication (MSM) that can process arbitrary numbers of elliptic curve cryptography (ECC) point addition. + +``` +ecc_add(ECCPoint *points, ECCPoint *) +``` + +However, WASM doesn't provide specifications for the host to access guest memory. Therefore we require the host env to track the mutable context of the host API itself. i.e., the host env should not change the memory or the stack. In addition, during the execution of a WASM image, multiple host APIs might be called in an undecided order. Because one specific host circuit might only have the ability to prove one specific host API, we provide the following architecture to utilize all the host circuits to work together to prove the correctness of a host API calling trace. + + +## 3. The architecture of Host VM. +The host VM usually contains three gates the selecting gate, the processing gate, and the operation gate. + +### Selecting Gate: +The selecting gate contains two tables. The shared operands table contains all the host operations called during the guest zkWASM VM trace and the selected operands table contains the operation that can be processed in the current host circuit. + +#### Example: Shared operand table + +| op_code | arg | idx | +| --------|-----| ----| +| 0 | 0 | 0 | +| op_a | a_0 | 1 | +| op_a | a_1 | 2 | +| op_a | a_r | 3 | +| sum_in | b_0 | 4 | +| sum_in | b_1 | 5 | +| sum_in | b_2 | 6 | +| sum_ret | b_3 | 7 | +| sum_in | b_4 | 8 | +| sum_in | b_5 | 9 | +| sum_ret | b_6 | 10 | + +#### Example: Selected operand table +| op_code | arg | idx_sel | +| --------|-------- | --------| +| sum_in | $b_0$ | 4 | +| sum_in | $b_1$ | 5 | +| sum_in | $b_2$ | 6 | +| sum_ret | $b_3$ | 7 | +| sum_in | $b_5$ | 8 | +| sum_in | $b_6$ | 9 | +| sum_ret | $b_7$ | 10 | + +### Processing Gate: +The processing gate needs to be a uniform gate that has uniform constraints for all opcodes that are handled in the current circuits. + +For example, in the hash circuit, there are three opcodes: **hash_cont**, **hash_push** and **hash_finalize**. The construction of the processing gate is as following: + +| advice | advice | advice | advice | advice | advice | fix | +|--------|--------|--------|--------|--------|--------|-----| +| operand| opcode | idx | m_operand | merge_ind | trans_ind | start | +| nil | opcode_n | idx_n | nil | nil | trans_ind_n | nil | + + +Suppose that in the zkWASM guest execution trace, there is the following shared host api calling trace: + +| op_code | arg | idx | +| --------|-----| ----| +| 0 | 0 | 0 | +| op_a | a_0 | 1 | +| op_a | a_1 | 2 | +| op_a | a_r | 3 | +| hash_reset | true | 4 | +| hash_push | b_1 | 5 | +| hash_reset | false | 6 | +| hash_push | b_2 | 7 | +| hash_finalize | b_3 | 8 | +| op_b | b_0 | 9 | +| op_b | b_1 | 10 | +| op_b | b_r | 11 | +| hash_reset | true | 12 | +| hash_push | h_4 | 13 | +| hash_reset | false | 14 | +| hash_push | h_5 | 15 | +| hash_reset | false | 16 | +| hash_push | h_6 | 17 | +| hash_reset | false | 18 | +| hash_push | h_7 | 19 | +| hash_finalize | h_8 | 20 | + +The processing gate picks all the hash-related ops into itself through lookup constraints and calculates the selected operand, opcode, idx and the derived trans_ind. + +| operand| opcode | idx | m_operand | merge_ind | trans_ind | +|--------|-----------|--------|-----------|-----------|-----------| +| true | hash_reset| 4 | true | 0 | 0 | +| b_1 | hash_push | 5 | b1 | 0 | 0 | +| false | hash_reset| 6 | false | 0 | 1 | +| b_2 | hash_push | 7 | b2 | 0 | 1 | +| b_3 | hash_final| 8 | b3 | 0 | 1 | +| true | hash_reset| 12 | true | 0 | 2 | +| h_4 | hash_push | 13 | h_4 | 0 | 2 | +| false | hash_reset| 14 | false | 0 | 3 | +| h_5 | hash_push | 15 | h_5 | 0 | 3 | +| flase | hash_reset| 16 | false | 0 | 4 | +| h_6 | hash_push | 17 | h_6 | 0 | 4 | +| flase | hash_reset| 16 | false | 0 | 5 | +| h_7 | hash_push | 17 | h_7 | 0 | 5 | +| h_8 | hash_final| 18 | h_8 | 0 | 5 | + +## Operation Gate: +The operation gate is the universal state transformation circuit that encodes the host function as a state transformation. + ++ +
+ +Each state transformation can contain multiple configuration and observation points which form a one-one relation between the operation gate and the processing gate. E.g., if we take the hash host circuit to be a state tranformation that has one configuration point; **hash_reset**, which indicates whether the start transform needs to be reset, and one observation point; **hash_final** which ensures the result of the hash is equal to the operand of **hash_final**. + +[back](./../../) \ No newline at end of file diff --git a/docs/docs_pages/zkWASM_Host_Circuits/assets/images/Guest_Host_Batched_Proof.png b/docs/docs_pages/zkWASM_Host_Circuits/assets/images/Guest_Host_Batched_Proof.png new file mode 100644 index 0000000..5a9107f Binary files /dev/null and b/docs/docs_pages/zkWASM_Host_Circuits/assets/images/Guest_Host_Batched_Proof.png differ diff --git a/docs/docs_pages/zkWASM_Host_Circuits/assets/images/universal_operation_gate.png b/docs/docs_pages/zkWASM_Host_Circuits/assets/images/universal_operation_gate.png new file mode 100644 index 0000000..c5f1fb7 Binary files /dev/null and b/docs/docs_pages/zkWASM_Host_Circuits/assets/images/universal_operation_gate.png differ diff --git a/docs/docs_pages/zkWASM_Playground/README.md b/docs/docs_pages/zkWASM_Playground/README.md new file mode 100644 index 0000000..ded80a0 --- /dev/null +++ b/docs/docs_pages/zkWASM_Playground/README.md @@ -0,0 +1,200 @@ +--- +layout: default +--- + +# zkWASM Playground + +The [Delphinus Lab Service Explorer](https://zkwasm-explorer.delphinuslab.com/) provides a convenient user interface to: + +1. Submit Web Assembly images where zkWasm generates zkSNARK circuits for the image. +2. Prove a Web Assembly image execution. +3. Deploy a verification contract on an Ethereum Testnet. + +To interact with Delphinus Lab service [install metamask](https://metamask.io/download/) as a browser extension and obtain some testnet coins. + ++ +
+ + +Paste the below example C source in to [WasmFiddle](https://wasdk.github.io/WasmFiddle/) and hit the Build button in the top center of the page. + + +```C +unsigned long long wasm_input(int); // external host api for fetch user inputs. + +int zkmain() { + int sum = wasm_input(1); + int b = sum + 2; + return b + 1; +} +``` + +Save the build application as `example.wasm` to a local directory on your machine. + +## Submitting a New Application: + +Using upper right task bar on [Delphinus Lab Service Explorer](https://zkwasm-explorer.delphinuslab.com/) click `Create New Application` and upload the `example.wasm` in the "Image ID (MD5)" field. + + +### Setup Phase: + ++ +
+ + + + ++ +
+ +You can see that the `TASK ID 64d09a94f0e3eee93f7e8e04` has moved from "Processing" to the "Done" state. + ++ +
+ ++ +
+ + + +Inspecting the task in the explorer shows the Application Image Hash: `B246F9E85B9D392B0A33374974A2CA23`, and the Setup phase Status as "Done". + ++ +
+ + +### Submit a Proof: + +At the top of the explorer, hit "Submit Prove Task", a new popup window will appear to create a new prove task. In the Image hash part input the application hash. In this example it is: `C0704FFA2384B360548789AD22911938`. With the image hash input the public input you can enter should be an integer 64-bit type, here for this example we are using the value 112, input: `112:i64`. + ++ +
+ +You can view the "Proof Info" details which contains the inputs, transcripts, auxiliary data (for batch field dividing in smart contracts) and instances of the proof batching circuits: + ++ +
+ + + + +### Deploying a Verification Contract: + +One the application has been Setup and has a Proof generated, a verification contract can be deployed on one of the Ethereum testnets. Hit the "Deploy Verification Contract" at the top of the explorer. Input the Image ID, in this case `C0704FFA2384B360548789AD22911938` and choose a test network to deploy to. Hit "Confirm". + + ++ +
+ +Sign the transaction and wait for the verification contract to be deployed. + ++ +
+ +In the main window of the explorer the deployment task can be seen as "Processing", + ++ +
+ +and after a short amount of time the status of this task is "Done". + ++ +
+ +The Deployment Info shows a "Details section" with the address of the contract, + + ++ +
+ ++ +
+ +This can be seen on etherscan: + ++ +
+ +With the verification contract deployed we can verify the proof on chain with the "Verify on Chain" facility. Within the proof section of the image in the explorer, select the Task ID for the proof, to view the proof task, then select "View Proof Info". + ++ +
+ +Hit the Verify on Chain button, sign the transaction, in some time the transaction receipt should should produce a successful on chain verification.+ +
+ +`Verification transaction successful! Transaction hash: 0x64f0c91ff3687541c674d9324a5869c9734f4729799869217e5640cda353f255` + + +[back](./../../) \ No newline at end of file diff --git a/docs/docs_pages/zkWASM_Playground/assets/example/example.wasm b/docs/docs_pages/zkWASM_Playground/assets/example/example.wasm new file mode 100644 index 0000000..0bc4270 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/example/example.wasm differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/0_metamask.png b/docs/docs_pages/zkWASM_Playground/assets/images/0_metamask.png new file mode 100644 index 0000000..a3bd595 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/0_metamask.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/1_taskbar.png b/docs/docs_pages/zkWASM_Playground/assets/images/1_taskbar.png new file mode 100644 index 0000000..785c870 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/1_taskbar.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/2_new_application.png b/docs/docs_pages/zkWASM_Playground/assets/images/2_new_application.png new file mode 100644 index 0000000..c327f0e Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/2_new_application.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_12_deploydone.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_12_deploydone.png new file mode 100644 index 0000000..d1c1be1 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_12_deploydone.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_13_deploymentinfo.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_13_deploymentinfo.png new file mode 100644 index 0000000..8a6dbc2 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_13_deploymentinfo.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_14_etherscan.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_14_etherscan.png new file mode 100644 index 0000000..30ede05 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_14_etherscan.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_15_proofinfo.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_15_proofinfo.png new file mode 100644 index 0000000..38abbaa Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_15_proofinfo.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_16_complete.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_16_complete.png new file mode 100644 index 0000000..3003f7a Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_16_complete.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_17_prooftranscripts.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_17_prooftranscripts.png new file mode 100644 index 0000000..58f57f9 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_17_prooftranscripts.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_3_applicatioprocessing.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_3_applicatioprocessing.png new file mode 100644 index 0000000..d071f78 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_3_applicatioprocessing.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone.png new file mode 100644 index 0000000..f6537b8 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone2.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone2.png new file mode 100644 index 0000000..6859dc4 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_4_applicationdone2.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_5_provedone.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_5_provedone.png new file mode 100644 index 0000000..8c4a200 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_5_provedone.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_6_deployverification.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_6_deployverification.png new file mode 100644 index 0000000..b9ebd0a Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_6_deployverification.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_7_sign.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_7_sign.png new file mode 100644 index 0000000..d2e463b Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_7_sign.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_8_deployprocessing.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_8_deployprocessing.png new file mode 100644 index 0000000..0d81f37 Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_8_deployprocessing.png differ diff --git a/docs/docs_pages/zkWASM_Playground/assets/images/test02_9_deploydone.png b/docs/docs_pages/zkWASM_Playground/assets/images/test02_9_deploydone.png new file mode 100644 index 0000000..d7701bd Binary files /dev/null and b/docs/docs_pages/zkWASM_Playground/assets/images/test02_9_deploydone.png differ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..a7ae470 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,29 @@ +--- +layout: default +--- + +Delphinus lab provides solutions for trustless computation and an application SDK based on a zkWasm virtual machine.