Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/hintrunner/zero/zerohint_ec.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func newGetHighLenHint(len_hi, scalar_u, scalar_v hinter.Reference) hinter.Hinte
bitLenU := scalarUD2.BitLen()
bitLenV := scalarVD2.BitLen()

lenHi := utils.Max(bitLenU, bitLenV) - 1
lenHi := max(bitLenU, bitLenV) - 1

lenHiAddr, err := len_hi.Get(vm)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/hintrunner/zero/zerohint_keccak.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func newUnsafeKeccakHint(data, length, high, low hinter.Reference) hinter.Hinter
word := uint256.Int(wordFelt.Bits())

//> n_bytes = min(16, length - byte_i)
nBytes := utils.Min(lengthVal-i, 16)
nBytes := min(lengthVal-i, 16)

//> assert 0 <= word < 2 ** (8 * n_bytes)
if uint64(word.BitLen()) >= 8*nBytes {
Expand Down
16 changes: 0 additions & 16 deletions pkg/utils/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"math/big"
"math/bits"

"golang.org/x/exp/constraints"

"github.com/consensys/gnark-crypto/ecc/stark-curve/fp"
)

Expand Down Expand Up @@ -59,20 +57,6 @@ func NextPowerOfTwo(n uint64) uint64 {
return 1 << higherBit
}

func Max[T constraints.Integer](a, b T) T {
if a > b {
return a
}
return b
}

func Min[T constraints.Integer](a, b T) T {
if a < b {
return a
}
return b
}

// FeltLt implements `a < b` felt comparison.
func FeltLt(a, b *fp.Element) bool {
return a.Cmp(b) == -1
Expand Down
3 changes: 1 addition & 2 deletions pkg/vm/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"

"github.com/NethermindEth/cairo-vm-go/pkg/utils"
f "github.com/consensys/gnark-crypto/ecc/stark-curve/fp"
)

Expand Down Expand Up @@ -158,7 +157,7 @@ func (segment *Segment) IncreaseSegmentSize(newSize uint64) {
if cap(segmentData) > int(newSize) {
newSegmentData = segmentData[:cap(segmentData)]
} else {
newSegmentData = make([]MemoryValue, utils.Max(newSize, uint64(len(segmentData)*2)))
newSegmentData = make([]MemoryValue, max(newSize, uint64(len(segmentData)*2)))
copy(newSegmentData, segmentData)
}
segment.Data = newSegmentData
Expand Down
8 changes: 4 additions & 4 deletions pkg/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ func (vm *VirtualMachine) RunInstruction(instruction *asmb.Instruction) error {
var off1 int = int(instruction.OffOp0) + (1 << (RC_OFFSET_BITS - 1))
var off2 int = int(instruction.OffOp1) + (1 << (RC_OFFSET_BITS - 1))

value := uint16(utils.Max(off0, utils.Max(off1, off2)))
vm.RcLimitsMax = utils.Max(vm.RcLimitsMax, value)
value = uint16(utils.Min(off0, utils.Min(off1, off2)))
vm.RcLimitsMin = utils.Min(vm.RcLimitsMin, value)
value := uint16(max(off0, max(off1, off2)))
vm.RcLimitsMax = max(vm.RcLimitsMax, value)
value = uint16(min(off0, min(off1, off2)))
vm.RcLimitsMin = min(vm.RcLimitsMin, value)
dstAddr, err := vm.getDstAddr(instruction)
if err != nil {
return fmt.Errorf("dst cell: %w", err)
Expand Down