utils

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CostOfAddGate = 3
View Source
const CostOfCstGate = 3
View Source
const CostOfInput = 1000
View Source
const CostOfMulGate = 10
View Source
const CostOfVariable = 100

Variables

This section is empty.

Functions

func CostOfCompress

func CostOfCompress(deg0, deg1, deg2 int) int

func CostOfMultiply

func CostOfMultiply(aDeg0, aDeg1, bDeg0, bDeg1 int) int

func FromInterface

func FromInterface(input interface{}) big.Int

FromInterface converts an interface to a big.Int element

input must be primitive (uintXX, intXX, []byte, string) or implement BigInt(res *big.Int) (which is the case for gnark-crypto field elements)

if the input is a string, it calls (big.Int).SetString(input, 0). In particular: The number prefix determines the actual base: A prefix of ”0b” or ”0B” selects base 2, ”0”, ”0o” or ”0O” selects base 8, and ”0x” or ”0X” selects base 16. Otherwise, the selected base is 10 and no prefix is accepted.

panics if the input is invalid

func NextPowerOfTwo

func NextPowerOfTwo(x int, is4 bool) int

pad to 2^n gates (and 4^n for first layer) 4^n exists for historical reasons, not used now

func ShowProfiling

func ShowProfiling(varSourceInfo []SourceInfo, varCost []int)

func SortIntSeq

func SortIntSeq(s []int, cmpLess func(int, int) bool)

SortIntSeq sorts an integer sequence using a given compare function

Types

type Hashable

type Hashable interface {
	HashCode() uint64
	EqualI(Hashable) bool
}

type InputBuf

type InputBuf struct {
	// contains filtered or unexported fields
}

func NewInputBuf

func NewInputBuf(buf []byte) *InputBuf

func (*InputBuf) IsEnd

func (i *InputBuf) IsEnd() bool

func (*InputBuf) ReadBigInt

func (i *InputBuf) ReadBigInt(n int) *big.Int

func (*InputBuf) ReadFieldElement

func (i *InputBuf) ReadFieldElement(field SimpleField) constraint.Element

func (*InputBuf) ReadIntSlice

func (i *InputBuf) ReadIntSlice() []int

func (*InputBuf) ReadUint32

func (i *InputBuf) ReadUint32() uint32

func (*InputBuf) ReadUint64

func (i *InputBuf) ReadUint64() uint64

func (*InputBuf) ReadUint8

func (i *InputBuf) ReadUint8() uint8

type IntSeq

type IntSeq struct {
	// contains filtered or unexported fields
}

func (*IntSeq) Len

func (l *IntSeq) Len() int

func (*IntSeq) Less

func (l *IntSeq) Less(i, j int) bool

func (*IntSeq) Swap

func (l *IntSeq) Swap(i, j int)

type Map

type Map map[uint64][]mapEntry

func (Map) Add

func (m Map) Add(e Hashable, v interface{}) interface{}

adds (e, v) to the map, returns the current value when e already exists

func (Map) Clear

func (m Map) Clear()

clear the map

func (Map) FilterKeys

func (m Map) FilterKeys(f func(interface{}) bool) []Hashable

filter (e, v) in the map using f(v), returns the keys

func (Map) Find

func (m Map) Find(e Hashable) (interface{}, bool)

finds the value of e in map

func (Map) Set

func (m Map) Set(e Hashable, v interface{})

sets the value of e to v

type OutputBuf

type OutputBuf struct {
	// contains filtered or unexported fields
}

func (*OutputBuf) AppendBigInt

func (o *OutputBuf) AppendBigInt(n int, x *big.Int)

func (*OutputBuf) AppendFieldElement

func (o *OutputBuf) AppendFieldElement(field SimpleField, x constraint.Element)

func (*OutputBuf) AppendIntSlice

func (o *OutputBuf) AppendIntSlice(x []int)

func (*OutputBuf) AppendUint32

func (o *OutputBuf) AppendUint32(x uint32)

func (*OutputBuf) AppendUint64

func (o *OutputBuf) AppendUint64(x uint64)

func (*OutputBuf) AppendUint8

func (o *OutputBuf) AppendUint8(x uint8)

func (*OutputBuf) Bytes

func (o *OutputBuf) Bytes() []byte

type SimpleField

type SimpleField interface {
	SerializedLen() int
	ToBigInt(c constraint.Element) *big.Int
	FromInterface(i interface{}) constraint.Element
}

type SourceInfo

type SourceInfo struct {
	File string
	Line int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL