Skip to content

Commit

Permalink
Merge pull request #6 from NilFoundation/directly-include-parallel-zk
Browse files Browse the repository at this point in the history
Directly include parallel zk
  • Loading branch information
AndreyMlashkin authored Jun 10, 2024
2 parents 3227dd3 + 377ac7f commit 65629ea
Show file tree
Hide file tree
Showing 285 changed files with 65,437 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "libs/threaded-zk"]
path = libs/parallel-zk
url = [email protected]:NilFoundation/actor-zk
[submodule "cmake/modules"]
path = cmake/modules
url = [email protected]:BoostCMake/cmake_modules.git
1 change: 0 additions & 1 deletion libs/parallel-zk
Submodule parallel-zk deleted from 96e210
73 changes: 73 additions & 0 deletions libs/parallel-zk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 2.8.12)

cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0028 NEW)
cmake_policy(SET CMP0042 NEW)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0057 NEW)
cmake_policy(SET CMP0076 NEW)

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/packages"
"${CMAKE_CURRENT_LIST_DIR}/cmake/modules/share/modules/cmake")

include(CMConfig)
include(CMSetupVersion)

if(NOT CMAKE_WORKSPACE_NAME OR NOT ("${CMAKE_WORKSPACE_NAME}" STREQUAL "actor"))
cm_workspace(actor)
endif()

option(ZK_PLACEHOLDER_PROFILING_ENABLED "Build with placeholder profiling" FALSE)
option(ZK_PLACEHOLDER_DEBUG_ENABLED "Build with placeholder testing inside" FALSE)

if(ZK_PLACEHOLDER_PROFILING)
add_definitions(-DZK_PLACEHOLDER_PROFILING_ENABLED)
endif()

if(ZK_PLACEHOLDER_DEBUG)
add_definitions(-DZK_PLACEHOLDER_DEBUG_ENABLED)
endif()

cm_project(zk WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES C CXX)

if(NOT Boost_FOUND AND NOT CMAKE_CROSSCOMPILING)
find_package(Boost)
endif()

include(CMDeploy)
include(FindPkgConfig)

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>

$<$<BOOL:${Boost_FOUND}>:${Boost_INCLUDE_DIRS}>)

target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE

${Boost_LIBRARIES}

${CMAKE_WORKSPACE_NAME}::containers
${CMAKE_WORKSPACE_NAME}::core
${CMAKE_WORKSPACE_NAME}::math

crypto3::algebra
crypto3::block
crypto3::hash
crypto3::multiprecision)

cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
INCLUDE include
NAMESPACE ${CMAKE_WORKSPACE_NAME}::)

include(CMTest)
cm_add_test_subdirectory(test)
44 changes: 44 additions & 0 deletions libs/parallel-zk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Zero-Knowledge Cryptography Schemes for =nil; Foundation's Cryptography Suite

Zero-Knowledge cryptography schemes for =nil; Foundation's cryptography suite.
SNARK-alike schemes for now. More trivial Pedersen commitment schemes, STARKs,
IOP-based SNARKs, Bulletproofs etc in future.

[![Run tests](https://github.com/NilFoundation/crypto3-zk/actions/workflows/run_tests.yml/badge.svg)](https://github.com/NilFoundation/crypto3-zk/actions/workflows/run_tests.yml)

## Building

This library uses Boost CMake build modules (https://github.com/BoostCMake/cmake_modules.git). To actually include this
library in a project it is required to:

1. Add [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) as submodule to target project repository.
2. Add all the internal dependencies using [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) as
submodules to target project repository.
3. Initialize parent project with [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) (Look
at [crypto3](https://github.com/nilfoundation/crypto3.git) for the example)

## Updating from crypto3-zk repository
Update could be done either with `git format-patch` and `git am --3way --whitespace=fix --reject`, but this will lead to *.rej* files in case of conflicts.

To make it more merge-like, add `crypto3-zk` as upstream, and cherry-pick commits from it:
```bash
git remote add crypto3-zk [email protected]:NilFoundation/crypto3-zk.git
git fetch crypto3-zk
git cherry-pick <from_crypto3-zk_commit_sha>^..<to_crypto3-zk_commit_sha>
```
After transforming Crypto3 into monorepo subtree path should be specified:
```bash
git cherry-pick -Xsubtree=libs/zk <from_crypto3_commit_sha>^..<to_crypto3_commit_sha>
```

## Dependencies

### Internal

* [Multiprecision](https://github.com/nilfoundation/crypto3-multiprecision.git)
* [Algebra](https://github.com/nilfoundation/crypto3-algebra.git)
* [FFT](https://github.com/nilfoundation/crypto3-fft.git)

### External

* [Boost](https://boost.org) (>= 1.74)
87 changes: 87 additions & 0 deletions libs/parallel-zk/crypto3.zk.podspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "crypto3.zk",
"version": "0.1.0",
"summary": "=nil; Crypto3 C++ Cryptography Suite Cipher VDF",
"description": "Crypto3.VDF library extends the =nil; Foundation's cryptography suite and provides a set of verifiable delay functions implemented in way C++ standard library implies: concepts, algorithms, predictable behavior, latest standard features support and clean architecture without compromising security and performance.",
"homepage": "http://crypto3.nil.foundation/projects/crypto3",
"license": "Boost Software License",
"authors": {
"Mikhail Komarov": "[email protected]"
},
"platforms": {
"ios": "5.0",
"osx": "10.7"
},
"source": {
"git": "https://github.com/nilfoundation/vdf.git",
"branch": "master"
},
"xcconfig": {
"CLANG_CXX_LANGUAGE_STANDARD": "c++14",
"CLANG_CXX_LIBRARY": "libc++",
"HEADER_SEARCH_PATHS": "\"${PODS_ROOT}/include/\""
},
"subspecs": [
{
"name": "include",
"subspecs": [
{
"name": "nil",
"subspecs": [
{
"name": "crypto3",
"subspecs": [
{
"name": "detail",
"source_files": [
"include/nil/crypto3/detail/*.{hpp}"
]
},
{
"name": "vdf",
"source_files": [
"include/nil/crypto3/vdf/*.{hpp}"
],
"subspecs": [
{
"name": "algorithm",
"source_files": [
"include/nil/crypto3/vdf/algorithm/*.{hpp}"
]
},
{
"name": "adaptor",
"source_files": [
"include/nil/crypto3/vdf/adaptor/*.{hpp}"
]
},
{
"name": "accumulators",
"source_files": [
"include/nil/crypto3/vdf/accumulators/*.{hpp}"
],
"subspecs": [
{
"name": "parameters",
"source_files": [
"include/nil/crypto3/vdf/accumulators/parameters/*.{hpp}"
]
}
]
},
{
"name": "detail",
"source_files": [
"include/nil/crypto3/vdf/detail/*.{hpp}"
]
}
]
}
]
}
]
}
]
}
]
}
3 changes: 3 additions & 0 deletions libs/parallel-zk/docs/concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Concepts # {#zk_concepts}

@tableofcontents
3 changes: 3 additions & 0 deletions libs/parallel-zk/docs/implementation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Implementation # {#zk_impl}

@tableofcontents
7 changes: 7 additions & 0 deletions libs/parallel-zk/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Zero-Knowledge Proofs {#zk_index}

@subpage zk_introduction
@subpage zk_manual
@subpage zk_concepts
@subpage zk_impl
@subpage zk_perf
24 changes: 24 additions & 0 deletions libs/parallel-zk/docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Introduction # {#zk_introduction}

This module contains followings.

Relations:

* QAP - Quadratic Arithmetic Program
* SAP - Square Arithmetic Program
* SSP - Square Span Program
* BACS - Bilinear Arithmetic Circuit Satisfiability
* TBCS - Two-input Boolean Circuit Satisfiability
* R1CS - Rank-1 Constraint System
* USCS - Unitary-Square Constraint System

zk-SNARKS (Zero-Knowledge Succinct Non-interactive ARgument of Knowledge):

* bacs_ppzksnark- - BACS PreProcessing zk-SNARK
* r1cs_gg_ppzksnark - R1CS Generic Group PreProcessing zk-SNARK (Groth16)
* r1cs_ppzksnark - R1CS PreProcessing zk-SNARK
* r1cs_se_ppzksnark - R1CS Simulation-Extractable PreProcessing zk-SNARK
* tbcs_ppzksnark - TBCS PreProcessing zk-SNARK
* uscs_ppzksnark - USCS PreProcessing zk-SNARK

@tableofcontents
Loading

0 comments on commit 65629ea

Please sign in to comment.