Skip to content

cyjseagull/libzkg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libzkg Development Guide

FISCO-BCOS use libzkg to generate zero-knowledge proof for user and only governer can oversee it!

Notice: This is an experimental prototype. Do not use it in product.

Introductions

Background

Security is a basic deveping purpose of FISCO-BCOS.

  • For users, they need sheild transactions and anyone else couldn't know their transaction information running on blockchain.
  • For verifiers(FISCO-BCOS nodes), they need to verify all sheild transacitons, without knowing something of the shield transactions.
  • For goverments, they need to oversee everything happen on blockchain even the shield transactions!

Ideas

Libzkg is a zero-knowledge proof library based on FISCO-BCOS project.-

  • For users, they use libzkg to generate shield transactions, nobody else can know what's inside the transactions.
  • For verifiers, they can verify every shield transactions generated by libzkg without knowing something of the transactions.
  • For goverments, they can decode the shield transactions on blockchain and know what's happend.

Design

Libzkg is deveped for supporting zero-knowldge proof senarios of FISCO-BCOS.

Every senario supported by libzkg is based on this 3 principle:

  • User can generate a shield transaction according with the certain senario.
  • Verifier can verify the shield transaction without knowing the information of the transaction.
  • Goverment can decode every shield transaction on blockchain.

Supporting Senarios

  • Tx1to1: Shield money transfer from one to one.
  • Anonymous donation(developing)

waiting for more..

Compile Option

To import libzkg in your project. Cmake is recommended.

Prepare

sudo yum install -y procps-ng procps-ng-devel libgomp

Download

Download cmake file

wget https://github.com/FISCO-BCOS/FISCO-BCOS/blob/master/cmake/ProjectLibZkg.cmake
cp ProjectLibZkg.cmake your_project_dir/cmake/

CMakeLists.txt

Import in your CMakeLists.txt

vim  your_project_dir/CMakeLists.txt

like

cmake_minimum_required (VERSION 3.0.0)

set(ZKG_CLIENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory")
list(APPEND CMAKE_MODULE_PATH ${ZKG_CLIENT_CMAKE_DIR})

include(ProjectLibZkg)

find_package(OpenMP)
if(OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

include_directories(${LIBZKG_INCLUDE_DIR})

add_compile_options(-DMULTICORE)
add_compile_options(-std=c++11)
add_compile_options(-DCURVE_ALT_BN128)
add_compile_options(-DNO_PROCPS)
add_compile_options(-DBINARY_OUTPUT=OFF)

#aux_source_directory(. DIR_SRCS)

set(DEMO "demo")
add_executable(${DEMO} demo.cpp)

target_link_libraries(${DEMO} Zkg)
target_link_libraries(${DEMO} Zkg::circuit)
target_link_libraries(${DEMO} Zkg::snark)
target_link_libraries(${DEMO} Zkg::ff)
target_link_libraries(${DEMO} Zkg::zm)
target_link_libraries(${DEMO} gmp)
target_link_libraries(${DEMO} stdc++)
target_link_libraries(${DEMO} procps)
target_link_libraries(${DEMO} gmpxx)
target_link_libraries(${DEMO} gomp)

cpp files

Include zkg.hpp in your cpp file

#include <circuit/zkg.hpp>

Compile

mkdir build
cd build
cmake3 ..
make
#If success, libzkg.a is generated

Senario 1: tx1to1

consult with zkg.hpp and zkg-tx1to1

About

可监管的零知识证明库

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 85.1%
  • Assembly 6.1%
  • Python 5.6%
  • C 1.2%
  • CMake 0.6%
  • Makefile 0.5%
  • Other 0.9%