From 83ca35c55b620addd178923f42051d542d91338a Mon Sep 17 00:00:00 2001 From: Shourya Goel Date: Fri, 28 Jun 2024 17:20:38 +0530 Subject: [PATCH] Revert "Integration test for Is_Zero (#494)" This reverts commit b5dac4caece7709f138d00ee0850354239e37dae. --- .github/workflows/integration-test.yml | 2 +- integration_tests/.env | 2 +- .../cairo_zero_hint_tests/is_zero.small.cairo | 31 ------------------- pkg/hintrunner/zero/hintcode.go | 2 +- pkg/hintrunner/zero/zerohint_ec.go | 7 ++--- 5 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 integration_tests/cairo_zero_hint_tests/is_zero.small.cairo diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index b788a923..f630180f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -18,7 +18,7 @@ jobs: python-version: '3.9' - name: Install cairo-lang - run: pip install cairo-lang==0.13.1 + run: pip install cairo-lang==0.11 - name: Build run: make build diff --git a/integration_tests/.env b/integration_tests/.env index b24a173e..8ffc5395 100644 --- a/integration_tests/.env +++ b/integration_tests/.env @@ -1,2 +1,2 @@ # Set to run some specific file tests (ex. fib.cairo,alloc.cairo) -INTEGRATION_TESTS_FILTERS=is_zero.small.cairo +INTEGRATION_TESTS_FILTERS= diff --git a/integration_tests/cairo_zero_hint_tests/is_zero.small.cairo b/integration_tests/cairo_zero_hint_tests/is_zero.small.cairo deleted file mode 100644 index c1d5e802..00000000 --- a/integration_tests/cairo_zero_hint_tests/is_zero.small.cairo +++ /dev/null @@ -1,31 +0,0 @@ -// Returns 1 if x == 0 (mod secp256k1_prime), and 0 otherwise. -// Serves as integration test for the following hints : -// isZeroNondetCode -// isZeroPackCode -// isZeroDivModCode - -%builtins range_check - -from starkware.cairo.common.cairo_secp.field import is_zero, SumBigInt3 - -func main{range_check_ptr}() -> () { - - // Test One - let a = SumBigInt3(0, 0, 0); - let (res: felt) = is_zero(a); - assert res = 1; - - // Test Two - let b = SumBigInt3(42, 0, 0); - let (res: felt) = is_zero(b); - assert res = 0; - - // Test Three - let c = SumBigInt3( - 77371252455336262886226991, 77371252455336267181195263, 19342813113834066795298815 - ); - let (res: felt) = is_zero(c); - assert res = 1; - - return (); -} diff --git a/pkg/hintrunner/zero/hintcode.go b/pkg/hintrunner/zero/hintcode.go index 45b54588..3df68b47 100644 --- a/pkg/hintrunner/zero/hintcode.go +++ b/pkg/hintrunner/zero/hintcode.go @@ -94,7 +94,7 @@ ids.multiplicities = segments.gen_arg([len(positions_dict[k]) for k in output])` ecDoubleAssignNewXV1Code string = "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack\n\nslope = pack(ids.slope, PRIME)\nx = pack(ids.point.x, PRIME)\ny = pack(ids.point.y, PRIME)\n\nvalue = new_x = (pow(slope, 2, SECP_P) - 2 * x) % SECP_P" ecDoubleAssignNewYV1Code string = "value = new_y = (slope * (x - new_x) - y) % SECP_P" ecMulInnerCode string = "memory[ap] = (ids.scalar % PRIME) % 2" - isZeroNondetCode string = "memory[ap] = to_felt_or_relocatable(x == 0)" + isZeroNondetCode string = "x == 0" isZeroPackCode string = "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack\n\nx = pack(ids.x, PRIME) % SECP_P" isZeroDivModCode string = "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P\nfrom starkware.python.math_utils import div_mod\n\nvalue = x_inv = div_mod(1, x, SECP_P)" diff --git a/pkg/hintrunner/zero/zerohint_ec.go b/pkg/hintrunner/zero/zerohint_ec.go index 62cdfc16..6d67362f 100644 --- a/pkg/hintrunner/zero/zerohint_ec.go +++ b/pkg/hintrunner/zero/zerohint_ec.go @@ -736,10 +736,9 @@ func createEcMulInnerHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // i.e, 1 if `x == 0`, 0 otherwise func newIsZeroNondetHint() hinter.Hinter { return &GenericZeroHinter{ - Name: "IsZeroNondet", + Name: "IsZeroConditional", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { - //> python hint in cairo file: "x == 0" - //> compiled file hint: "memory[ap] = to_felt_or_relocatable(x == 0)" + //> x == 0 x, err := ctx.ScopeManager.GetVariableValueAsBigInt("x") if err != nil { @@ -776,7 +775,6 @@ func newIsZeroPackHint(x hinter.ResOperander) hinter.Hinter { Name: "IsZeroPack", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { //> from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack - //> x = pack(ids.x, PRIME) % SECP_P xAddr, err := x.GetAddress(vm) @@ -831,7 +829,6 @@ func newIsZeroDivModHint() hinter.Hinter { Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { //> from starkware.cairo.common.cairo_secp.secp_utils import SECP_P //> from starkware.python.math_utils import div_mod - //> value = x_inv = div_mod(1, x, SECP_P) secPBig, ok := secp_utils.GetSecPBig()