From 275db6d6b1002eb63cc6607d70faaedfd28b48a1 Mon Sep 17 00:00:00 2001 From: ImmanuelSegol <3ditds@gmail.com> Date: Mon, 22 Jan 2024 11:33:25 +0100 Subject: [PATCH] refactor --- .prettierignore | 17 +++++++++++++++ .prettierrc | 10 +++++++++ docs/contributor-guide.md | 1 - docs/icicle/integrations.md | 7 +++---- docs/icicle/introduction.md | 23 ++++++++------------- docs/icicle/rust-bindings.md | 2 -- docs/icicle/supporting-additional-curves.md | 23 +++++++++------------ docs/introduction.md | 3 ++- package-lock.json | 18 ++++++++++++++++ package.json | 6 +++++- 10 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..984e656 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,17 @@ +.docusaurus/ +node_modules/ +yarn.lock +.DS_Store + +# tex build artifacts +.aux +.bbl +.bcf +.blg +.fdb_latexmk +.fls +.log +.out +.xml +.gz +.toc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c12b8c5 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "proseWrap": "preserve", + "endOfLine": "lf" +} diff --git a/docs/contributor-guide.md b/docs/contributor-guide.md index d369b40..8aec53b 100644 --- a/docs/contributor-guide.md +++ b/docs/contributor-guide.md @@ -21,4 +21,3 @@ When opening a [pull request](https://github.com/ingonyama-zk/icicle/pulls) plea ## Questions? Find us on [Discord](https://discord.gg/6vYrE7waPj). - diff --git a/docs/icicle/integrations.md b/docs/icicle/integrations.md index 513f703..90625df 100644 --- a/docs/icicle/integrations.md +++ b/docs/icicle/integrations.md @@ -2,7 +2,7 @@ ICICLE has been used by companies like [Celer Network](https://github.com/celer-network), [Gnark](https://github.com/Consensys/gnark) and others to accelerate their ZK proving pipeline. -Many of these integrations have been a collaboration between Ingonyama and the integrating company. We have learned a lot about designing GPU based ZK provers. +Many of these integrations have been a collaboration between Ingonyama and the integrating company. We have learned a lot about designing GPU based ZK provers. If you're interested in understanding these integrations better or learning how you can use ICICLE to accelerate your existing ZK proving pipeline this is the place for you. @@ -12,7 +12,7 @@ Lets illustrate an ICICLE integration, so you can understand the core API and de ![ICICLE architecture](../../static/img/architecture-high-level.png) -Engineers usually use a cryptography library to implement their ZK protocols. These libraries implement efficient primitives which are used as building blocks for the protocol; ICICLE is such a library. The difference is that ICICLE is designed from the start to run on GPUs; the Rust and Golang APIs abstract away all low level CUDA details. Our goal was to allow developers with no GPU experience to quickly get started with ICICLE. +Engineers usually use a cryptography library to implement their ZK protocols. These libraries implement efficient primitives which are used as building blocks for the protocol; ICICLE is such a library. The difference is that ICICLE is designed from the start to run on GPUs; the Rust and Golang APIs abstract away all low level CUDA details. Our goal was to allow developers with no GPU experience to quickly get started with ICICLE. A developer may use ICICLE with two main approaches in mind. @@ -61,7 +61,7 @@ To switch over to ICICLE proving, make sure to change the backend you are using, ``` // toggle on proofIci, err := groth16.Prove(ccs, pk, secretWitness, backend.WithIcicleAcceleration()) - + // toggle off proof, err := groth16.Prove(ccs, pk, secretWitness) ``` @@ -88,7 +88,6 @@ Your logs should look something like this if everything went as expected. You can reference the [Gnark docs](https://github.com/Consensys/gnark?tab=readme-ov-file#gpu-support) for further information. - ### Halo2 [Halo2](https://github.com/zkonduit/halo2) fork integrated with ICICLE for GPU acceleration. This means that you can run your existing Halo2 circuits with GPU acceleration just by activating a feature flag. diff --git a/docs/icicle/introduction.md b/docs/icicle/introduction.md index 42bb5e5..a570055 100644 --- a/docs/icicle/introduction.md +++ b/docs/icicle/introduction.md @@ -25,11 +25,10 @@ ICICLE Core would typically be compiled into a static library and used in a thir ### ICICLE Rust and Golang bindings - [ICICLE Rust bindings](https://github.com/ingonyama-zk/icicle/tree/main/wrappers/rust) -- [ICICLE Golang bindings](https://github.com/ingonyama-zk/icicle/tree/main/goicicle) +- [ICICLE Golang bindings](https://github.com/ingonyama-zk/icicle/tree/main/goicicle) These bindings allow you to easily use ICICLE in a Rust or Golang project. Setting up Golang bindings requires a bit of extra steps compared to the Rust bindings which utilize the `cargo build` tool. - ## Running ICICLE This guide assumes that you have a Linux or Windows machine with a Nvidia GPU installed. If you don't have access to a Nvidia GPU you can access one for free on [Google Colab](https://colab.google/). @@ -44,17 +43,15 @@ This guide assumes that you have a Linux or Windows machine with a Nvidia GPU in #### Optional Prerequisites -- Docker, latest version. +- Docker, latest version. - [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html) - If you don't wish to install these prerequisites you can follow this tutorial using a [ZK-Container](https://github.com/ingonyama-zk/icicle/blob/main/Dockerfile) (docker container). To learn more about using ZK-Containers [read this](../ZKContainers.md). ### Setting up ICICLE and running tests The objective of this guide is to make sure you can run the ICICLE Core, Rust and Golang tests. Achieving this will ensure you know how to setup ICICLE and run a ICICLE program. For simplicity, we will be using the ICICLE docker container as our environment, however, you may install the prerequisites on your machine and follow the same commands in your terminal. - #### Setting up our environment Lets begin by cloning the ICICLE repository: @@ -70,7 +67,7 @@ docker build -t icicle-demo . docker run -it --runtime=nvidia --gpus all --name icicle_container icicle-demo ``` -- `-it` runs the container in interactive mode with a terminal. +- `-it` runs the container in interactive mode with a terminal. - `--gpus all` Allocate all available GPUs to the container. You can also specify which GPUs to use if you don't want to allocate all. - `--runtime=nvidia` Use the NVIDIA runtime, necessary for GPU support. @@ -121,12 +118,11 @@ cmake --build build The output in `build` folder should include the static libraries for the compiled curve. - :::info Make sure to only use `-DBUILD_TESTS=ON` for running test as the archive output will only be available when `-DBUILD_TESTS=ON` is not supplied. ::: -To run the test +To run the test ``` cd build @@ -177,11 +173,10 @@ ICICLE examples can be found [here](https://github.com/ingonyama-zk/icicle-examp In each example directory, ZK-container files are located in a subdirectory `.devcontainer`. -* example-name/ - * .devcontainer/ - * Dockerfile - * devcontainer.json - +- example-name/ + - .devcontainer/ + - Dockerfile + - devcontainer.json Lets run one of our C++ examples, in this case the [MSM example](https://github.com/ingonyama-zk/icicle-examples/blob/main/c%2B%2B/msm/example.cu). @@ -230,7 +225,6 @@ static libraries can be loaded into memory once and used by multiple programs, r Lets review the Golang bindings since its a pretty verbose example (compared to rust which hides it pretty well) of using static libraries. Golang has a library named `CGO` which can be used to link static libraries. Here's a basic example on how you can use cgo to link these libraries: - ```go /* #cgo LDFLAGS: -L/path/to/shared/libs -lbn254 -lbls12_381 -lbls12_377 -lbw6_671 @@ -260,4 +254,5 @@ One of the core ideas behind ICICLE is that developers can gradually accelerate Therefore we offer adapters for various popular libraries, these adapters allow us to convert points and scalars between different formats defined by various libraries. Here is a list: Golang adapters: + - [Gnark crypto adapter](https://github.com/ingonyama-zk/iciclegnark) diff --git a/docs/icicle/rust-bindings.md b/docs/icicle/rust-bindings.md index ad82ff5..e52beae 100644 --- a/docs/icicle/rust-bindings.md +++ b/docs/icicle/rust-bindings.md @@ -25,12 +25,10 @@ If you wish to point to a specific ICICLE branch add `branch = " When you build your project ICICLE will be built as part of the build command. - # How do the rust bindings work? The rust bindings are just rust wrappers for ICICLE Core static libraries which can be compiled. We integrate the compilation of the static libraries into rusts toolchain to make usage seamless and easy. This is achieved by [extending rusts build command](https://github.com/ingonyama-zk/icicle/blob/main/wrappers/rust/icicle-curves/icicle-bn254/build.rs). - ```rust use cmake::Config; use std::env::var; diff --git a/docs/icicle/supporting-additional-curves.md b/docs/icicle/supporting-additional-curves.md index f0ed1fb..703805c 100644 --- a/docs/icicle/supporting-additional-curves.md +++ b/docs/icicle/supporting-additional-curves.md @@ -6,7 +6,6 @@ Supporting additional curves is still a work in progress and is bound to change ::: - We understand the need for ZK developers to use different curves, some common some more exotic. For this reason we designed ICICLE to allow developers to add any curve they desire. ## ICICLE Core @@ -45,21 +44,19 @@ In order to support a new curves in the binding libraries you first must support Create a new folder named `icicle-` under the [rust wrappers folder](https://github.com/ingonyama-zk/icicle/tree/main/wrappers/rust/icicle-curves). Your new directory should look like this. - -* icicle-/ - * src/ - * ntt/ - * mod.rs - * msm/ - * mod.rs - * curve.rs - * lib.rs - * Cargo.toml - * build.rs +- icicle-/ + - src/ + - ntt/ + - mod.rs + - msm/ + - mod.rs + - curve.rs + - lib.rs + - Cargo.toml + - build.rs Lets look at [`ntt/mod.rs`](https://github.com/ingonyama-zk/icicle/blob/main/wrappers/rust/icicle-curves/icicle-bn254/src/ntt/mod.rs) for example. - ``` ... diff --git a/docs/introduction.md b/docs/introduction.md index 5a7d27c..a7b011a 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -2,6 +2,7 @@ slug: / displayed_sidebar: GettingStartedSidebar --- + # Welcome to Ingonyama's Developer Documentation Ingonyama is a next-generation semiconductor company, focusing on Zero-Knowledge Proof hardware acceleration. We build accelerators for advanced cryptography, unlocking real-time applications. Our focus is on democratizing access to compute intensive cryptography and making it accessible for developers to build on top of. @@ -9,7 +10,7 @@ Ingonyama is a next-generation semiconductor company, focusing on Zero-Knowledge Currently our flagship products are: - **ICICLE**: -[ICICLE](https://github.com/ingonyama-zk/icicle) is a fully featured GPU accelerated cryptography library for building ZK provers. ICICLE allows you to accelerate your ZK existing protocols in a matter of hours or implement your protocol from scratch on GPU. + [ICICLE](https://github.com/ingonyama-zk/icicle) is a fully featured GPU accelerated cryptography library for building ZK provers. ICICLE allows you to accelerate your ZK existing protocols in a matter of hours or implement your protocol from scratch on GPU. --- diff --git a/package-lock.json b/package-lock.json index b0b1c36..2dd8cd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,9 @@ "react-dom": "^17.0.2", "rehype-katex": "5", "remark-math": "3" + }, + "devDependencies": { + "prettier": "^3.2.4" } }, "node_modules/@algolia/autocomplete-core": { @@ -9842,6 +9845,21 @@ "node": ">=4" } }, + "node_modules/prettier": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz", + "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-error": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", diff --git a/package.json b/package.json index 94a10c4..ff1e8bd 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "serve": "docusaurus serve", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "dev": "docusaurus start" + "dev": "docusaurus start", + "format": "prettier --write '**/*.md'" }, "dependencies": { "@docusaurus/core": "2.0.0-beta.18", @@ -40,5 +41,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "prettier": "^3.2.4" } }