From 839955a21aa20d30035312a1a05a2b18f65cf3b1 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 Date: Fri, 23 Aug 2024 07:09:22 +0530 Subject: [PATCH] Unit and Integration Tests pass --- pkg/hintrunner/core/cairo_hintparser.go | 6 +- pkg/hintrunner/core/hint.go | 182 +++++++++--------- pkg/hintrunner/hinter/utils.go | 6 +- pkg/hintrunner/zero/README.md | 2 +- .../zero/hint_reference_resolver.go | 8 +- pkg/hintrunner/zero/hintparser.go | 69 ++++--- pkg/hintrunner/zero/hintparser_test.go | 4 +- pkg/hintrunner/zero/zerohint.go | 2 +- pkg/hintrunner/zero/zerohint_blake.go | 10 +- pkg/hintrunner/zero/zerohint_dictionaries.go | 26 +-- pkg/hintrunner/zero/zerohint_ec.go | 48 ++--- pkg/hintrunner/zero/zerohint_keccak.go | 30 +-- pkg/hintrunner/zero/zerohint_math.go | 42 ++-- pkg/hintrunner/zero/zerohint_others.go | 22 +-- pkg/hintrunner/zero/zerohint_sha256.go | 6 +- pkg/hintrunner/zero/zerohint_signature.go | 10 +- pkg/hintrunner/zero/zerohint_test.go | 4 +- pkg/hintrunner/zero/zerohint_uint256.go | 22 +-- pkg/hintrunner/zero/zerohint_uint512.go | 2 +- pkg/hintrunner/zero/zerohint_usort.go | 6 +- pkg/hintrunner/zero/zerohint_utils.go | 6 +- 21 files changed, 264 insertions(+), 249 deletions(-) diff --git a/pkg/hintrunner/core/cairo_hintparser.go b/pkg/hintrunner/core/cairo_hintparser.go index e6c38fb7d..51bda93de 100644 --- a/pkg/hintrunner/core/cairo_hintparser.go +++ b/pkg/hintrunner/core/cairo_hintparser.go @@ -8,7 +8,7 @@ import ( "github.com/consensys/gnark-crypto/ecc/stark-curve/fp" ) -func parseCellRefer(cr starknet.CellRef) hinter.CellRefer { +func parseCellRefer(cr starknet.CellRef) hinter.Reference { switch cr.Register { case starknet.AP: return hinter.ApCellRef(cr.Offset) @@ -49,7 +49,7 @@ func parseBinOp(ro starknet.ResOperand) hinter.BinaryOp { a := hinter.Deref{ Deref: parseCellRefer(binOp.A), } - var b hinter.ResOperander = nil + var b hinter.Reference = nil switch binOp.B.Inner.(type) { case *starknet.Deref: b = &hinter.Deref{ @@ -74,7 +74,7 @@ func parseBinOp(ro starknet.ResOperand) hinter.BinaryOp { } } -func parseResOperand(ro starknet.ResOperand) hinter.ResOperander { +func parseResOperand(ro starknet.ResOperand) hinter.Reference { switch ro.Name { case starknet.DerefName: return parseDeref(ro) diff --git a/pkg/hintrunner/core/hint.go b/pkg/hintrunner/core/hint.go index 46a715b69..71b725f33 100644 --- a/pkg/hintrunner/core/hint.go +++ b/pkg/hintrunner/core/hint.go @@ -32,7 +32,7 @@ func GetCairoHints(cairoProgramJson *starknet.StarknetProgram) (map[uint64][]hin } type AllocSegment struct { - Dst hinter.CellRefer + Dst hinter.Reference } func (hint *AllocSegment) String() string { @@ -57,9 +57,9 @@ func (hint *AllocSegment) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerCon } type TestLessThan struct { - dst hinter.CellRefer - lhs hinter.ResOperander - rhs hinter.ResOperander + dst hinter.Reference + lhs hinter.Reference + rhs hinter.Reference } func (hint *TestLessThan) String() string { @@ -107,9 +107,9 @@ func (hint *TestLessThan) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerCon } type TestLessThanOrEqual struct { - dst hinter.CellRefer - lhs hinter.ResOperander - rhs hinter.ResOperander + dst hinter.Reference + lhs hinter.Reference + rhs hinter.Reference } func (hint *TestLessThanOrEqual) String() string { @@ -157,9 +157,9 @@ func (hint *TestLessThanOrEqual) Execute(vm *VM.VirtualMachine, _ *hinter.HintRu } type TestLessThanOrEqualAddress struct { - dst hinter.CellRefer - lhs hinter.ResOperander - rhs hinter.ResOperander + dst hinter.Reference + lhs hinter.Reference + rhs hinter.Reference } func (hint *TestLessThanOrEqualAddress) String() string { @@ -197,11 +197,11 @@ func (hint *TestLessThanOrEqualAddress) Execute(vm *VM.VirtualMachine, _ *hinter } type LinearSplit struct { - value hinter.ResOperander - scalar hinter.ResOperander - maxX hinter.ResOperander - x hinter.CellRefer - y hinter.CellRefer + value hinter.Reference + scalar hinter.Reference + maxX hinter.Reference + x hinter.Reference + y hinter.Reference } func (hint LinearSplit) String() string { @@ -281,10 +281,10 @@ func (hint LinearSplit) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerConte } type WideMul128 struct { - lhs hinter.ResOperander - rhs hinter.ResOperander - high hinter.CellRefer - low hinter.CellRefer + lhs hinter.Reference + rhs hinter.Reference + high hinter.Reference + low hinter.Reference } func (hint *WideMul128) String() string { @@ -355,10 +355,10 @@ func (hint *WideMul128) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerConte } type DivMod struct { - lhs hinter.ResOperander - rhs hinter.ResOperander - quotient hinter.CellRefer - remainder hinter.CellRefer + lhs hinter.Reference + rhs hinter.Reference + quotient hinter.Reference + remainder hinter.Reference } func (hint DivMod) String() string { @@ -438,16 +438,16 @@ func (hint DivMod) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) e } type U256InvModN struct { - B0 hinter.ResOperander - B1 hinter.ResOperander - N0 hinter.ResOperander - N1 hinter.ResOperander - G0OrNoInv hinter.CellRefer - G1Option hinter.CellRefer - SOrR0 hinter.CellRefer - SOrR1 hinter.CellRefer - TOrK0 hinter.CellRefer - TOrK1 hinter.CellRefer + B0 hinter.Reference + B1 hinter.Reference + N0 hinter.Reference + N1 hinter.Reference + G0OrNoInv hinter.Reference + G1Option hinter.Reference + SOrR0 hinter.Reference + SOrR1 hinter.Reference + TOrK0 hinter.Reference + TOrK1 hinter.Reference } func (hint U256InvModN) String() string { @@ -665,14 +665,14 @@ func (hint U256InvModN) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerConte } type Uint256DivMod struct { - dividend0 hinter.ResOperander - dividend1 hinter.ResOperander - divisor0 hinter.ResOperander - divisor1 hinter.ResOperander - quotient0 hinter.CellRefer - quotient1 hinter.CellRefer - remainder0 hinter.CellRefer - remainder1 hinter.CellRefer + dividend0 hinter.Reference + dividend1 hinter.Reference + divisor0 hinter.Reference + divisor1 hinter.Reference + quotient0 hinter.Reference + quotient1 hinter.Reference + remainder0 hinter.Reference + remainder1 hinter.Reference } func (hint Uint256DivMod) String() string { @@ -789,8 +789,8 @@ func (hint Uint256DivMod) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerCon } type DebugPrint struct { - start hinter.ResOperander - end hinter.ResOperander + start hinter.Reference + end hinter.Reference } func (hint DebugPrint) String() string { @@ -840,8 +840,8 @@ func (hint DebugPrint) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerContex } type SquareRoot struct { - value hinter.ResOperander - dst hinter.CellRefer + value hinter.Reference + dst hinter.Reference } func (hint *SquareRoot) String() string { @@ -880,13 +880,13 @@ func (hint *SquareRoot) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerConte } type Uint256SquareRoot struct { - valueLow hinter.ResOperander - valueHigh hinter.ResOperander - sqrt0 hinter.CellRefer - sqrt1 hinter.CellRefer - remainderLow hinter.CellRefer - remainderHigh hinter.CellRefer - sqrtMul2MinusRemainderGeU128 hinter.CellRefer + valueLow hinter.Reference + valueHigh hinter.Reference + sqrt0 hinter.Reference + sqrt1 hinter.Reference + remainderLow hinter.Reference + remainderHigh hinter.Reference + sqrtMul2MinusRemainderGeU128 hinter.Reference } func (hint Uint256SquareRoot) String() string { @@ -1037,7 +1037,7 @@ func (hint Uint256SquareRoot) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunne // type AllocFelt252Dict struct { - SegmentArenaPtr hinter.ResOperander + SegmentArenaPtr hinter.Reference } func (hint *AllocFelt252Dict) String() string { @@ -1091,8 +1091,8 @@ func (hint *AllocFelt252Dict) Execute(vm *VM.VirtualMachine, ctx *hinter.HintRun } type Felt252DictEntryInit struct { - DictPtr hinter.ResOperander - Key hinter.ResOperander + DictPtr hinter.Reference + Key hinter.Reference } func (hint Felt252DictEntryInit) String() string { @@ -1123,8 +1123,8 @@ func (hint *Felt252DictEntryInit) Execute(vm *VM.VirtualMachine, ctx *hinter.Hin } type Felt252DictEntryUpdate struct { - DictPtr hinter.ResOperander - Value hinter.ResOperander + DictPtr hinter.Reference + Value hinter.Reference } func (hint Felt252DictEntryUpdate) String() string { @@ -1159,8 +1159,8 @@ func (hint *Felt252DictEntryUpdate) Execute(vm *VM.VirtualMachine, ctx *hinter.H } type GetSegmentArenaIndex struct { - DictIndex hinter.CellRefer - DictEndPtr hinter.ResOperander + DictIndex hinter.Reference + DictEndPtr hinter.Reference } func (hint *GetSegmentArenaIndex) String() string { @@ -1192,10 +1192,10 @@ func (hint *GetSegmentArenaIndex) Execute(vm *VM.VirtualMachine, ctx *hinter.Hin // type InitSquashData struct { - FirstKey hinter.CellRefer - BigKeys hinter.CellRefer - DictAccesses hinter.ResOperander - NumAccesses hinter.ResOperander + FirstKey hinter.Reference + BigKeys hinter.Reference + DictAccesses hinter.Reference + NumAccesses hinter.Reference } func (hint *InitSquashData) String() string { @@ -1274,7 +1274,7 @@ func (hint *InitSquashData) Execute(vm *VM.VirtualMachine, ctx *hinter.HintRunne } type GetCurrentAccessIndex struct { - RangeCheckPtr hinter.ResOperander + RangeCheckPtr hinter.Reference } func (hint *GetCurrentAccessIndex) String() string { @@ -1299,7 +1299,7 @@ func (hint *GetCurrentAccessIndex) Execute(vm *VM.VirtualMachine, ctx *hinter.Hi } type ShouldSkipSquashLoop struct { - ShouldSkipLoop hinter.CellRefer + ShouldSkipLoop hinter.Reference } func (hint *ShouldSkipSquashLoop) String() string { @@ -1325,7 +1325,7 @@ func (hint *ShouldSkipSquashLoop) Execute(vm *VM.VirtualMachine, ctx *hinter.Hin } type GetCurrentAccessDelta struct { - IndexDeltaMinusOne hinter.CellRefer + IndexDeltaMinusOne hinter.Reference } func (hint *GetCurrentAccessDelta) String() string { @@ -1356,7 +1356,7 @@ func (hint *GetCurrentAccessDelta) Execute(vm *VM.VirtualMachine, ctx *hinter.Hi } type ShouldContinueSquashLoop struct { - ShouldContinue hinter.CellRefer + ShouldContinue hinter.Reference } func (hint *ShouldContinueSquashLoop) String() string { @@ -1381,7 +1381,7 @@ func (hint *ShouldContinueSquashLoop) Execute(vm *VM.VirtualMachine, ctx *hinter } type GetNextDictKey struct { - NextKey hinter.CellRefer + NextKey hinter.Reference } func (hint *GetNextDictKey) String() string { @@ -1404,18 +1404,18 @@ func (hint *GetNextDictKey) Execute(vm *VM.VirtualMachine, ctx *hinter.HintRunne } type Uint512DivModByUint256 struct { - dividend0 hinter.ResOperander - dividend1 hinter.ResOperander - dividend2 hinter.ResOperander - dividend3 hinter.ResOperander - divisor0 hinter.ResOperander - divisor1 hinter.ResOperander - quotient0 hinter.CellRefer - quotient1 hinter.CellRefer - quotient2 hinter.CellRefer - quotient3 hinter.CellRefer - remainder0 hinter.CellRefer - remainder1 hinter.CellRefer + dividend0 hinter.Reference + dividend1 hinter.Reference + dividend2 hinter.Reference + dividend3 hinter.Reference + divisor0 hinter.Reference + divisor1 hinter.Reference + quotient0 hinter.Reference + quotient1 hinter.Reference + quotient2 hinter.Reference + quotient3 hinter.Reference + remainder0 hinter.Reference + remainder1 hinter.Reference } func (hint Uint512DivModByUint256) String() string { @@ -1577,8 +1577,8 @@ func (hint Uint512DivModByUint256) Execute(vm *VM.VirtualMachine, _ *hinter.Hint } type AllocConstantSize struct { - Size hinter.ResOperander - Dst hinter.CellRefer + Size hinter.Reference + Dst hinter.Reference } func (hint *AllocConstantSize) String() string { @@ -1611,9 +1611,9 @@ func (hint *AllocConstantSize) Execute(vm *VM.VirtualMachine, ctx *hinter.HintRu } type AssertLeFindSmallArc struct { - A hinter.ResOperander - B hinter.ResOperander - RangeCheckPtr hinter.ResOperander + A hinter.Reference + B hinter.Reference + RangeCheckPtr hinter.Reference } func (hint *AssertLeFindSmallArc) String() string { @@ -1729,7 +1729,7 @@ func (hint *AssertLeFindSmallArc) Execute(vm *VM.VirtualMachine, ctx *hinter.Hin } type AssertLeIsFirstArcExcluded struct { - SkipExcludeAFlag hinter.CellRefer + SkipExcludeAFlag hinter.Reference } func (hint *AssertLeIsFirstArcExcluded) String() string { @@ -1757,7 +1757,7 @@ func (hint *AssertLeIsFirstArcExcluded) Execute(vm *VM.VirtualMachine, ctx *hint } type AssertLeIsSecondArcExcluded struct { - SkipExcludeBMinusA hinter.CellRefer + SkipExcludeBMinusA hinter.Reference } func (hint *AssertLeIsSecondArcExcluded) String() string { @@ -1785,8 +1785,8 @@ func (hint *AssertLeIsSecondArcExcluded) Execute(vm *VM.VirtualMachine, ctx *hin } type RandomEcPoint struct { - x hinter.CellRefer - y hinter.CellRefer + x hinter.Reference + y hinter.Reference } func (hint *RandomEcPoint) String() string { @@ -1844,8 +1844,8 @@ func (hint *RandomEcPoint) Execute(vm *VM.VirtualMachine, _ *hinter.HintRunnerCo } type FieldSqrt struct { - val hinter.ResOperander - sqrt hinter.CellRefer + val hinter.Reference + sqrt hinter.Reference } func (hint *FieldSqrt) String() string { diff --git a/pkg/hintrunner/hinter/utils.go b/pkg/hintrunner/hinter/utils.go index e6a559f17..61db2a1b2 100644 --- a/pkg/hintrunner/hinter/utils.go +++ b/pkg/hintrunner/hinter/utils.go @@ -8,7 +8,7 @@ import ( f "github.com/consensys/gnark-crypto/ecc/stark-curve/fp" ) -func ResolveAsAddress(vm *VM.VirtualMachine, op ResOperander) (*mem.MemoryAddress, error) { +func ResolveAsAddress(vm *VM.VirtualMachine, op Reference) (*mem.MemoryAddress, error) { mv, err := op.Resolve(vm) if err != nil { return nil, fmt.Errorf("%s: %w", op, err) @@ -22,7 +22,7 @@ func ResolveAsAddress(vm *VM.VirtualMachine, op ResOperander) (*mem.MemoryAddres return addr, nil } -func ResolveAsFelt(vm *VM.VirtualMachine, op ResOperander) (*f.Element, error) { +func ResolveAsFelt(vm *VM.VirtualMachine, op Reference) (*f.Element, error) { mv, err := op.Resolve(vm) if err != nil { return nil, fmt.Errorf("%s: %w", op, err) @@ -36,7 +36,7 @@ func ResolveAsFelt(vm *VM.VirtualMachine, op ResOperander) (*f.Element, error) { return felt, nil } -func ResolveAsUint64(vm *VM.VirtualMachine, op ResOperander) (uint64, error) { +func ResolveAsUint64(vm *VM.VirtualMachine, op Reference) (uint64, error) { mv, err := op.Resolve(vm) if err != nil { return 0, fmt.Errorf("%s: %w", op, err) diff --git a/pkg/hintrunner/zero/README.md b/pkg/hintrunner/zero/README.md index 83015ec94..0eede83d7 100644 --- a/pkg/hintrunner/zero/README.md +++ b/pkg/hintrunner/zero/README.md @@ -36,7 +36,7 @@ type Hinter interface { so to make this process easier we've created a generic structure `GenericZeroHinter` that will allow you to pass on all the information needed. It will look something like this: ``` -func newAssert250bitsHint(low, high, value hinter.ResOperander) hinter.Hinter { +func newAssert250bitsHint(low, high, value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Assert250bits", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/hint_reference_resolver.go b/pkg/hintrunner/zero/hint_reference_resolver.go index 1d06c8baf..3e8d9b288 100644 --- a/pkg/hintrunner/zero/hint_reference_resolver.go +++ b/pkg/hintrunner/zero/hint_reference_resolver.go @@ -35,24 +35,24 @@ func (m *hintReferenceResolver) GetReference(name string) (hinter.Reference, err // GetResOperander returns the result of GetReference type-asserted to ResOperander. // If reference is not found or is not of ResOperander type, a non-nil error is returned. -func (m *hintReferenceResolver) GetResOperander(name string) (hinter.ResOperander, error) { +func (m *hintReferenceResolver) GetResOperander(name string) (hinter.Reference, error) { ref, err := m.GetReference(name) if err != nil { return nil, err } - op, ok := ref.(hinter.ResOperander) + op, ok := ref.(hinter.Reference) if !ok { return nil, fmt.Errorf("expected %s to be ResOperander (got %T)", name, ref) } return op, nil } -func (m *hintReferenceResolver) GetCellRefer(name string) (hinter.CellRefer, error) { +func (m *hintReferenceResolver) GetCellRefer(name string) (hinter.Reference, error) { ref, err := m.GetReference(name) if err != nil { return nil, err } - op, ok := ref.(hinter.CellRefer) + op, ok := ref.(hinter.Reference) if !ok { return nil, fmt.Errorf("expected %s to be CellRefer (got %T)", name, ref) } diff --git a/pkg/hintrunner/zero/hintparser.go b/pkg/hintrunner/zero/hintparser.go index 40ae81551..63e22e306 100644 --- a/pkg/hintrunner/zero/hintparser.go +++ b/pkg/hintrunner/zero/hintparser.go @@ -140,7 +140,9 @@ func (expression DerefCastExp) Evaluate() (hinter.Reference, error) { } switch result := value.(type) { - case hinter.CellRefer: + case hinter.ApCellRef: + return hinter.Deref{Deref: result}, nil + case hinter.FpCellRef: return hinter.Deref{Deref: result}, nil case hinter.Deref: return hinter.DoubleDeref{ @@ -176,7 +178,7 @@ func (expression ArithExp) Evaluate() (hinter.Reference, error) { return nil, err } - if leftResult, ok := leftExp.(hinter.CellRefer); ok { + if leftResult, ok := leftExp.(hinter.ApCellRef); ok { // Binary Operation does not support CellRef in the left hand side // so the expression has to follow the pattern: // reg + off + off + ... + off @@ -199,16 +201,35 @@ func (expression ArithExp) Evaluate() (hinter.Reference, error) { off = -off } - switch cellRef := leftResult.(type) { - case hinter.ApCellRef: - oldOffset := int16(cellRef) - leftResult = hinter.ApCellRef(off + oldOffset) - continue - case hinter.FpCellRef: - oldOffset := int16(cellRef) - leftResult = hinter.FpCellRef(off + oldOffset) - continue + oldOffset := int16(leftResult) + leftResult = hinter.ApCellRef(off + oldOffset) + } + return leftResult, nil + } else if leftResult, ok := leftExp.(hinter.FpCellRef); ok { + // Binary Operation does not support CellRef in the left hand side + // so the expression has to follow the pattern: + // reg + off + off + ... + off + for _, term := range expression.AddExp { + rightExp, err := term.TermExp.Evaluate() + if err != nil { + return nil, err } + rightResult, ok := rightExp.(hinter.Immediate) + if !ok { + return nil, fmt.Errorf("invalid arithmetic expression") + } + + off, ok := utils.Int16FromFelt((*fp.Element)(&rightResult)) + if !ok { + return nil, fmt.Errorf("invalid arithmetic expression") + } + + if term.Operator == "-" { + off = -off + } + + oldOffset := int16(leftResult) + leftResult = hinter.FpCellRef(off + oldOffset) } return leftResult, nil } else { @@ -223,17 +244,11 @@ func (expression ArithExp) Evaluate() (hinter.Reference, error) { return nil, err } - if leftResult, ok := leftExp.(hinter.ResOperander); ok { - if rightResult, ok := rightExp.(hinter.ResOperander); ok { - leftExp = hinter.BinaryOp{ - Operator: op, - Lhs: leftResult, - Rhs: rightResult, - } - continue - } + leftExp = hinter.BinaryOp{ + Operator: op, + Lhs: leftExp, + Rhs: rightExp, } - return nil, fmt.Errorf("invalid arithmetic expression") } return leftExp, nil } @@ -261,8 +276,8 @@ func (expression ProdExp) Evaluate() (hinter.Reference, error) { return nil, err } - if leftOp, ok := leftExp.(hinter.ResOperander); ok { - if rightOp, ok := rightExp.(hinter.ResOperander); ok { + if leftOp, ok := leftExp.(hinter.Reference); ok { + if rightOp, ok := rightExp.(hinter.Reference); ok { return hinter.BinaryOp{ Operator: hinter.Mul, Lhs: leftOp, @@ -292,7 +307,7 @@ func (expression Expression) Evaluate() (hinter.Reference, error) { } } -func (expression CellRefSimple) Evaluate() (hinter.CellRefer, error) { +func (expression CellRefSimple) Evaluate() (hinter.Reference, error) { if expression.RegisterOffset != nil { return expression.RegisterOffset.Evaluate() } @@ -300,7 +315,7 @@ func (expression CellRefSimple) Evaluate() (hinter.CellRefer, error) { return EvaluateRegister(expression.Register, 0) } -func (expression CellRefExp) Evaluate() (hinter.CellRefer, error) { +func (expression CellRefExp) Evaluate() (hinter.Reference, error) { if expression.RegisterOffset != nil { return expression.RegisterOffset.Evaluate() } @@ -308,7 +323,7 @@ func (expression CellRefExp) Evaluate() (hinter.CellRefer, error) { return EvaluateRegister(expression.Register, 0) } -func (expression RegisterOffset) Evaluate() (hinter.CellRefer, error) { +func (expression RegisterOffset) Evaluate() (hinter.Reference, error) { offsetValue, _ := expression.Offset.Evaluate() offset, ok := utils.Int16FromBigInt(offsetValue) if !ok { @@ -321,7 +336,7 @@ func (expression RegisterOffset) Evaluate() (hinter.CellRefer, error) { return EvaluateRegister(expression.Register, offset) } -func EvaluateRegister(register string, offset int16) (hinter.CellRefer, error) { +func EvaluateRegister(register string, offset int16) (hinter.Reference, error) { switch register { case "ap": return hinter.ApCellRef(offset), nil diff --git a/pkg/hintrunner/zero/hintparser_test.go b/pkg/hintrunner/zero/hintparser_test.go index 260fc3516..8e1ab4979 100644 --- a/pkg/hintrunner/zero/hintparser_test.go +++ b/pkg/hintrunner/zero/hintparser_test.go @@ -10,8 +10,8 @@ import ( func TestHintParser(t *testing.T) { type testSetType struct { Parameter string - ExpectedCellRefer hinter.CellRefer - ExpectedResOperander hinter.ResOperander + ExpectedCellRefer hinter.Reference + ExpectedResOperander hinter.Reference } testSet := []testSetType{ diff --git a/pkg/hintrunner/zero/zerohint.go b/pkg/hintrunner/zero/zerohint.go index b599cc90a..a98c26109 100755 --- a/pkg/hintrunner/zero/zerohint.go +++ b/pkg/hintrunner/zero/zerohint.go @@ -391,7 +391,7 @@ func createTestAssignHinter(resolver hintReferenceResolver) (hinter.Hinter, erro return nil, err } - a, ok := arg.(hinter.ResOperander) + a, ok := arg.(hinter.Reference) if !ok { return nil, fmt.Errorf("expected a ResOperander reference") } diff --git a/pkg/hintrunner/zero/zerohint_blake.go b/pkg/hintrunner/zero/zerohint_blake.go index 0c7e8b264..c23d986c8 100644 --- a/pkg/hintrunner/zero/zerohint_blake.go +++ b/pkg/hintrunner/zero/zerohint_blake.go @@ -21,7 +21,7 @@ import ( // // `newBlake2sAddUint256Hint` splits each part of the `uint256` in 4 `u32` and writes the result in memory // This hint is available in Big-Endian or Little-Endian representation -func newBlake2sAddUint256Hint(low, high, data hinter.ResOperander, bigend bool) hinter.Hinter { +func newBlake2sAddUint256Hint(low, high, data hinter.Reference, bigend bool) hinter.Hinter { name := "Blake2sAddUint256" if bigend { name += "Bigend" @@ -125,7 +125,7 @@ func createBlake2sAddUint256Hinter(resolver hintReferenceResolver, bigend bool) // - `blake2sPtrEnd` is a pointer to the address where to write the result // // There are 3 versions of Blake2sFinalize hint, this implementation corresponds to V1 and V2 -func newBlake2sFinalizeHint(blake2sPtrEnd hinter.ResOperander) hinter.Hinter { +func newBlake2sFinalizeHint(blake2sPtrEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Blake2sFinalize", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -211,7 +211,7 @@ func createBlake2sFinalizeHinter(resolver hintReferenceResolver) (hinter.Hinter, // // There are 3 versions of Blake2sFinalize hint, this is the V3 implementation, with a slightly // modification in the way padding is done compared to V1 and V2 -func newBlake2sFinalizeV3Hint(blake2sPtrEnd hinter.ResOperander) hinter.Hinter { +func newBlake2sFinalizeV3Hint(blake2sPtrEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Blake2sFinalizeV3", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -295,7 +295,7 @@ func createBlake2sFinalizeV3Hinter(resolver hintReferenceResolver) (hinter.Hinte // - `output` should point to the middle of an instance, right after initial_state, message, t, f, // which should all have a value at this point, and right before the output portion which will be // written by this function. -func newBlake2sComputeHint(output hinter.ResOperander) hinter.Hinter { +func newBlake2sComputeHint(output hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Blake2sCompute", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -437,7 +437,7 @@ func createBlake2sComputeHinter(resolver hintReferenceResolver) (hinter.Hinter, // written by this function. // - `blake2s_start` should point to the middle of an instance, right after initial_state, message, t, f, // which should all have a value at this point. -func newBlake2sCompressHint(nBytes, output, blake2sStart hinter.ResOperander) hinter.Hinter { +func newBlake2sCompressHint(nBytes, output, blake2sStart hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Blake2sCompress", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_dictionaries.go b/pkg/hintrunner/zero/zerohint_dictionaries.go index 1c7bbc78c..bce76c19a 100644 --- a/pkg/hintrunner/zero/zerohint_dictionaries.go +++ b/pkg/hintrunner/zero/zerohint_dictionaries.go @@ -78,7 +78,7 @@ func createDictNewHinter() (hinter.Hinter, error) { // `newDefaultDictNewHint` takes 1 operander as argument // - `default_value` variable will be the default value // returned for keys not present in the dictionary -func newDefaultDictNewHint(defaultValue hinter.ResOperander) hinter.Hinter { +func newDefaultDictNewHint(defaultValue hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DefaultDictNew", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -131,7 +131,7 @@ func createDefaultDictNewHinter(resolver hintReferenceResolver) (hinter.Hinter, // - `dictPtr` variable will be pointer to the dictionary to read from // - `key` variable represents the key we are accessing the dictionary with // - `value` variable will hold the value of the dictionary stored at key after the hint is run -func newDictReadHint(dictPtr, key, value hinter.ResOperander) hinter.Hinter { +func newDictReadHint(dictPtr, key, value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DictRead", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -196,7 +196,7 @@ func createDictReadHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // - `dict_accesses_end` variable is a memory address that allows access to the dictionary // // `newDictSquashCopyDictHint`assigns `initial_dict` to the retrieved dictionary in the current scope -func newDictSquashCopyDictHint(dictAccessesEnd hinter.ResOperander) hinter.Hinter { +func newDictSquashCopyDictHint(dictAccessesEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DictSquashCopyDict", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -268,7 +268,7 @@ func createDictSquashCopyDictHinter(resolver hintReferenceResolver) (hinter.Hint // - `dictPtr` variable will be pointer to the dictionary to update // - `key` variable will be the key whose value is updated in the dictionary // - `newValue` variable will be the new value for given key in the dictionary -func newDictWriteHint(dictPtr, key, newValue hinter.ResOperander) hinter.Hinter { +func newDictWriteHint(dictPtr, key, newValue hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DictWrite", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -349,7 +349,7 @@ func createDictWriteHinter(resolver hintReferenceResolver) (hinter.Hinter, error // - `newValue` variable will be the new value for given `key` in the dictionary // - `prevValue` variable will be the old value for given `key` in the dictionary // which will be asserted before the update -func newDictUpdateHint(dictPtr, key, newValue, prevValue hinter.ResOperander) hinter.Hinter { +func newDictUpdateHint(dictPtr, key, newValue, prevValue hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DictUpdate", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -445,7 +445,7 @@ func createDictUpdateHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // - `nAccesses` variable will have a value indicating the number of times the dict was accessed // - `bigKeys` variable will be written a value of 1 if the keys used are bigger than the range_check and 0 otherwise // - `firstKey` variable will be written the value of the largest used key after the hint is run -func newSquashDictHint(dictAccesses, ptrDiff, nAccesses, bigKeys, firstKey hinter.ResOperander) hinter.Hinter { +func newSquashDictHint(dictAccesses, ptrDiff, nAccesses, bigKeys, firstKey hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDict", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -644,7 +644,7 @@ func createSquashDictInnerAssertLenKeysHinter() (hinter.Hinter, error) { // `newSquashDictInnerCheckAccessIndexHint` writes to the first field `index_delta_minus1` // of the `loop_temps` struct the result of `new_access_index - current_access_index - 1` // and assigns `new_access_index` to `current_access_index` in the scope -func newSquashDictInnerCheckAccessIndexHint(loopTemps hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerCheckAccessIndexHint(loopTemps hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerCheckAccessIndex", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -721,7 +721,7 @@ func createSquashDictInnerCheckAccessIndexHinter(resolver hintReferenceResolver) // // `newSquashDictInnerContinueLoopHint`writes 0 or 1 in the `should_continue` field // depending on whether the `current_access_indices` array contains items or not -func newSquashDictInnerContinueLoopHint(loopTemps hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerContinueLoopHint(loopTemps hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerContinueLoop", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -768,7 +768,7 @@ func createSquashDictInnerContinueLoopHinter(resolver hintReferenceResolver) (hi // // `newSquashDictInnerFirstIterationHint`writes `current_access_index` at `rangeCheckPtr` // offset in the execution segment of memory -func newSquashDictInnerFirstIterationHint(rangeCheckPtr hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerFirstIterationHint(rangeCheckPtr hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerFirstIteration", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -839,7 +839,7 @@ func createSquashDictInnerFirstIterationHinter(resolver hintReferenceResolver) ( // // `newSquashDictInnerSkipLoopHint` writes 0 or 1 in the `should_skip_loop`variable // depending on whether the `current_access_indices` array contains items or not -func newSquashDictInnerSkipLoopHint(shouldSkipLoop hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerSkipLoopHint(shouldSkipLoop hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerSkipLoop", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -911,7 +911,7 @@ func createSquashDictInnerLenAssertHinter() (hinter.Hinter, error) { // // `newSquashDictInnerNextKeyHint` takes 1 operander as argument // - `next_key` variable will be assigned to the next key in `keys` -func newSquashDictInnerNextKeyHint(nextKey hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerNextKeyHint(nextKey hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerNextKey", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -968,7 +968,7 @@ func createSquashDictInnerNextKeyHinter(resolver hintReferenceResolver) (hinter. // // `newSquashDictInnerUsedAccessesAssertHint` takes one operander as argument // - `nUsedAccesses` represents the number of used accesses for a given key -func newSquashDictInnerUsedAccessesAssertHint(nUsedAccesses hinter.ResOperander) hinter.Hinter { +func newSquashDictInnerUsedAccessesAssertHint(nUsedAccesses hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SquashDictInnerUsedAccessesAssert", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1014,7 +1014,7 @@ func createSquashDictInnerUsedAccessesAssertHinter(resolver hintReferenceResolve // `newDictSquashUpdatePtrHint` takes two operanders as arguments // - `squashed_dict_start` pointer to the dictionary whose current_ptr should be updated // - `squashed_dict_end` new current_ptr of the dictionary -func newDictSquashUpdatePtrHint(squashedDictStart, squashedDictEnd hinter.ResOperander) hinter.Hinter { +func newDictSquashUpdatePtrHint(squashedDictStart, squashedDictEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DictSquashUpdatePtr", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_ec.go b/pkg/hintrunner/zero/zerohint_ec.go index 1c62afd51..1500dad52 100644 --- a/pkg/hintrunner/zero/zerohint_ec.go +++ b/pkg/hintrunner/zero/zerohint_ec.go @@ -20,7 +20,7 @@ import ( // - `len_hi`: the variable that will store the result of the bit-length calculation // - `scalar_u.d2`: the first scalar value // - `scalar_v.d2`: the second scalar value -func newGetHighLenHint(len_hi, scalar_u, scalar_v hinter.ResOperander) hinter.Hinter { +func newGetHighLenHint(len_hi, scalar_u, scalar_v hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "GetHighLen", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -93,7 +93,7 @@ func createGetHighLenHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // `newBigIntToUint256Hint` takes 2 operanders as arguments // - `low` is the variable that will store the low part of the uint256 result // - `x` is the BigInt variable to convert to uint256 -func newBigIntToUint256Hint(low, x hinter.ResOperander) hinter.Hinter { +func newBigIntToUint256Hint(low, x hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "BigIntToUint256", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -165,7 +165,7 @@ func createBigIntToUint256Hinter(resolver hintReferenceResolver) (hinter.Hinter, // - `point` is the point on an elliptic curve to operate on // // `newEcNegateHint` assigns the result as `value` in the current scope -func newEcNegateHint(point hinter.ResOperander) hinter.Hinter { +func newEcNegateHint(point hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcNegate", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -278,7 +278,7 @@ func createDivModNSafeDivPlusOneHinter() (hinter.Hinter, error) { // - `b` is the value that will be packed and taken prime // // `DivModNPackedDivModExternalN` assigns the result as `value` in the current scope. -func newDivModNPackedDivModExternalN(a, b hinter.ResOperander) hinter.Hinter { +func newDivModNPackedDivModExternalN(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DivModNPackedDivModExternalN", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -355,7 +355,7 @@ func createDivModNPackedDivModExternalNHinter(resolver hintReferenceResolver) (h // - `res` is the location in memory where to write the result // // `newNondetBigint3V1Hint` uses `SecPSplit` to split the value in 3 felts and writes the result in memory -func newNondetBigint3V1Hint(res hinter.ResOperander) hinter.Hinter { +func newNondetBigint3V1Hint(res hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "NondetBigint3V1", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -423,7 +423,7 @@ func createNondetBigint3V1Hinter(resolver hintReferenceResolver) (hinter.Hinter, // V1 uses Secp256k1 curve // V2 uses Curve25519 curve with SECP_P = 2**255 - 19 // V3 is similar to V1 but uses `pt0` and `pt1` for operanders where V1 and V2 use `point0` and `point1` -func newFastEcAddAssignNewXHint(slope, point0, point1 hinter.ResOperander, secPBig big.Int) hinter.Hinter { +func newFastEcAddAssignNewXHint(slope, point0, point1 hinter.Reference, secPBig big.Int) hinter.Hinter { return &GenericZeroHinter{ Name: "FastEcAddAssignNewX", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -658,7 +658,7 @@ func createFastEcAddAssignNewYHinter() (hinter.Hinter, error) { // - `point` is the point on an elliptic curve to operate on // // `newEcDoubleSlopeV1Hint` assigns the `slope` result as `value` in the current scope -func newEcDoubleSlopeV1Hint(point hinter.ResOperander) hinter.Hinter { +func newEcDoubleSlopeV1Hint(point hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcDoubleSlopeV1", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -740,7 +740,7 @@ func createEcDoubleSlopeV1Hinter(resolver hintReferenceResolver) (hinter.Hinter, // This version differs from EcDoubleSlopeV1 by the name of the operander (`point` for V1, `pt` for V3) // and the computation of the slope : V1 uses a dedicated utility function with an additionnal check // while V3 executes the modular division directly -func newEcDoubleSlopeV3Hint(point hinter.ResOperander) hinter.Hinter { +func newEcDoubleSlopeV3Hint(point hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcDoubleSlopeV3", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -816,7 +816,7 @@ func createEcDoubleSlopeV3Hinter(resolver hintReferenceResolver) (hinter.Hinter, // // `newReduceHint` assigns the result as `value` in the current scope // This implementation is valid for ReduceV1 and ReduceV2 -func newReduceHint(x hinter.ResOperander) hinter.Hinter { +func newReduceHint(x hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Reduce", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -867,7 +867,7 @@ func createReduceHinter(resolver hintReferenceResolver) (hinter.Hinter, error) { // - `x` is the packed value to be reduced // // `newReduceEd25519Hint` assigns the result as `value` in the current scope -func newReduceEd25519Hint(x hinter.ResOperander) hinter.Hinter { +func newReduceEd25519Hint(x hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "ReduceEd25519", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -926,7 +926,7 @@ func createReduceEd25519Hinter(resolver hintReferenceResolver) (hinter.Hinter, e // This implementation is valid for EcDoubleAssignNewX V1,V2 and V4, only the operander differs // with `point` used for V1,V2 and `pt` used for V4 and for V2 SECP_P has to be already in scope // contrary to V1 -func newEcDoubleAssignNewXHint(slope, point hinter.ResOperander) hinter.Hinter { +func newEcDoubleAssignNewXHint(slope, point hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcDoubleAssignNewX", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1128,7 +1128,7 @@ func createEcDoubleAssignNewYV1Hinter() (hinter.Hinter, error) { // - `point1` is the second point on an elliptic curve to operate on // // `newComputeSlopeV1Hint` assigns the `slope` result as `value` in the current scope -func newComputeSlopeV1Hint(point0, point1 hinter.ResOperander) hinter.Hinter { +func newComputeSlopeV1Hint(point0, point1 hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "ComputeSlopeV1", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1253,7 +1253,7 @@ func createComputeSlopeV1Hinter(resolver hintReferenceResolver) (hinter.Hinter, // // `newComputeSlopeV2Hint` assigns the `slope` result as `value` in the current scope // // This version uses Curve25519 curve with SECP_P = 2**255 - 19 -func newComputeSlopeV2Hint(point0, point1 hinter.ResOperander) hinter.Hinter { +func newComputeSlopeV2Hint(point0, point1 hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "ComputeSlopeV2", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1382,7 +1382,7 @@ func createComputeSlopeV2Hinter(resolver hintReferenceResolver) (hinter.Hinter, // This version differs from ComputeSlopeV1 by the name of the operanders (`point0` and `point1` for V1, `pt0` and `pt1` for V3) // and the computation of the slope : V1 uses a dedicated utility function with an additionnal check while V3 executes // the modular division directly -func newComputeSlopeV3Hint(point0, point1 hinter.ResOperander) hinter.Hinter { +func newComputeSlopeV3Hint(point0, point1 hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "ComputeSlopeV3", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1490,7 +1490,7 @@ func createComputeSlopeV3Hinter(resolver hintReferenceResolver) (hinter.Hinter, return newComputeSlopeV3Hint(point0, point1), nil } -func newEcMulInnerHint(scalar hinter.ResOperander) hinter.Hinter { +func newEcMulInnerHint(scalar hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcMulInner", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1566,7 +1566,7 @@ func createIsZeroNondetHinter() (hinter.Hinter, error) { // - `x` is the value that will be packed and taken modulo SECP_P prime // // `newIsZeroPackHint` assigns the result as `x` in the current scope -func newIsZeroPackHint(x hinter.ResOperander) hinter.Hinter { +func newIsZeroPackHint(x hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsZeroPack", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1659,7 +1659,7 @@ func createIsZeroDivModHinter() (hinter.Hinter, error) { // `newRecoverYHint` takes 2 operanders as arguments // - `x` is the x coordinate of an elliptic curve point // - `p` is one of the two EC points with the given x coordinate (x, y) -func newRecoverYHint(x, p hinter.ResOperander) hinter.Hinter { +func newRecoverYHint(x, p hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "RecoverY", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1737,7 +1737,7 @@ func createRecoverYHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // - `m` the multiplication coefficient of Q used for seed generation // - `q` an EC point used for seed generation // - `s` is where the generated random EC point is written to -func newRandomEcPointHint(p, m, q, s hinter.ResOperander) hinter.Hinter { +func newRandomEcPointHint(p, m, q, s hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "RandomEcPoint", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1835,7 +1835,7 @@ func createRandomEcPointHinter(resolver hintReferenceResolver) (hinter.Hinter, e // - `m` the multiplication coefficient of Q used for seed generation // - `q` an EC point used for seed generation // - `s` is where the generated random EC point is written to -func newChainedEcOpHint(len, p, m, q, s hinter.ResOperander) hinter.Hinter { +func newChainedEcOpHint(len, p, m, q, s hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "ChainedEcOp", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -1976,7 +1976,7 @@ func createChainedEcOpHinter(resolver hintReferenceResolver) (hinter.Hinter, err // - `n` is an EC point // - `x` is an EC point // - `s` is an EC point -func newEcRecoverDivModNPackedHint(n, x, s hinter.ResOperander) hinter.Hinter { +func newEcRecoverDivModNPackedHint(n, x, s hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcRecoverDivModNPacked", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -2076,7 +2076,7 @@ func createEcRecoverDivModNPackedHinter(resolver hintReferenceResolver) (hinter. // `newEcRecoverSubABHint` takes 2 operanders as arguments // - `a` is an EC point // - `b` is an EC point -func newEcRecoverSubABHint(a, b hinter.ResOperander) hinter.Hinter { +func newEcRecoverSubABHint(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcRecoverSubAB", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -2151,7 +2151,7 @@ func createEcRecoverSubABHinter(resolver hintReferenceResolver) (hinter.Hinter, // - `a` is an EC point // - `b` is an EC point // - `m` is an EC point -func newEcRecoverProductModHint(a, b, m hinter.ResOperander) hinter.Hinter { +func newEcRecoverProductModHint(a, b, m hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "EcRecoverProductMod", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -2291,7 +2291,7 @@ func createEcRecoverProductDivMHinter() (hinter.Hinter, error) { // - `y` is the denominator // // `newBigIntPackDivModHint` assigns the result as `value` in the current scope -func newBigIntPackDivModHint(x, y, p hinter.ResOperander) hinter.Hinter { +func newBigIntPackDivModHint(x, y, p hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "BigIntPackDivMod", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -2417,7 +2417,7 @@ func createBigIntPackDivModHinter(resolver hintReferenceResolver) (hinter.Hinter // `newBigIntSafeDivHint` does not take any arguments // // `newBigIntSafeDivHint` assigns the result as `value` and sets `flag` based on the result in the current scope -func newBigIntSafeDivHint(flag hinter.ResOperander) hinter.Hinter { +func newBigIntSafeDivHint(flag hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "BigIntSafeDiv", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_keccak.go b/pkg/hintrunner/zero/zerohint_keccak.go index 3b01f5855..e85d60e30 100644 --- a/pkg/hintrunner/zero/zerohint_keccak.go +++ b/pkg/hintrunner/zero/zerohint_keccak.go @@ -22,7 +22,7 @@ import ( // // There are 2 versions of this hint, depending on whether `_block_size` should be lower than 10 or 1000 // Corresponding hintcodes are cairoKeccakFinalizeCode and cairoKeccakFinalizeBlockSize1000Code -func newCairoKeccakFinalizeHint(keccakPtrEnd hinter.ResOperander) hinter.Hinter { +func newCairoKeccakFinalizeHint(keccakPtrEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "CairoKeccakFinalize", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -85,7 +85,7 @@ func createCairoKeccakFinalizeHinter(resolver hintReferenceResolver) (hinter.Hin // - `length` is the length of the data to hash // - `low` is the low part of the produced hash // - `high` is the high part of the produced hash -func newUnsafeKeccakHint(data, length, high, low hinter.ResOperander) hinter.Hinter { +func newUnsafeKeccakHint(data, length, high, low hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UnsafeKeccak", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -221,7 +221,7 @@ func createUnsafeKeccakHinter(resolver hintReferenceResolver) (hinter.Hinter, er // start_ptr: felt*, // end_ptr: felt*, // } -func newUnsafeKeccakFinalizeHint(keccakState, high, low hinter.ResOperander) hinter.Hinter { +func newUnsafeKeccakFinalizeHint(keccakState, high, low hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UnsafeKeccakFinalize", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -334,7 +334,7 @@ func createUnsafeKeccakFinalizeHinter(resolver hintReferenceResolver) (hinter.Hi // - `inputs` is the address in memory where to write Keccak arguments // - `low` is the low part of the `uint256` argument for the Keccac function // - `high` is the high part of the `uint256` argument for the Keccac function -func newKeccakWriteArgsHint(inputs, low, high hinter.ResOperander) hinter.Hinter { +func newKeccakWriteArgsHint(inputs, low, high hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "KeccakWriteArgs", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -432,7 +432,7 @@ func createKeccakWriteArgsHinter(resolver hintReferenceResolver) (hinter.Hinter, // // `newCompareKeccakFullRateInBytesHint` writes 1 or 0 to `ap` memory address depending on whether // `n_bytes` is greater or equal to KECCAK_FULL_RATE_IN_BYTES or not -func newCompareKeccakFullRateInBytesHint(nBytes hinter.ResOperander) hinter.Hinter { +func newCompareKeccakFullRateInBytesHint(nBytes hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "CompareKeccakFullRateInBytes", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -476,7 +476,7 @@ func createCompareKeccakFullRateInBytesNondetHinter(resolver hintReferenceResolv // `KECCAK_STATE_SIZE_FELTS` is an operander in the Python VM but it is constant that we decided to hardcode // `newBlockPermutationHint` reads 25 memory cells starting from `keccakPtr - 25`, and writes // the result of the Keccak block permutation in the next 25 memory cells, starting from `keccakPtr` -func newBlockPermutationHint(keccakPtr hinter.ResOperander) hinter.Hinter { +func newBlockPermutationHint(keccakPtr hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "BlockPermutation", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -553,7 +553,7 @@ func createBlockPermutationHinter(resolver hintReferenceResolver) (hinter.Hinter // // `newCompareBytesInWordHint` writes 1 or 0 to `ap` memory address depending on whether // `n_bytes` is lower than BYTES_IN_WORD or not -func newCompareBytesInWordHint(nBytes hinter.ResOperander) hinter.Hinter { +func newCompareBytesInWordHint(nBytes hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "CompareBytesInWordHint", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -598,7 +598,7 @@ func createCompareBytesInWordNondetHinter(resolver hintReferenceResolver) (hinte // - `high12` is the variable that will store the quotient of the division // - `low12` is the variable that will store the remainder of the division // - `inputs` is the address in memory to which we add an offset of 12 and read that value -func newSplitInput12Hint(high12, low12, inputs hinter.ResOperander) hinter.Hinter { +func newSplitInput12Hint(high12, low12, inputs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInput12", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -685,7 +685,7 @@ func createSplitInput12Hinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `high15` is the variable that will store the quotient of the division // - `low15` is the variable that will store the remainder of the division // - `inputs` is the address in memory to which we add an offset of 15 and read that value -func newSplitInput15Hint(high15, low15, inputs hinter.ResOperander) hinter.Hinter { +func newSplitInput15Hint(high15, low15, inputs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInput15", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -774,7 +774,7 @@ func createSplitInput15Hinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `output1Mid` is the variable that will store the remainder of the second division // - `output1High` is the variable that will store the quotient of the second division // - `output1` is the variable that will be divided in the first division -func newSplitOutputMidLowHighHint(output1, output1Low, output1Mid, output1High hinter.ResOperander) hinter.Hinter { +func newSplitOutputMidLowHighHint(output1, output1Low, output1Mid, output1High hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitOutputMidLowHigh", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -871,7 +871,7 @@ func createSplitOutputMidLowHighHinter(resolver hintReferenceResolver) (hinter.H // - `output0_low` is the variable that will store the low part of `output0` // - `output0_high` is the variable that will store the high part of `output0` // - `output0` is the value to split -func newSplitOutput0Hint(output0Low, output0High, output0 hinter.ResOperander) hinter.Hinter { +func newSplitOutput0Hint(output0Low, output0High, output0 hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitOutput0", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -948,7 +948,7 @@ func createSplitOutput0Hinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `nWordsToCopy` is the variable that will store the quotient of the division // - `nBytesLeft` is the variable that will store the remainder of the division // - `nBytes` is the variable that will be divided -func newSplitNBytesHint(nBytes, nWordsToCopy, nBytesLeft hinter.ResOperander) hinter.Hinter { +func newSplitNBytesHint(nBytes, nWordsToCopy, nBytesLeft hinter.Reference) hinter.Hinter { name := "SplitNBytes" return &GenericZeroHinter{ Name: name, @@ -1025,7 +1025,7 @@ func createSplitNBytesHinter(resolver hintReferenceResolver) (hinter.Hinter, err // - `high3` is the variable that will store the quotient of the division // - `low3` is the variable that will store the remainder of the division // - `inputs` is the address in memory to which we add an offset of 3 and read that value -func newSplitInput3Hint(high3, low3, inputs hinter.ResOperander) hinter.Hinter { +func newSplitInput3Hint(high3, low3, inputs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInput3", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1111,7 +1111,7 @@ func createSplitInput3Hinter(resolver hintReferenceResolver) (hinter.Hinter, err // - `high6` is the variable that will store the quotient of the division // - `low6` is the variable that will store the remainder of the division // - `inputs` is the address in memory to which we add an offset of 6 and read that value -func newSplitInput6Hint(high6, low6, inputs hinter.ResOperander) hinter.Hinter { +func newSplitInput6Hint(high6, low6, inputs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInput6", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1198,7 +1198,7 @@ func createSplitInput6Hinter(resolver hintReferenceResolver) (hinter.Hinter, err // - `high9` is the variable that will store the quotient of the division // - `low9` is the variable that will store the remainder of the division // - `inputs` is the address in memory to which we add an offset of 9 and read that value -func newSplitInput9Hint(high9, low9, inputs hinter.ResOperander) hinter.Hinter { +func newSplitInput9Hint(high9, low9, inputs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInput9", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_math.go b/pkg/hintrunner/zero/zerohint_math.go index 3f512940b..880ab9988 100755 --- a/pkg/hintrunner/zero/zerohint_math.go +++ b/pkg/hintrunner/zero/zerohint_math.go @@ -23,7 +23,7 @@ import ( // // `newIsLeFeltHint` writes to `[ap]` the result of the comparison // i.e, 1 if `a % PRIME <= b % PRIME`, 0 otherwise -func newIsLeFeltHint(a, b hinter.ResOperander) hinter.Hinter { +func newIsLeFeltHint(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsLeFelt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -75,7 +75,7 @@ func createIsLeFeltHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // // `newAssertLtFeltHint` returns an error if `a` is not // strictly less than `b` within a finite field -func newAssertLtFeltHint(a, b hinter.ResOperander) hinter.Hinter { +func newAssertLtFeltHint(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "AssertLtFelt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -124,7 +124,7 @@ func createAssertLtFeltHinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `value` is the value that will be compared to 0 // // `newAssertNotZeroHint` returns an error if `value` is zero -func newAssertNotZeroHint(value hinter.ResOperander) hinter.Hinter { +func newAssertNotZeroHint(value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "AssertNotZero", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -163,7 +163,7 @@ func createAssertNotZeroHinter(resolver hintReferenceResolver) (hinter.Hinter, e // // `newAssertNNHint` returns an error if `value` is negative // within a specified range -func newAssertNNHint(a hinter.ResOperander) hinter.Hinter { +func newAssertNNHint(a hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "AssertNN", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -200,7 +200,7 @@ func createAssertNNHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // - `a` and `b` are the values that will be compared // // `newAssertNotEqualHint` returns an error if `a` and `b` are not equal -func newAssertNotEqualHint(a, b hinter.ResOperander) hinter.Hinter { +func newAssertNotEqualHint(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "AssertNotEqual", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -261,7 +261,7 @@ func createAssertNotEqualHinter(resolver hintReferenceResolver) (hinter.Hinter, // // `newAssert250bitsHint` writes the quotient and the remainder of the modular // division of `value` by 2**128 at `low` and `high` addresses in memory, respectively -func newAssert250bitsHint(low, high, value hinter.ResOperander) hinter.Hinter { +func newAssert250bitsHint(low, high, value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Assert250bits", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -342,7 +342,7 @@ func createAssert250bitsHinter(resolver hintReferenceResolver) (hinter.Hinter, e // `newAssertLeFeltHint` takes 3 operanders as arguments // - `a` and `b` is the values that will be evaluated // - `rangeCheckPtr` is a pointer to the range-check builtin -func newAssertLeFeltHint(a, b, rangeCheckPtr hinter.ResOperander) hinter.Hinter { +func newAssertLeFeltHint(a, b, rangeCheckPtr hinter.Reference) hinter.Hinter { return &core.AssertLeFindSmallArc{ A: a, B: b, @@ -412,7 +412,7 @@ func createAssertLeFeltExcluded2Hinter() (hinter.Hinter, error) { // // `newIsNNHint` writes 0 or 1 to memory at `[ap]` address, depending on // whether `a` is positive or negative, respectively -func newIsNNHint(a hinter.ResOperander) hinter.Hinter { +func newIsNNHint(a hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsNN", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -456,7 +456,7 @@ func createIsNNHinter(resolver hintReferenceResolver) (hinter.Hinter, error) { // // `newIsNNOutOfRangeHint` writes 0 or 1 to memory at `[ap]` address, depending on // whether the negation of `a` minus one is positive or negative, respectively -func newIsNNOutOfRangeHint(a hinter.ResOperander) hinter.Hinter { +func newIsNNOutOfRangeHint(a hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsNNOutOfRange", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -505,7 +505,7 @@ func createIsNNOutOfRangeHinter(resolver hintReferenceResolver) (hinter.Hinter, // // `newIsPositiveHint` writes 1 or 0 to `dest` address, depending on // whether `value` is positive or negative in the context, respectively -func newIsPositiveHint(value, isPositive hinter.ResOperander) hinter.Hinter { +func newIsPositiveHint(value, isPositive hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsPositive", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -556,7 +556,7 @@ func createIsPositiveHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // - `value` is the value that will be evaluated // // `newSplitIntAssertRangeHint` returns an error if `value` is not zero -func newSplitIntAssertRangeHint(value hinter.ResOperander) hinter.Hinter { +func newSplitIntAssertRangeHint(value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitIntAssertRange", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -596,7 +596,7 @@ func createSplitIntAssertRangeHinter(resolver hintReferenceResolver) (hinter.Hin // // `newSplitIntHint` is recursively called when splitting an integer // and writes to the `output` memory address the calculated limb -func newSplitIntHint(output, value, base, bound hinter.ResOperander) hinter.Hinter { +func newSplitIntHint(output, value, base, bound hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitInt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -668,7 +668,7 @@ func createSplitIntHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // // `newPowHint` writes to the memory address of `locs` variable the value of the least // significant bit of the exponent of `prevLocs` variable module a prime field -func newPowHint(locs, prevLocs hinter.ResOperander) hinter.Hinter { +func newPowHint(locs, prevLocs hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Pow", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -736,7 +736,7 @@ func createPowHinter(resolver hintReferenceResolver) (hinter.Hinter, error) { // - `base` is the value that will be checked // // `newSignedPowHint` returns an error if `base` is zero -func newSignedPowHint(base hinter.ResOperander) hinter.Hinter { +func newSignedPowHint(base hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SignedPow", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -771,7 +771,7 @@ func createSignedPowHinter(resolver hintReferenceResolver) (hinter.Hinter, error // // `newSplitFeltHint` writes the low and high components in the `low` and `high` // memory address, respectively -func newSplitFeltHint(low, high, value hinter.ResOperander) hinter.Hinter { +func newSplitFeltHint(low, high, value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitFelt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -862,7 +862,7 @@ func createSplitFeltHinter(resolver hintReferenceResolver) (hinter.Hinter, error // - `biased_q` is the variable that will store the quotient of the modular division // // `newSignedDivRemHint` writes `r` and `biased_q` values to their respective memory address -func newSignedDivRemHint(value, div, bound, r, biased_q hinter.ResOperander) hinter.Hinter { +func newSignedDivRemHint(value, div, bound, r, biased_q hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SignedDivRem", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -985,7 +985,7 @@ func createSignedDivRemHinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `value` is the variable to operate on // // `newSqrtHint` writes the result of the hint at `root` address in memory -func newSqrtHint(root, value hinter.ResOperander) hinter.Hinter { +func newSqrtHint(root, value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Sqrt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1047,7 +1047,7 @@ func createSqrtHinter(resolver hintReferenceResolver) (hinter.Hinter, error) { // - `r` is the variable that will store the remainder of the modular division // // `newUnsignedDivRemHinter` writes `q` and `r` values to their respective memory address -func newUnsignedDivRemHint(value, div, q, r hinter.ResOperander) hinter.Hinter { +func newUnsignedDivRemHint(value, div, q, r hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UnsignedDivRem", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1127,7 +1127,7 @@ func createUnsignedDivRemHinter(resolver hintReferenceResolver) (hinter.Hinter, return newUnsignedDivRemHint(value, div, q, r), nil } -func newIsQuadResidueHint(x, y hinter.ResOperander) hinter.Hinter { +func newIsQuadResidueHint(x, y hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "IsQuadResidue", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1195,7 +1195,7 @@ func createIsQuadResidueHinter(resolver hintReferenceResolver) (hinter.Hinter, e // `newSplit128Hint` takes 3 operanders as arguments // - `low` and `high` are the variables that will store the low and high components // - `a` is the variable to split -func newSplit128Hint(low, high, a hinter.ResOperander) hinter.Hinter { +func newSplit128Hint(low, high, a hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Split128", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -1254,7 +1254,7 @@ func createSplit128Hinter(resolver hintReferenceResolver) (hinter.Hinter, error) // - `addr` is the address that will be compared to 2**250 // // `newIs250Bits` writes 1 or 0 to the memory address of `is_250` variable -func newIs250BitsHint(is_250, addr hinter.ResOperander) hinter.Hinter { +func newIs250BitsHint(is_250, addr hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Is250Bits", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_others.go b/pkg/hintrunner/zero/zerohint_others.go index 994846830..d6fdc8864 100644 --- a/pkg/hintrunner/zero/zerohint_others.go +++ b/pkg/hintrunner/zero/zerohint_others.go @@ -14,7 +14,7 @@ import ( "github.com/consensys/gnark-crypto/ecc/stark-curve/fp" ) -func newMemContinueHint(continueTarget hinter.ResOperander, memset bool) hinter.Hinter { +func newMemContinueHint(continueTarget hinter.Reference, memset bool) hinter.Hinter { var name string if memset { name = "MemsetContinueLoop" @@ -63,7 +63,7 @@ func newMemContinueHint(continueTarget hinter.ResOperander, memset bool) hinter. } func createMemContinueHinter(resolver hintReferenceResolver, memset bool) (hinter.Hinter, error) { - var continueTarget hinter.ResOperander + var continueTarget hinter.Reference var err error if memset { continueTarget, err = resolver.GetResOperander("continue_loop") @@ -107,7 +107,7 @@ func createVMExitScopeHinter() (hinter.Hinter, error) { // `newMemEnterScopeHint` takes 2 operanders as arguments // - `value` is the value that is added in the new scope // - `memset` specifies whether it's a memset or memcpy operation -func newMemEnterScopeHint(value hinter.ResOperander, memset bool) hinter.Hinter { +func newMemEnterScopeHint(value hinter.Reference, memset bool) hinter.Hinter { var name string if memset { name = "MemsetEnterScope" @@ -135,7 +135,7 @@ func newMemEnterScopeHint(value hinter.ResOperander, memset bool) hinter.Hinter } func createMemEnterScopeHinter(resolver hintReferenceResolver, memset bool) (hinter.Hinter, error) { - var value hinter.ResOperander + var value hinter.Reference var err error if memset { value, err = resolver.GetResOperander("n") @@ -153,7 +153,7 @@ func createMemEnterScopeHinter(resolver hintReferenceResolver, memset bool) (hin // `newGetFeltBitLengthHint` takes 2 operanders as arguments // - `x` is a felt variable // - `bit_length` is the variable that will store the bit length of x -func newGetFeltBitLengthHint(x, bitLength hinter.ResOperander) hinter.Hinter { +func newGetFeltBitLengthHint(x, bitLength hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "GetFeltBitLength", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -203,7 +203,7 @@ func createGetFeltBitLengthHinter(resolver hintReferenceResolver) (hinter.Hinter // - `key` is the felt key to search for in the array // - `index` is the address in memory where to write the index of the found element in the array // - `nElms` is the number of elements in the array -func newFindElementHint(arrayPtr, elmSize, key, index, nElms hinter.ResOperander) hinter.Hinter { +func newFindElementHint(arrayPtr, elmSize, key, index, nElms hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "FindElement", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -384,7 +384,7 @@ func createFindElementHinter(resolver hintReferenceResolver) (hinter.Hinter, err return newFindElementHint(arrayPtr, elmSize, key, index, nElms), nil } -func newSetAddHint(elmSize, elmPtr, setPtr, setEndPtr, index, isElmInSet hinter.ResOperander) hinter.Hinter { +func newSetAddHint(elmSize, elmPtr, setPtr, setEndPtr, index, isElmInSet hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SetAdd", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -514,7 +514,7 @@ func createSetAddHinter(resolver hintReferenceResolver) (hinter.Hinter, error) { // - `nElms` is the number of elements in the array // - `key` is the given key that acts a threshold // - `index` is the result, i.e., the index of the first element greater or equal to the given key -func newSearchSortedLowerHint(arrayPtr, elmSize, nElms, key, index hinter.ResOperander) hinter.Hinter { +func newSearchSortedLowerHint(arrayPtr, elmSize, nElms, key, index hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SearchSortedLower", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -652,7 +652,7 @@ func createSearchSortedLowerHinter(resolver hintReferenceResolver) (hinter.Hinte // - `elementsEnd` represents the address in memory right after the last element of the array // - `elements` represents the address in memory of the first element of the array // - `x` represents the offset difference used to decide the result -func newNondetElementsOverXHint(elementsEnd, elements hinter.ResOperander, x uint64) hinter.Hinter { +func newNondetElementsOverXHint(elementsEnd, elements hinter.Reference, x uint64) hinter.Hinter { return &GenericZeroHinter{ Name: "NondetElementsOverX", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -701,7 +701,7 @@ func createNondetElementsOverXHinter(resolver hintReferenceResolver, x uint64) ( // `newNormalizeAddressHint` takes 2 arguments // - `isSmall` represents the address where the result of the comparison is stored // - `addr` represents the address whose value is checked against ADDR_BOUND -func newNormalizeAddressHint(isSmall, addr hinter.ResOperander) hinter.Hinter { +func newNormalizeAddressHint(isSmall, addr hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "NormalizeAddress", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -758,7 +758,7 @@ func createNormalizeAddressHinter(resolver hintReferenceResolver) (hinter.Hinter // `newSha256AndBlake2sInputHint` takes 2 arguments // - `full_word` represents the address where the result of the comparison is stored // - `n_bytes` represents the value that will be compared to 4 -func newSha256AndBlake2sInputHint(fullWord, nbytes hinter.ResOperander) hinter.Hinter { +func newSha256AndBlake2sInputHint(fullWord, nbytes hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Sha256AndBlake2sInput", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_sha256.go b/pkg/hintrunner/zero/zerohint_sha256.go index 0b7b5a016..e9ed28102 100644 --- a/pkg/hintrunner/zero/zerohint_sha256.go +++ b/pkg/hintrunner/zero/zerohint_sha256.go @@ -15,7 +15,7 @@ import ( // `newPackedSha256Hint` takes 2 operanders as arguments // - `sha256Start` is the address where to start reading the input for the `compute_message_schedule` function // - `output` is the address where to write the new state in memory -func newPackedSha256Hint(sha256Start, output hinter.ResOperander) hinter.Hinter { +func newPackedSha256Hint(sha256Start, output hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "PackedSha256", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -101,7 +101,7 @@ func createPackedSha256Hinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `sha256Start` is the address where to start reading the input for `sha2_compress_function` // - `state` is the current that will be passed to compute the next state // - `output` is the address where to write the new state in memory -func newSha256ChunkHint(sha256Start, state, output hinter.ResOperander) hinter.Hinter { +func newSha256ChunkHint(sha256Start, state, output hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Sha256Chunk", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -213,7 +213,7 @@ func createSha256ChunkHinter(resolver hintReferenceResolver) (hinter.Hinter, err // // `newFinalizeSha256Hint` takes 1 operander as argument // - `sha256PtrEnd` is the address where to write the new state in memory -func newFinalizeSha256Hint(sha256PtrEnd hinter.ResOperander) hinter.Hinter { +func newFinalizeSha256Hint(sha256PtrEnd hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "FinalizeSha256", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_signature.go b/pkg/hintrunner/zero/zerohint_signature.go index 2a797e312..397d66291 100644 --- a/pkg/hintrunner/zero/zerohint_signature.go +++ b/pkg/hintrunner/zero/zerohint_signature.go @@ -22,7 +22,7 @@ import ( // // `newVerifyZeroHint` writes the quotient of the modular division of the packed value // by secp256k1 prime to the memory address corresponding to `q` -func newVerifyZeroHint(val, q hinter.ResOperander) hinter.Hinter { +func newVerifyZeroHint(val, q hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "VerifyZero", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -99,7 +99,7 @@ func createVerifyZeroHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // // `newVerifyZeroV3Hint` writes the quotient of the modular division of the packed value // by Curve25519 prime to the memory address corresponding to `q` -func newVerifyZeroV3Hint(val, q hinter.ResOperander) hinter.Hinter { +func newVerifyZeroV3Hint(val, q hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "VerifyZeroV3", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -177,7 +177,7 @@ func createVerifyZeroV3Hinter(resolver hintReferenceResolver) (hinter.Hinter, er // - `signature_r` and `signature_s` are the r and s parts of the signature // // `newVerifyECDSASignatureHint` uses the ECDSA builtin to perform this operation -func newVerifyECDSASignatureHint(ecdsaPtr, signature_r, signature_s hinter.ResOperander) hinter.Hinter { +func newVerifyECDSASignatureHint(ecdsaPtr, signature_r, signature_s hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "VerifyECDSASignature", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -236,7 +236,7 @@ func createVerifyECDSASignatureHinter(resolver hintReferenceResolver) (hinter.Hi // - `v` is the parity of the `y` result, it should be either 0 or 1 // // `newGetPointFromXHint` assigns the y-coordinate as `value` in the current scope -func newGetPointFromXHint(xCube, v hinter.ResOperander) hinter.Hinter { +func newGetPointFromXHint(xCube, v hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "GetPointFromX", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -393,7 +393,7 @@ func createDivModSafeDivHinter() (hinter.Hinter, error) { // - `b` is the packed value that will divide `a` // // `newDivModNPackedDivmodV1Hint` assigns the result `res` as `value` in the current scope -func newDivModNPackedDivmodV1Hint(a, b hinter.ResOperander) hinter.Hinter { +func newDivModNPackedDivmodV1Hint(a, b hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "DivModNPackedDivmodV1", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_test.go b/pkg/hintrunner/zero/zerohint_test.go index 9a5cb0024..638755fbc 100644 --- a/pkg/hintrunner/zero/zerohint_test.go +++ b/pkg/hintrunner/zero/zerohint_test.go @@ -23,7 +23,7 @@ type hintTestContext struct { vm *VM.VirtualMachine runnerContext *hinter.HintRunnerContext - operanders map[string]hinter.ResOperander + operanders map[string]hinter.Reference } // hintTestCase describes a single zero hint test case. @@ -125,7 +125,7 @@ func runHinterTests(t *testing.T, tests map[string][]hintTestCase) { testCtx := &hintTestContext{ vm: vm, runnerContext: ctx, - operanders: make(map[string]hinter.ResOperander), + operanders: make(map[string]hinter.Reference), } // builtinsAllocated stores fp offsets mapping for the builtin pointers. diff --git a/pkg/hintrunner/zero/zerohint_uint256.go b/pkg/hintrunner/zero/zerohint_uint256.go index 415bfe36d..6e92231a8 100644 --- a/pkg/hintrunner/zero/zerohint_uint256.go +++ b/pkg/hintrunner/zero/zerohint_uint256.go @@ -20,7 +20,7 @@ import ( // - `a` and `b` are the two `uint256` variables that will be added // - `carryLow` and `carryHigh` represent the potential extra bit that needs to be carried // if the sum of the `low` or `high` parts exceeds 2**128 - 1 -func newUint256AddHint(a, b, carryLow, carryHigh hinter.ResOperander) hinter.Hinter { +func newUint256AddHint(a, b, carryLow, carryHigh hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256Add", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -116,7 +116,7 @@ func createUint256AddHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // `newSplit64Hint` takes 3 operanders as arguments // - `a` is the `felt` variable in range [0, 2^192) that will be splitted // - `low` and `high` represent the `low` 64 bits and the `high` 128 bits of the `felt` variable -func newSplit64Hint(a, low, high hinter.ResOperander) hinter.Hinter { +func newSplit64Hint(a, low, high hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Split64", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -185,7 +185,7 @@ func createSplit64Hinter(resolver hintReferenceResolver) (hinter.Hinter, error) // `newUint256SqrtHint` takes 2 operanders as arguments // - `n` represents the `uint256` variable for which we will calculate the square root // - `root` is the variable that will store the result of the hint in memory -func newUint256SqrtHint(n, root hinter.ResOperander) hinter.Hinter { +func newUint256SqrtHint(n, root hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256Sqrt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -248,7 +248,7 @@ func createUint256SqrtHinter(resolver hintReferenceResolver) (hinter.Hinter, err // // `newUint256SignedNNHint` takes 1 operander as argument // - `a` represents the `uint256` variable that will be checked -func newUint256SignedNNHint(a hinter.ResOperander) hinter.Hinter { +func newUint256SignedNNHint(a hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256SignedNN", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -291,7 +291,7 @@ func createUint256SignedNNHinter(resolver hintReferenceResolver) (hinter.Hinter, // - `div` is the `uint256` variable that will divide `a` // - `quotient` is the quotient of the Euclidean division of `a` by `div` // - `remainder` is the remainder of the Euclidean division of `a` by `div` -func newUint256UnsignedDivRemHint(a, div, quotient, remainder hinter.ResOperander) hinter.Hinter { +func newUint256UnsignedDivRemHint(a, div, quotient, remainder hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256UnsignedDivRem", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -389,7 +389,7 @@ func createUint256UnsignedDivRemHinter(resolver hintReferenceResolver) (hinter.H // - `div` is the `uint256` variable that will divide `a`, consists of `b23` (high) parts and `b01` (low) // - `quotient` is the quotient of the Euclidean division of `a` by `div` // - `remainder` is the remainder of the Euclidean division of `a` by `div` -func newUint256UnsignedDivRemExpandedHint(a, div, quotient, remainder hinter.ResOperander) hinter.Hinter { +func newUint256UnsignedDivRemExpandedHint(a, div, quotient, remainder hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256UnsignedDivRemExpanded", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -496,7 +496,7 @@ func createUint256UnsignedDivRemExpandedHinter(resolver hintReferenceResolver) ( // - `div` is the `uint256` variable that will divide the result of `a * b` // - `quotient` is the quotient of the Euclidean division of `a * b` by `div` // - `remainder` is the remainder of the Euclidean division of `a * b` by `div` -func newUint256MulDivModHint(a, b, div, quotientLow, quotientHigh, remainder hinter.ResOperander) hinter.Hinter { +func newUint256MulDivModHint(a, b, div, quotientLow, quotientHigh, remainder hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256MulDivMod", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -620,7 +620,7 @@ func createUint256MulDivModHinter(resolver hintReferenceResolver) (hinter.Hinter // `newUint256SubHint` takes 3 operanders as arguments // - `a` and `b` are the `uint256` variables that will be subtracted // - `res` is the variable that will store the result of the subtraction in memory -func newUint256SubHint(a, b, res hinter.ResOperander) hinter.Hinter { +func newUint256SubHint(a, b, res hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint256Sub", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -704,7 +704,7 @@ func createUint256SubHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // newSplitXXHint takes 2 operanders as arguments: // - `xx` is the `uint256` variable that will be used to calculate the square root // - `x` is the variable that will store the result of the hint in memory -func newSplitXXHint(x, xx hinter.ResOperander) hinter.Hinter { +func newSplitXXHint(x, xx hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "SplitXX", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -798,7 +798,7 @@ func createSplitXXHinter(resolver hintReferenceResolver) (hinter.Hinter, error) // - `a` and `b` are the two `uint128` variables that will be added // - `carry` represent the potential extra bit that needs to be carried // if the res of the sum of `a` and `b` exceeds 2**64 - 1 -func newUint128AddHint(a, b, carry hinter.ResOperander) hinter.Hinter { +func newUint128AddHint(a, b, carry hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint128Add", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { @@ -860,7 +860,7 @@ func createUint128AddHinter(resolver hintReferenceResolver) (hinter.Hinter, erro // - `a` and `b` are the two `uint128` variables that will be added // - `carry` represent the potential extra bit that needs to be carried // if the res of the sum of `a` and `b` exceeds 2**64 - 1 -func newUint128SqrtHint(n, root hinter.ResOperander) hinter.Hinter { +func newUint128SqrtHint(n, root hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "Uint128Sqrt", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_uint512.go b/pkg/hintrunner/zero/zerohint_uint512.go index 58da52bf1..43ed4a62e 100644 --- a/pkg/hintrunner/zero/zerohint_uint512.go +++ b/pkg/hintrunner/zero/zerohint_uint512.go @@ -19,7 +19,7 @@ const ( // `newInvModPUint512Hint` takes 2 operanders as arguments // - `x` is the `uint512` variable that will be inverted modulo `p` // - `x_inverse_mod_p` is the variable that will store the result of the hint in memory -func newInvModPUint512Hint(x, xInverseModP hinter.ResOperander) hinter.Hinter { +func newInvModPUint512Hint(x, xInverseModP hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "InvModPUint512", Op: func(vm *VM.VirtualMachine, _ *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_usort.go b/pkg/hintrunner/zero/zerohint_usort.go index fcf5492bc..69657d9bd 100644 --- a/pkg/hintrunner/zero/zerohint_usort.go +++ b/pkg/hintrunner/zero/zerohint_usort.go @@ -46,7 +46,7 @@ func createUsortEnterScopeHinter() (hinter.Hinter, error) { // - `output` is the pointer to the base of the output array of field elements // - `outputLen` is the length of the output array // - `multiplicities` is the pointer to the base of the multiplicities array of field elements -func newUsortBodyHint(input, inputLen, output, outputLen, multiplicities hinter.ResOperander) hinter.Hinter { +func newUsortBodyHint(input, inputLen, output, outputLen, multiplicities hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UsortBody", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -229,7 +229,7 @@ func createUsortBodyHinter(resolver hintReferenceResolver) (hinter.Hinter, error // `positions` is set to the reversed order list associated with `ids.value` // key in `positions_dict` // `newUsortVerifyHint` assigns `last_pos` and `positions` in the current scope -func newUsortVerifyHint(value hinter.ResOperander) hinter.Hinter { +func newUsortVerifyHint(value hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UsortVerify", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { @@ -280,7 +280,7 @@ func createUsortVerifyHinter(resolver hintReferenceResolver) (hinter.Hinter, err // // `next_item_index` is set to `current_pos - last_pos` for the next iteration // `newUsortVerifyMultiplicityBodyHint` assigns `last_pos` in the current scope -func newUsortVerifyMultiplicityBodyHint(nextItemIndex hinter.ResOperander) hinter.Hinter { +func newUsortVerifyMultiplicityBodyHint(nextItemIndex hinter.Reference) hinter.Hinter { return &GenericZeroHinter{ Name: "UsortVerifyMultiplicityBody", Op: func(vm *VM.VirtualMachine, ctx *hinter.HintRunnerContext) error { diff --git a/pkg/hintrunner/zero/zerohint_utils.go b/pkg/hintrunner/zero/zerohint_utils.go index c293ce708..5dfeb59fc 100644 --- a/pkg/hintrunner/zero/zerohint_utils.go +++ b/pkg/hintrunner/zero/zerohint_utils.go @@ -14,7 +14,7 @@ import ( // // The low and high parts previously extracted from memory are then // converted to field elements and returned -func GetUint256AsFelts(vm *VM.VirtualMachine, ref hinter.ResOperander) (*fp.Element, *fp.Element, error) { +func GetUint256AsFelts(vm *VM.VirtualMachine, ref hinter.Reference) (*fp.Element, *fp.Element, error) { lowRefAddr, err := ref.GetAddress(vm) if err != nil { return nil, nil, err @@ -48,7 +48,7 @@ func GetUint256AsFelts(vm *VM.VirtualMachine, ref hinter.ResOperander) (*fp.Elem return low, high, nil } -func GetUint256ExpandAsFelts(vm *VM.VirtualMachine, ref hinter.ResOperander) ([]*fp.Element, error) { +func GetUint256ExpandAsFelts(vm *VM.VirtualMachine, ref hinter.Reference) ([]*fp.Element, error) { //> struct Uint256_expand { //> B0: felt, //> b01: felt, @@ -78,7 +78,7 @@ func GetUint256ExpandAsFelts(vm *VM.VirtualMachine, ref hinter.ResOperander) ([] return uint256Expanded, nil } -func GetUint512AsFelts(vm *VM.VirtualMachine, ref hinter.ResOperander) (*fp.Element, *fp.Element, *fp.Element, *fp.Element, error) { +func GetUint512AsFelts(vm *VM.VirtualMachine, ref hinter.Reference) (*fp.Element, *fp.Element, *fp.Element, *fp.Element, error) { var fps [4]*fp.Element firstRefAddr, err := ref.GetAddress(vm) if err != nil {