prover

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2022 License: AGPL-3.0 Imports: 7 Imported by: 12

README

go-rapidsnark

A go wrapper for the RapidSNARK C++ library.

To use this module you either need to have RapidSNARK library available on your build host or have one of the supported architectures to use vendored pre-built library for convenience use.

Build using pre-built vendored RapidSNARK library.

For few architectures, pre-built vendored libraries are included. And just use this module without any externally built dependencies except standard C/C++ libraries.

Supported architectures are:

  • MacOS x86_64
  • MacOS ARM64 Apple Silicon
  • Linux x86_64
  • Linux ARM64 v8

Minimum glibc version that should be available on build host is 2.31.

Also, you need a C/C++ compiler and standard libraries available. On Ubuntu it would be enough to install build-essential package. If you build your project using golang Docker container, all tools are already installed.

Usage on older hardware

Older x86_64 processors may lack support for ADX and BMI2 instruction sets used to optimize rapidsnark computations. To use this library on such processors on linux use rapidsnark_noasm build tag.

go build -tags rapidsnark_noasm
go test -tags rapidsnark_noasm

Build using custom RapidSNARK library.

You need gmp and rapidsnark libraries available on build host.

Supposed all needed files are in following directories:

  • prover.h is located in ${HOME}/src/rapidsnark/src
  • librapidsnark.a is located in ${HOME}/src/rapidsnark/build_prover/src
  • libgmp.a is located in ${HOME}/src/rapidsnark/depends/gmp/package/lib
export CGO_CFLAGS="-I${HOME}/src/rapidsnark/src" 
export CGO_LDFLAGS="-L${HOME}/src/rapidsnark/build_prover/src -L${HOME}/src/rapidsnark/depends/gmp/package/lib"
go build -tags dynamic

Tag dynamic is required to exclude usage of vendored libraries.

Examples

Library usage example is available in /cmd/proof/ directory.

Documentation

Index

Constants

View Source
const MaxBufferSize = 10485760

Variables

This section is empty.

Functions

func Groth16Prover

func Groth16Prover(zkey []byte,
	witness []byte) (proof *types.ZKProof, err error)

Groth16Prover generates proof and returns proof and pubsignals as types.ZKProof

func Groth16ProverRaw

func Groth16ProverRaw(zkey []byte,
	witness []byte) (proof string, publicInputs string, err error)

Groth16ProverRaw generates proof and returns proof and pubsignals as json string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL