Skip to content

Commit

Permalink
use only one randomness to work with circuit params (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
gusanh authored Aug 13, 2024
1 parent 2b9c225 commit b0eafc5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions examples/poseidon_m31/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ const NumRepeat = 120
type MockPoseidonM31Circuit struct {
State [NumRepeat][16]frontend.Variable
Digest [NumRepeat]frontend.Variable `gnark:",public"`
Params *poseidon.PoseidonParams
}

func (c *MockPoseidonM31Circuit) Define(api frontend.API) (err error) {
// Define the circuit
param := poseidon.NewPoseidonParams()
engine := m31.Field{}
for i := 0; i < NumRepeat; i++ {
digest := poseidon.PoseidonCircuit(api, engine, param, c.State[i][:], true)
digest := poseidon.PoseidonCircuit(api, engine, c.Params, c.State[i][:], true)
api.AssertIsEqual(digest, c.Digest[i])
}

Expand Down Expand Up @@ -57,17 +57,15 @@ func M31CircuitBuild() {
assignment := &MockPoseidonM31Circuit{
State: stateVars,
Digest: outputVars,
Params: param,
}

// Gnark test disabled as it does not support randomness
// err := test.IsSolved(&MockPoseidonCircuit{}, assignment, m31.ScalarField)
// if err != nil {
// panic(err)
// }
// fmt.Println("Gnark test passed")

// Ecc test
circuit, err := ExpanderCompilerCollection.Compile(m31.ScalarField, &MockPoseidonM31Circuit{}, frontend.WithCompressThreshold(32))
circuit, err := ExpanderCompilerCollection.Compile(m31.ScalarField, &MockPoseidonM31Circuit{
State: stateVars,
Digest: outputVars,
Params: param,
}, frontend.WithCompressThreshold(32))
if err != nil {
panic(err)
}
Expand Down

0 comments on commit b0eafc5

Please sign in to comment.