Moved to variables

This commit is contained in:
Uma Roy
2023-10-11 12:01:26 -07:00
parent 3b8611c6ac
commit 5d53737841
39 changed files with 180 additions and 177 deletions

View File

@@ -20,15 +20,15 @@ const BN254_SPONGE_WIDTH int = 4
const BN254_SPONGE_RATE int = 3
type BN254Chip struct {
api frontend.API `gnark:"-"`
gl gl.GoldilocksApi `gnark:"-"`
api frontend.API `gnark:"-"`
gl gl.Chip `gnark:"-"`
}
type BN254State = [BN254_SPONGE_WIDTH]frontend.Variable
type BN254HashOut = frontend.Variable
func NewBN254Chip(api frontend.API) *BN254Chip {
return &BN254Chip{api: api, gl: *gl.NewGoldilocksApi(api)}
return &BN254Chip{api: api, gl: *gl.New(api)}
}
func (c *BN254Chip) Poseidon(state BN254State) BN254State {

View File

@@ -16,12 +16,12 @@ type GoldilocksStateExtension = [SPONGE_WIDTH]gl.QuadraticExtensionVariable
type GoldilocksHashOut = [4]gl.Variable
type GoldilocksChip struct {
api frontend.API `gnark:"-"`
gl gl.GoldilocksApi `gnark:"-"`
api frontend.API `gnark:"-"`
gl gl.Chip `gnark:"-"`
}
func NewGoldilocksChip(api frontend.API) *GoldilocksChip {
return &GoldilocksChip{api: api, gl: *gl.NewGoldilocksApi(api)}
return &GoldilocksChip{api: api, gl: *gl.New(api)}
}
// The permutation function.

View File

@@ -25,7 +25,7 @@ func (circuit *TestPoseidonCircuit) Define(api frontend.API) error {
poseidonChip := NewGoldilocksChip(api)
output := poseidonChip.Poseidon(input)
glApi := gl.NewGoldilocksApi(api)
glApi := gl.New(api)
for i := 0; i < 12; i++ {
glApi.AssertIsEqual(output[i], gl.NewVariable(circuit.Out[i]))

View File

@@ -18,7 +18,7 @@ type TestPublicInputsHashCircuit struct {
}
func (circuit *TestPublicInputsHashCircuit) Define(api frontend.API) error {
glAPI := gl.NewGoldilocksApi(api)
glAPI := gl.New(api)
// BN254 -> Binary(64) -> F
var input [3]gl.Variable