-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 309-rework-fri
- Loading branch information
Showing
420 changed files
with
218,128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
include(CMConfig) | ||
include(CMSetupVersion) | ||
|
||
cm_project(blueprint WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES C CXX) | ||
|
||
include(CMDeploy) | ||
|
||
cm_setup_version(VERSION 0.1.0 PREFIX ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}) | ||
|
||
add_library(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE) | ||
|
||
set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES | ||
EXPORT_NAME ${CURRENT_PROJECT_NAME}) | ||
|
||
target_include_directories(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>) | ||
|
||
target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE | ||
${Boost_LIBRARIES} | ||
) | ||
|
||
cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} | ||
INCLUDE include | ||
NAMESPACE ${CMAKE_WORKSPACE_NAME}::) | ||
|
||
include(CMTest) | ||
cm_add_test_subdirectory(test) | ||
|
||
if(BUILD_EXAMPLES) | ||
add_subdirectory(example) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Circuit Definition Library for =nil; Foundation's Cryptography Suite | ||
|
||
[![Run tests](https://github.com/NilFoundation/zkllvm-blueprint/actions/workflows/run_tests.yml/badge.svg)](https://github.com/NilFoundation/zkllvm-blueprint/actions/workflows/run_tests.yml) | ||
|
||
## Dependencies | ||
|
||
- [Boost](https://boost.org) (>= 1.76) | ||
- [cmake](https://cmake.org/) (>=3.21.4) | ||
- Following dependencies must be built and installed from sources: | ||
- [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) | ||
- [crypto3](https://github.com/nilfoundation/crypto3.git) | ||
|
||
## Building and installation | ||
|
||
```bash | ||
cmake -B build -DCMAKE_INSTALL_PREFIX=/path/to/install | ||
make -C build install | ||
``` | ||
|
||
> Note: if you got an error on `find_package` during cmake configuration, make sure that you provided paths to the installed dependencies (for example, via `CMAKE_PREFIX_PATH` environment variable) | ||
## Nix support | ||
This repository provides Nix flake, so once you have installed Nix with flake support, you can use single command to fetch all the dependencies and build: | ||
|
||
```bash | ||
nix build ?submodules=1# | ||
``` | ||
|
||
To activate Nix development environment: | ||
|
||
```bash | ||
nix develop | ||
``` | ||
|
||
To run all tests: | ||
|
||
```bash | ||
nix flake check -L ?submodules=1# | ||
``` | ||
|
||
To build/develop/test with local crypto3 version, add an argument `--override-input nil-crypto3 /path/to/local/crypto3` to any of the above commands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Concepts # {#component_concepts} | ||
|
||
A ```circuit``` is defined by ```Blueprint``` and ```Blueprint assignment table``` (contains ```Blueprint public assignment table``` and ```Blueprint private assignment table```) instances. | ||
It consist of one or multiple components putted on these two. | ||
While ```Blueprint``` holds information about the circuit itself, its gates, constraints and other fixed expressions, ```Blueprint assignment table``` contains public and private assignments needed by zk-SNARK system. | ||
|
||
## Blueprint | ||
|
||
## PLONK component concept ## {##plonk_component_concepts} | ||
|
||
### PLONK Component interface ### | ||
|
||
A ```Component``` ```X``` is a state-less type with following static functions to operate with it: | ||
|
||
* ```X::allocate_rows``` - allocates required amount of rows in the given ```Arithmetization table```. The amount of required rows amount is constexpr for the particular component; | ||
* ```X::generate_circuit``` - generates gate expressions, copy constraints and lookup constraints and puts them on the given ```Blueprint```; | ||
* ```X::generate_assignments``` - evaluates assignments values and puts them on the given ```Blueprint assignment table```; | ||
|
||
Note that ```generate_circuit``` can modify of the ```Blueprint public assignment table``` setting ```Constant``` or ```Selector``` columns, but they don't use or set data of the ```Blueprint private assignment table```. The only function managing ```Blueprint private assignment table``` is ```generate_assignments``` - which, by the way, also can modify the ```Blueprint public assignment table```. In short, it looks like that: | ||
|
||
|Function |Required Input |Can modify | | ||
|-----------------------------|------------------------|-----------------------| | ||
|```X::allocate_rows``` |```Blueprint``` |```Blueprint```| | ||
|```X::generate_circuit``` |```Blueprint```, ```Component params```, ```Allocated data (auxiliary data for the component re-use)```, ```component start row``` |```Blueprint```, ```Allocated data```| | ||
|```X::generate_assignments``` |```Blueprint assignment table```, ```Component params```, ```component start row``` |```Blueprint assignment table```| | ||
|
||
The process of adding a component is following: | ||
|
||
1. (Optional) Get ```component``` start row by calling ```allocate_rows```. If the ```component``` is used as part of other ```component``` logic, it's not necessary to call the function, because needed rows are allocated by the master ```component```. | ||
2. (Optional) Allocate public input on the ```Blueprint assignment table``` via ```Blueprint assignment table::allocate_public_input```. | ||
3. Set all the gates and constraints on the ```Blueprint``` by calling ```generate_circuit```. ```Allocated data``` is being modified in process of the function working. | ||
4. Set all the assignments on the ```Blueprint assignment table``` table by calling ```generate_assignments```. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Extension {#blueprint_extension_manual} | ||
|
||
@tableofcontents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Blueprint (Circuit Definition Library) {#blueprint_index} | ||
|
||
@subpage blueprint_manual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Manual {#blueprint_manual} | ||
|
||
@subpage blueprint_usage_manual | ||
@subpage blueprint_extension_manual |
Oops, something went wrong.