From f1df68d7a85ae2960865e7929def0bd8afee72ea Mon Sep 17 00:00:00 2001 From: Tristan <122918260+TAdev0@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:54:33 +0200 Subject: [PATCH] `ecMulInner` integration test (#496) * ecMulInner * fmt * fmt * put alloc and hintref in right folder --- .../alloc.cairo | 0 .../cairo_zero_hint_tests/ec.small.cairo | 16 ++++++++++++++-- .../hintrefs.cairo | 0 pkg/hintrunner/zero/zerohint_ec.go | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) rename integration_tests/{cairo_zero_file_tests => cairo_zero_hint_tests}/alloc.cairo (100%) rename integration_tests/{cairo_zero_file_tests => cairo_zero_hint_tests}/hintrefs.cairo (100%) diff --git a/integration_tests/cairo_zero_file_tests/alloc.cairo b/integration_tests/cairo_zero_hint_tests/alloc.cairo similarity index 100% rename from integration_tests/cairo_zero_file_tests/alloc.cairo rename to integration_tests/cairo_zero_hint_tests/alloc.cairo diff --git a/integration_tests/cairo_zero_hint_tests/ec.small.cairo b/integration_tests/cairo_zero_hint_tests/ec.small.cairo index 6dd3d245..8559b753 100644 --- a/integration_tests/cairo_zero_hint_tests/ec.small.cairo +++ b/integration_tests/cairo_zero_hint_tests/ec.small.cairo @@ -1,8 +1,7 @@ %builtins range_check from starkware.cairo.common.cairo_secp.bigint import BigInt3 -from starkware.cairo.common.cairo_secp.ec import EcPoint, ec_negate, compute_doubling_slope, compute_slope, ec_double, fast_ec_add - +from starkware.cairo.common.cairo_secp.ec import EcPoint, ec_negate, compute_doubling_slope, compute_slope, ec_double, fast_ec_add, ec_mul_inner func test_ec_negate{range_check_ptr}() { let p = EcPoint(BigInt3(1, 2, 3), BigInt3(1, 2, 3)); let (res) = ec_negate(p); @@ -84,11 +83,24 @@ func test_fast_ec_add{range_check_ptr}() { return (); } +func test_ec_muller_inner{range_check_ptr}() { + let (pow2, res) = ec_mul_inner( + EcPoint( + BigInt3(65162296, 359657, 04862662171381), BigInt3(-5166641367474701, -63029418, 793) + ), + 123, + 298, + ); + + return (); +} + func main{range_check_ptr}() { test_ec_negate(); test_compute_doubling_slope(); test_compute_slope(); test_ec_double(); test_fast_ec_add(); + test_ec_muller_inner(); return (); } diff --git a/integration_tests/cairo_zero_file_tests/hintrefs.cairo b/integration_tests/cairo_zero_hint_tests/hintrefs.cairo similarity index 100% rename from integration_tests/cairo_zero_file_tests/hintrefs.cairo rename to integration_tests/cairo_zero_hint_tests/hintrefs.cairo diff --git a/pkg/hintrunner/zero/zerohint_ec.go b/pkg/hintrunner/zero/zerohint_ec.go index 2b582995..73469efe 100644 --- a/pkg/hintrunner/zero/zerohint_ec.go +++ b/pkg/hintrunner/zero/zerohint_ec.go @@ -718,6 +718,7 @@ func newEcMulInnerHint(scalar hinter.ResOperander) hinter.Hinter { resultFelt := new(fp.Element).SetBytes(resultUint256.Bytes()) resultMv := mem.MemoryValueFromFieldElement(resultFelt) apAddr := vm.Context.AddressAp() + return vm.Memory.WriteToAddress(&apAddr, &resultMv) }, }