Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gnarkd): exposing gnark APIs through RPCs #54

Merged
merged 24 commits into from
Feb 9, 2021
Merged

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Jan 19, 2021

This is a placeholder.

cmd/gnarkd will expose through some gRPC APIs groth16.Prove and groth16.Verify. It will handle large circuits and large witness, and be easily callable from non-Go codebases.

--> gnarkd/README.md contents:
WARNING: this is an experimental feature and might not stay in gnark main repository in the future.

gnarkd

gnarkd is a gnark Proving / Verifying server.
It offers synchronous gRPC APIs (use when proving time & witness size are short) and asynchronous APIs.

See pb/gnardk.proto for up to date protobuf service description.

gRPC clients can be generated for multiple languages (Go, Rust, ...) see protoc doc for more info.
In go:

protoc --experimental_allow_proto3_optional --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative  pb/gnarkd.proto

Under the hood

When gnarkd starts, it loads the circuits defined in circuits/ folder. Circuits must be stored in a separate folder, under a curve subfolder.
Example:

  • circuits/bn256/cubic will contain cubic.pk, cubic.vk and cubic.r1cs.
  • CircuitID (as needed in the APIs) is then bn256/cubic

gnarkd listens on 2 distinct TCP connections: one for gRPC, one for receiving large witnesses on async calls.

On this second connection, the server expects: jobID | witness .

  • jobID is returned by CreateProveJob and is a standard UUID (RFC 4122) on 16 byte (server impl uses github.com/google/uuid)
  • gnarkd knows which witness size to expect (via r1cs.GetNbPublicWires, r1cs.GetNbSecretWires and r1cs.SizeFrElement)

Example client (Go)

See client/example.go.

@gbotrel gbotrel marked this pull request as ready for review February 2, 2021 01:15
@gbotrel gbotrel changed the title [WIP]: Adding gnarkd, exposing gnark APIs through RPCs Adding gnarkd, exposing gnark APIs through RPCs Feb 2, 2021
@gbotrel gbotrel changed the title Adding gnarkd, exposing gnark APIs through RPCs feat(gnarkd): exposing gnark APIs through RPCs Feb 9, 2021
@gbotrel gbotrel merged commit 110d326 into develop Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant