Skip to content

Commit

Permalink
refactor: public GkrPermutations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabaie committed Jan 29, 2025
1 parent d7c49f9 commit 909adbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions std/permutation/poseidon2/gkr.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,22 @@ func (g extGate) Degree() int {
return 1
}

type gkrPermutations struct {
type GkrPermutations struct {
api frontend.API
ins1 []frontend.Variable
ins2 []frontend.Variable
outs []frontend.Variable
}

func newGkrPermutations(api frontend.API) *gkrPermutations {
res := gkrPermutations{
func NewGkrPermutations(api frontend.API) *GkrPermutations {
res := GkrPermutations{
api: api,
}
api.Compiler().Defer(res.finalize)
return &res
}

func (p *gkrPermutations) permute(a, b frontend.Variable) frontend.Variable {
func (p *GkrPermutations) Permute(a, b frontend.Variable) frontend.Variable {
s, err := p.api.Compiler().NewHint(permuteHint, 1, a, b)
if err != nil {
panic(err)
Expand All @@ -190,7 +190,7 @@ func frToInt(x *fr.Element) *big.Int {
return &res
}

func (p *gkrPermutations) finalize(api frontend.API) error {
func (p *GkrPermutations) finalize(api frontend.API) error {
if p.api != api {
panic("unexpected API")
}
Expand Down
4 changes: 2 additions & 2 deletions std/permutation/poseidon2/gkr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ type testGkrPermutationCircuit struct {

func (c *testGkrPermutationCircuit) Define(api frontend.API) error {

pos2 := newGkrPermutations(api)
pos2 := NewGkrPermutations(api)
api.AssertIsEqual(len(c.Ins), len(c.Outs))
for i := range c.Ins {
api.AssertIsEqual(c.Outs[i], pos2.permute(c.Ins[i][0], c.Ins[i][1]))
api.AssertIsEqual(c.Outs[i], pos2.Permute(c.Ins[i][0], c.Ins[i][1]))

}

Expand Down

0 comments on commit 909adbf

Please sign in to comment.