From b0eafc58a9d7e4c7ebe5de86dd985b4d89e7b672 Mon Sep 17 00:00:00 2001 From: gusanh Date: Mon, 12 Aug 2024 22:19:31 -0400 Subject: [PATCH] use only one randomness to work with circuit params (#17) --- examples/poseidon_m31/main.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/poseidon_m31/main.go b/examples/poseidon_m31/main.go index 4a2fb26..0b6ec6f 100644 --- a/examples/poseidon_m31/main.go +++ b/examples/poseidon_m31/main.go @@ -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]) } @@ -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) }