Documentation ¶
Index ¶
- func Abs(a int) int
- func AllReturnEqual[T, U any](fs func(T) U, args []T) (U, error)
- func ApplyModulusBls12377(b string) string
- func ApplyModulusBn254(b string) string
- func AsBigEndian32Bytes(x int) (res [32]byte)
- func BigsToBytes(ins []*big.Int) []byte
- func BigsToInts(ints []*big.Int) []int
- func BytesEqual(expected, actual []byte) error
- func Copy[T any](dst []frontend.Variable, src []T) (n int)
- func Digest(src io.Reader) (string, error)
- func DivCeil(a, b int) int
- func DivExact(a, b int) int
- func FillRange[T constraints.Integer](dst []T, start T)
- func FmtInt32Bytes(v int) [32]byte
- func FmtIntHex32Bytes(v int) string
- func FmtUint32Bytes(v uint) [32]byte
- func GCD[T ~int](a, b T) T
- func HexConcat(v ...string) string
- func HexDecodeString(s string) ([]byte, error)
- func HexEncodeToString(b []byte) string
- func HexHashHex(v ...string) string
- func HexHashUint64(v ...uint64) string
- func IsPowerOfTwo[T ~int](n T) bool
- func Ite[T any](cond bool, ifSo, ifNot T) T
- func Join[T any](ts ...[]T) []T
- func KeccakHash(stream []byte) []byte
- func Log2Ceil(a int) int
- func Log2Floor(a int) int
- func Max[T constraints.Ordered](s ...T) T
- func Min[T constraints.Ordered](s ...T) T
- func NewElementFromBytes[T emulated.FieldParams](api frontend.API, bytes []frontend.Variable) *emulated.Element[T]
- func NextPowerOfTwo[T ~int64 | ~uint64 | ~uintptr | ~int | ~uint](in T) T
- func Panic(msg string, args ...any)
- func Partition[T any, I constraints.Integer](s []T, index []I) [][]T
- func PositiveMod[T ~int](a, n T) T
- func RangeSlice[T constraints.Integer](length int, startingPoints ...T) []T
- func ReadAllJsonFiles(dirPath string) (map[string][]byte, error)
- func ReadFromFile(path string, to io.ReaderFrom) error
- func ReadFromJSON(path string, v interface{}) error
- func ReduceBytes[T emulated.FieldParams](api frontend.API, bytes []frontend.Variable) []frontend.Variable
- func RegisterHints()
- func RepeatSlice[T any](s []T, n int) []T
- func Require(cond bool, msg string, args ...any)
- func RightPad[T any](s []T, n int) []T
- func RightPadWith[T any](s []T, n int, padWith T) []T
- func Sha2SumHexOf(w io.WriterTo) string
- func ToBytes(api frontend.API, x frontend.Variable) [32]frontend.Variable
- func ToInt[T ~uint | ~uint64 | ~int64](i T) int
- func ToUint16[T ~int | ~uint](i T) uint16
- func ToUint64[T constraints.Signed](i T) uint64
- func ToVariableSlice[X any](s []X) []frontend.Variable
- func ValidateHexString(joinToErr *error, x, errWrapper string, size int)
- func ValidateTimestamps(joinToErr *error, timestamps ...uint)
- func WrapErrsAlphabetically(errs []error) error
- func WriteToFile(path string, from io.WriterTo) error
- func WriteToJSON(path string, v interface{}) error
- func WriterstoEqual(expected, actual io.WriterTo) error
- type BytesEqualError
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllReturnEqual ¶
Iterates the function on all the given arguments and return an error if one is not equal to the first one. Panics if given an empty array.
func ApplyModulusBn254 ¶
Apply the modulus of the BLS12-377 scalar field
func AsBigEndian32Bytes ¶
Format an integer as a big-endian uint256
func BigsToBytes ¶
func BigsToInts ¶
func BytesEqual ¶
BytesEqual between byte slices a,b a readable error message would show in case of inequality TODO error options: block size, check forwards or backwards etc
func Digest ¶
Digest computes the SHA256 Digest of the contents of file and prepends a "0x" byte to it. Callers are responsible for closing the file. The reliance on SHA256 is motivated by the fact that we use the sum checksum for the verifier key to identify which verifier contract to use.
func FillRange ¶
func FillRange[T constraints.Integer](dst []T, start T)
func FmtInt32Bytes ¶
func FmtIntHex32Bytes ¶
Format an integer as a 32 bytes hex string
func FmtUint32Bytes ¶
func HexDecodeString ¶
func HexEncodeToString ¶
func HexHashHex ¶
Parse one or more hex string into a byte array, hash it and return the result as an hexstring. If several hex string are passed, what is hashed is the concatenation of the strings and the hasher is implictly updated only once. The hash function is Keccak.
func HexHashUint64 ¶
Encode the uint64 into an hexstring representing it as a u256 in bigendian form
func Join ¶
func Join[T any](ts ...[]T) []T
Join joins a set of slices by appending them into a new array. It can also be used to flatten a double array.
func KeccakHash ¶
Compute the keccak of a stream of bytes. Returns the hex string.
func Max ¶
func Max[T constraints.Ordered](s ...T) T
func Min ¶
func Min[T constraints.Ordered](s ...T) T
func NewElementFromBytes ¶
func NewElementFromBytes[T emulated.FieldParams](api frontend.API, bytes []frontend.Variable) *emulated.Element[T]
NewElementFromBytes range checks the bytes and gives a reduced field element
func NextPowerOfTwo ¶
NextPowerOfTwo returns the next power of two for the given number. It returns the number itself if it's a power of two. As an edge case, zero returns zero.
Taken from : https://github.com/protolambda/zrnt/blob/v0.13.2/eth2/util/math/math_util.go#L58 The function panics if the input is more than 2**62 as this causes overflow
func Partition ¶
func Partition[T any, I constraints.Integer](s []T, index []I) [][]T
func RangeSlice ¶
func RangeSlice[T constraints.Integer](length int, startingPoints ...T) []T
func ReadFromFile ¶
func ReadFromFile(path string, to io.ReaderFrom) error
func ReadFromJSON ¶
func ReduceBytes ¶
func ReduceBytes[T emulated.FieldParams](api frontend.API, bytes []frontend.Variable) []frontend.Variable
ReduceBytes reduces given bytes modulo a given field. As a side effect, the "bytes" are range checked
func RegisterHints ¶
func RegisterHints()
func RepeatSlice ¶
RepeatSlice returns the concatenation of `s` with itself `n` times
func RightPad ¶
RightPad copies `s` and returns a vector padded up to length `n`. The padding value is T's default. The padding value. The function panics if len(s) > n and returns a copy of s if len(s) == n.
func RightPadWith ¶
RightPadWith copies `s` and returns a vector padded up to length `n` using `padWith` as a filling value. The function panics if len(s) < n and returns a copy of s if len(s) == n.
func Sha2SumHexOf ¶
Returns a SHA256 checksum of the given asset. TODO @gbotrel merge with Digest Sha2SumHexOf returns a SHA256 checksum of the given asset.
func ToInt ¶
ToInt converts a uint, uint64 or int64 to an int, panicking on overflow. Due to its use of generics, it is inefficient to use in loops than run a "cryptographic" number of iterations. Use type-specific functions in such cases.
func ToUint64 ¶
func ToUint64[T constraints.Signed](i T) uint64
ToUint64 converts a signed integer into a uint64, panicking on negative values. Due to its use of generics, it is inefficient to use in loops than run a "cryptographic" number of iterations. Use type-specific functions in such cases.
func ToVariableSlice ¶
func ValidateHexString ¶
Appends a wrapped error to `err` if x is not a valid hexstring. The err wrapper must be a string of the form "err message : %w". Size if the expected length of the string. Set to -1 to ignore the length. The length refers to the number of encoded bytes, not the number of characters.
func ValidateTimestamps ¶
Validate that the timestamps are increasing.
func WrapErrsAlphabetically ¶
func WriteToJSON ¶
func WriterstoEqual ¶
Types ¶
type BytesEqualError ¶
type BytesEqualError struct { Index int // contains filtered or unexported fields }
func (*BytesEqualError) Error ¶
func (e *BytesEqualError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package csvtraces provides a way to read and write traces in CSV format.
|
Package csvtraces provides a way to read and write traces in CSV format. |