Skip to content

Commit 12a8dcb

Browse files
committed
chore: solidify RegisterGKRGates
1 parent 1ee4644 commit 12a8dcb

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

std/permutation/poseidon2/gkr.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,20 @@ var bls12377Permutation = sync.OnceValue(func() *poseidon2Bls12377.Permutation {
369369
return poseidon2Bls12377.NewPermutation(2, params.NbFullRounds, params.NbPartialRounds) // TODO @Tabaie add NewDefaultPermutation to gnark-crypto
370370
})
371371

372-
// TODO find better name
373-
// these are the fr gates
374-
func AddGkrGatesSolution() {
375-
csBls12377.RegisterHashBuilder("mimc", func() hash.Hash {
376-
return mimcBls12377.NewMiMC()
377-
})
378-
gkrPoseidon2Bls12377.RegisterGkrGates()
372+
// RegisterGKRGates registers the GKR gates corresponding to the given curves for the solver
373+
func RegisterGKRGates(curves ...ecc.ID) {
374+
if len(curves) == 0 {
375+
panic("expected at least one curve")
376+
}
377+
for _, curve := range curves {
378+
switch curve {
379+
case ecc.BLS12_377:
380+
csBls12377.RegisterHashBuilder("mimc", func() hash.Hash {
381+
return mimcBls12377.NewMiMC()
382+
})
383+
gkrPoseidon2Bls12377.RegisterGkrGates()
384+
default:
385+
panic(fmt.Sprintf("curve %s not currently supported", curve))
386+
}
387+
}
379388
}

std/permutation/poseidon2/gkr_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestGkrPermutation(t *testing.T) {
3434
Outs: outs,
3535
}
3636

37-
AddGkrGatesSolution()
37+
RegisterGKRGates(ecc.BLS12_377)
3838

3939
require.NoError(t, test.IsSolved(&circuit, &circuit, ecc.BLS12_377.ScalarField()))
4040
}

0 commit comments

Comments
 (0)