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

Support icicle v2 add bw6761 #25

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
585 changes: 585 additions & 0 deletions backend/groth16/bn254/icicle/icicle.go

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions backend/groth16/bn254/icicle/noicicle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//go:build !icicle

package icicle_bn254

import (
"fmt"

"github.com/consensys/gnark/backend"
groth16_bn254 "github.com/consensys/gnark/backend/groth16/bn254"
"github.com/consensys/gnark/backend/witness"
cs "github.com/consensys/gnark/constraint/bn254"
)

const HasIcicle = false

func Prove(r1cs *cs.R1CS, pk *ProvingKey, fullWitness witness.Witness, opts ...backend.ProverOption) (*groth16_bn254.Proof, error) {
return nil, fmt.Errorf("icicle backend requested but program compiled without 'icicle' build tag")
}

func SetupDevicePointers(pk *ProvingKey) error {
fmt.Println("WARN: no icicle to use or load")
return nil
}
32 changes: 32 additions & 0 deletions backend/groth16/bn254/icicle/provingkey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package icicle_bn254

import (
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
groth16_bn254 "github.com/consensys/gnark/backend/groth16/bn254"
cs "github.com/consensys/gnark/constraint/bn254"
icicle_core "github.com/ingonyama-zk/icicle/v2/wrappers/golang/core"
)

type deviceInfo struct {
CosetGenerator [fr.Limbs * 2]uint32
G1Device struct {
A, B, K, Z icicle_core.DeviceSlice
}
G2Device struct {
B icicle_core.DeviceSlice
}
DenDevice icicle_core.DeviceSlice
}

type ProvingKey struct {
*groth16_bn254.ProvingKey
*deviceInfo
}

func Setup(r1cs *cs.R1CS, pk *ProvingKey, vk *groth16_bn254.VerifyingKey) error {
return groth16_bn254.Setup(r1cs, pk.ProvingKey, vk)
}

func DummySetup(r1cs *cs.R1CS, pk *ProvingKey) error {
return groth16_bn254.DummySetup(r1cs, pk.ProvingKey)
}
Loading
Loading