From 118363e059a62e24252c49fabd35362ee98acb62 Mon Sep 17 00:00:00 2001 From: ruslan0012 <155269177+ruslan0012@users.noreply.github.com> Date: Thu, 19 Jun 2025 10:58:12 +0200 Subject: [PATCH 1/3] fix(hint): add input validation to dvHint function --- internal/backend/circuits/hint.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/backend/circuits/hint.go b/internal/backend/circuits/hint.go index 2489ce1eab..f975e71ea2 100644 --- a/internal/backend/circuits/hint.go +++ b/internal/backend/circuits/hint.go @@ -148,8 +148,21 @@ var make3 = func(_ *big.Int, inputs []*big.Int, result []*big.Int) error { } var dvHint = func(_ *big.Int, inputs []*big.Int, res []*big.Int) error { + // Check that inputs and outputs have the same length + if len(inputs) != len(res) { + return fmt.Errorf("dvHint: expected same length for inputs and results, got %d inputs and %d results", len(inputs), len(res)) + } + + // Ensure we have at least one input to process + if len(inputs) == 0 { + return fmt.Errorf("dvHint: no inputs provided") + } + two := big.NewInt(2) for i := range inputs { + if inputs[i] == nil { + return fmt.Errorf("dvHint: input at index %d is nil", i) + } res[i].Mul(two, inputs[i]) } return nil From 31a7d4521be92325a7296dc69e7bd1566fe64418 Mon Sep 17 00:00:00 2001 From: ruslan0012 <155269177+ruslan0012@users.noreply.github.com> Date: Thu, 19 Jun 2025 10:58:29 +0200 Subject: [PATCH 2/3] test: enable fuzzing for multi-output-hint test --- integration_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/integration_test.go b/integration_test.go index 95c2ccc926..4c2fb49a25 100644 --- a/integration_test.go +++ b/integration_test.go @@ -44,11 +44,6 @@ func TestIntegrationAPI(t *testing.T) { opts = append(opts, test.WithInvalidAssignment(tData.InvalidAssignments[i])) } - if name == "multi-output-hint" { - // TODO @gbotrel FIXME - opts = append(opts, test.NoFuzzing()) - } - assert.CheckCircuit(tData.Circuit, opts...) }, name) } From a536736ede4e9ece09111b2581312c144c5fd87f Mon Sep 17 00:00:00 2001 From: Ivo Kubjas Date: Mon, 23 Jun 2025 08:13:13 +0000 Subject: [PATCH 3/3] chore: gofmt --- internal/backend/circuits/hint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/backend/circuits/hint.go b/internal/backend/circuits/hint.go index f975e71ea2..93e88f124c 100644 --- a/internal/backend/circuits/hint.go +++ b/internal/backend/circuits/hint.go @@ -152,7 +152,7 @@ var dvHint = func(_ *big.Int, inputs []*big.Int, res []*big.Int) error { if len(inputs) != len(res) { return fmt.Errorf("dvHint: expected same length for inputs and results, got %d inputs and %d results", len(inputs), len(res)) } - + // Ensure we have at least one input to process if len(inputs) == 0 { return fmt.Errorf("dvHint: no inputs provided")